2

I would like to left-align a few equations inside the alignat* environment, but I am not sure how to achieve this. Essentially, what I want is something that behaves like flalignbut lets me align the terms just like alignat. However, using fleqn to align all equations in the document is not an option for me, since I only want to left-align them in one instance. I looked around and found this question and this one. I don't think that these answer my question though, but I am fairly new to using LaTeX, so please forgive my cluelessness in case they do.

If there is a way to create a list and then align the terms in the list that would also work for me, however I got the warning message that I cannot use lists inside a math environment, but that is the only way I know how to align equations.

Example with all the packages I use in my document:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{natbib}
\usepackage{xcolor}
\usepackage{amsmath,amsfonts}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{enumitem}
\usepackage{amsthm}
\newtheorem{innercustomthm}{Theorem} % I use this because I want to number my theorems myself
\newenvironment{customthm}[1]
  {\renewcommand\theinnercustomthm{#1}\innercustomthm}
  {\endinnercustomthm}

\begin{document}
\begin{customthm}{5.3.9}[Properties of the transpose]
\begin{alignat*}{3}
    &\textbf{\textup{(a) }} (A+B)^T &&= A^T + B^T \qquad && \forall ~n \times n \text{ matrices A and B}. \\
    &\textbf{\textup{(b) }} (kA)^T &&= kA^T  && \forall \text{ matrices A, scalars k}. \\
\end{alignat*}
\end{customthm}
\end{document} 

The way it is aligned is great, but I need it to be on the left. As I mentioned above, if there is a way to make a list and align it from within that list, then that would also be great (even better maybe, since I wouldn't have to put (a), (b), etc. myself), but I couldn't figure out how to do this. Thanks a lot in advance, I hope I formulated the question clearly.

Current output. I want Theorem 5.3.9 to be on the left.

P.S.: In case you are wondering why I need this, I am only writing a summary for myself right now, but would like to get better in LaTeX, hence I'm doing it this way, two birds with one stone...

1 Answer 1

1

It seems more appropriate here to set the list of items in the theorem using a regular list. Since you're loading enumitem already, formatting of the list elements is easy. Together with eqparbox's \eqmakebox[<tag>][<align>]{<stuff>}, you can set the horizontal alignment across \items:

enter image description here

\documentclass{article}

\usepackage{mathtools}
\usepackage{enumitem,eqparbox}
\usepackage{amsthm}

\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}[Properties of the transpose]
  \begin{alignat*}{3}
    &\textbf{\textup{(a) }} (A+B)^T &&= A^T + B^T \qquad && \forall ~n \times n \text{ matrices A and B}. \\
    &\textbf{\textup{(b) }} (kA)^T &&= kA^T  && \forall \text{ matrices A, scalars k}.
  \end{alignat*}
\end{theorem}

\begin{theorem}[Properties of the transpose]
  \mbox{}
  \begin{enumerate}[label=\textbf{\upshape(\alph*)}, ref=(\alph*)]
    \item $\eqmakebox[LHS][l]{$(A+B)^T$} = \eqmakebox[RHS][l]{$A^T + B^T~$} \forall~n \times n$ matrices $A$ and $B$.
    \item $\eqmakebox[LHS][l]{$(kA)^T$}  = \eqmakebox[RHS][l]{$kA^T$}       \forall~n$ matrices $A$, scalars $k$.
  \end{enumerate}
\end{theorem}

\end{document}
5
  • Thank you, that worked. Could you tell me what the difference is between the empty \mbox argument and something like ~\\ ? To me it looks like the latter makes the vertical offset a bit bigger, but can/should I always use \mbox{} in situation like these? Thanks for the clarification!
    – davebc112
    Nov 18, 2019 at 20:22
  • Cannot edit my earlier comment for whatever reason. Just wanted to add that ~ seems - to my layman's eye at least - to do the same as \mbox{}...
    – davebc112
    Nov 18, 2019 at 20:58
  • @davebc112: It's similar. They're may be problems when the theorem is at the bottom of the page, since the start of a list can be used as a possible page break.
    – Werner
    Nov 18, 2019 at 21:25
  • Ok, I shall use \mbox{} in these situations then. Just a small follow-up question: Is there a way to use alignment character & in lists? I added a \qquad in front of the \forall on all five lines, but out of interest (and a bit of lazyness), is there a (simple) way to only add the spacing once and then just align the other \foralls at that point?
    – davebc112
    Nov 19, 2019 at 12:42
  • @davebc112: The alignment character & does not work within a list. I'd suggest including the \qquad as part of the \eqmakebox[RHS][l] that is the largest. eqparbox stores the maximum width by <tag>, so adding it to the largest (widest) element would necessarily add it to all other \eqmakebox[RHS][l]'s.
    – Werner
    Nov 19, 2019 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.