Math & SciencePlacement of "comma"/"point" between 2 lines of equations

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
juk80
Posts: 4
Joined: Thu Jun 23, 2022 3:16 pm

Placement of "comma"/"point" between 2 lines of equations

Post by juk80 »

Hi everybody,

I use the following code to define math operations, here a group operation.

Code: Select all

%preamble: centers content in an alignat cell, instead of left/right alignment 
\newcommand*\centermathcell[1]{\omit\hfil$\displaystyle#1$\hfil\ignorespaces}

% usage in text: definition of a binary operation with subequation label on each line 
\begin{subequations}
\begin{alignat}{5}
	& \circ  && \ :\quad && \centermathcell{G \times G } && \centermathcell{\quad\to\quad}     && G\\
	&        &&          && \centermathcell{(g, h)}      && \centermathcell{\quad\mapsto\quad} && g \circ h := \circ(g, h)
\end{alignat}
\end{subequations}
I like the style, but sometimes I need a "comma" or a "point" at the end of the definition (somehow between the 2 lines) in order to integrate it with the text flow (see pic attached, highlighted in yellow).
Can anyone help me with the placement of the "comma"/"point" at the end of the definition and still have the sub equation labels on each line.

Thx in advance.

Kind regards,
Jens
Attachments
output.PNG
output.PNG (10.99 KiB) Viewed 47960 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
MjK
Posts: 89
Joined: Fri Jan 28, 2022 6:09 pm

Placement of "comma"/"point" between 2 lines of equations

Post by MjK »

Please always try to make a Infominimal working example instead of showing only a code snippet.

To place the comma between the line, you could add a \raisebox after the longest line:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\newcommand*\centermathcell[1]{\omit\hfil$\displaystyle#1$\hfil\ignorespaces}

\begin{document}

\begin{subequations}
\begin{alignat}{5}
	& \circ  && \ :\quad && \centermathcell{G \times G } && \centermathcell{\quad\to\quad}     && G\\
	&        &&          && \centermathcell{(g, h)}      && \centermathcell{\quad\mapsto\quad} && g \circ h := \circ(g, h)\smash{\text{\quad\raisebox{.5\baselineskip}{,}}}
\end{alignat}
\end{subequations}

\end{document}
However, I would not add the comma centered, but just at the end of the last line:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\newcommand*\centermathcell[1]{\omit\hfil$\displaystyle#1$\hfil\ignorespaces}

\begin{document}

\begin{subequations}
\begin{alignat}{5}
	& \circ  && \ :\quad && \centermathcell{G \times G } && \centermathcell{\quad\to\quad}     && G\\
	&        &&          && \centermathcell{(g, h)}      && \centermathcell{\quad\mapsto\quad} && g \circ h := \circ(g, h)\text{\enskip,}
\end{alignat}
\end{subequations}

\end{document}
My main topics are KOMA-Script and other questions related to my packages. If I reply to any other topic or if you've not yet added a minimal working example, please do not expect any further response. And please don't forget to tag examples as code.
juk80
Posts: 4
Joined: Thu Jun 23, 2022 3:16 pm

Placement of "comma"/"point" between 2 lines of equations

Post by juk80 »

Thx MjK, this will work.
You are, of course, right about the minimal working example - duly noted!
Post Reply