# How to Align Lines with Comments with other Lines in Math-mode

When I use the \tag command to add a comment in line in math-mode, sometimes that line becomes off-centre and doesn't align with the rest of the equations. Here is example of a code and its output:

\documentclass[a4paper, 11pt, letterpaper]{article}
\usepackage{comment}
\usepackage{fullpage}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{mathtools,amsthm}
\begin{document}
$\mathrm{cosec}^2 (x-200^{\circ}) =2 \tag{-150 ^{\circ} \leq x-200^{\circ} \leq 150 ^{\circ}}$
$\sin ^2 (x-200 ^{\circ}) = \f 12$
$\sin (x-200 ^{\circ}) = \pm \f{1}{\sqrt{2}}$
$x-200 ^{\circ} = 45 ^{\circ}, 135 ^{\circ}, -45 ^{\circ}, -135 ^{\circ}$
$x= 65^{\circ}, 155 ^{\circ}, 245^{\circ}, 335 ^{\circ}$
\end{document}


I have tried using the align* environment but then all the equations become a bit off-centre. Also it doesn't look as aesthetic when all the equations are aligned by the equal sign. I would like a solution which still keeps all the equations in the centre of the page.

Thanks for any help!

• This code won't produce any output unless you provide the missing \begin{document} and \end{document}. And this is not how the \tag command is to be used. As the name suggests, it tags an equation. – user121799 Feb 7 '18 at 22:18
• @marmot oh thanks for mentioning that , I completely forgot to add that in – Nanoputian Feb 7 '18 at 23:45

You can use the flalign* environments, and a medium-sized comment, with the \medmath command, from nccmath. Other solution, nicer in my opinion: two independent aligned environments within gather*:

\documentclass[a4paper, 11pt, letterpaper]{article}
\usepackage{amssymb, amsthm}
\usepackage{mathtools, nccmath}
\DeclareMathOperator{\cosec}{cosec}

\begin{document}

\begin{flalign*}
& & \cosec ^2 (x-200^{\circ}) & = 2 & & \mathllap{(\medmath{-150 ^{\circ} \leq x-200^{\circ} \leq 150 ^{\circ}})} \\
& & \sin ^2 (x-200 ^{\circ}) & = \frac12 \\
& & \sin (x-200 ^{\circ}) & = \pm \frac{1}{\sqrt{2}} \\
& & x-200 ^{\circ} & = 45 ^{\circ}, 135 ^{\circ}, -\mathrlap{45 ^{\circ}, -135 ^{\circ}} \\
& & x & = 65^{\circ}, 155 ^{\circ}, \mathrlap{245^{\circ}, 335 ^{\circ}}
\end{flalign*}
\bigskip
\begin{gather*}
\begin{aligned}
\cosec ^2 (x-200^{\circ}) & = 2 & & \mathrlap{(\medmath{-150 ^{\circ} = \leq x-200^{\circ} \leq 150 ^{\circ}})} \\
\sin ^2 (x-200 ^{\circ}) & = \frac12 \\
\sin (x-200 ^{\circ}) & = \pm \frac{1}{\sqrt{2}}
\end{aligned}\\[1ex]
\begin{aligned}
x-200 ^{\circ} & = 45 ^{\circ}, 135 ^{\circ}, - 45 ^{\circ}, -135 ^{\circ} \\
x & = 65^{\circ}, 155 ^{\circ}, 245^{\circ}, 335 ^{\circ}
\end{aligned}
\end{gather*}

\end{document}


• Thank you for your answer. However is there a way to make the comment to be at the very right of the line like when you use the \tag command? Also for the second example, does aligned has to be specifically used? Can align* be used as well? If it can't could you please explain why so? Thanks! – Nanoputian Feb 8 '18 at 0:07
• The first example (with flalign*) does it.. From my point of view, it would make sense if all (or at least most) rows were commented. Using align* will yield something more or less like the first example. I think the last two equations, while similar, are quite different form the first three. That's why I used two aligned environments, so each group is centred, but each row is aligned within its group. – Bernard Feb 8 '18 at 0:21

I would keep it simple: there's no need to align at equals signs; moreover, the parenthetical condition is not a comment, but part of the equation.

\documentclass[a4paper,11pt]{article}
\usepackage{amsmath}

\DeclareMathOperator{\cosec}{cosec}
\newcommand{\dg}{^{\circ}}

\begin{document}

\begin{align*}
&\! \cosec ^2 (x-200\dg) = 2 \qquad (-150\dg \leq x-200\dg \leq 150\dg) \\
&\! \sin ^2 (x-200\dg) = \frac12 \\
&\! \sin (x-200\dg) = \pm \frac{1}{\sqrt{2}} \\
& x-200\dg = 45\dg, 135\dg, -45\dg, -135\dg \\
& x = 65\dg, 155\dg, 245\dg, 335\dg
\end{align*}

\end{document}


The \! after = are necessary, because LaTeX inserts a thin space after odd numbered & in align, which would cause misalignment of the operators (not when & is followed by x).

Using a macro such as \dg makes for faster typing and ensures uniformity.

By the way, specifying both a4paper and letterpaper is wrong: use only the option corresponding to your paper format (if it is US Letter, then letterpaper` can be omitted because it's the default).