6

I would like to align some maths items listed in an itemize list. Is this possible without hacking with lots of phantom symbols? Here's a MWE to play and have fun with:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.1}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document}

Blablabla:
\medskip
\begin{itemize}
\renewcommand{\labelitemi}{$\circ$}
    \item Some comment: $y^2 = x$,
    \smallskip
    \item Another small comment: $a x = z$,
    \smallskip
    \item Insert a joke here: $x - y = z$.
\end{itemize}
\medskip
Blablabla.
\end{document}

Here's a small preview to make you laugh, with my issue shown in red:

enter image description here

As you have guessed, I want the maths expressions to be left aligned, while the text stays in place. Is this funny trick possible?

1
  • You may want to accept one of these nice answers. Commented May 24, 2020 at 11:28

5 Answers 5

4

You can use eqparbox for that. In

\eqmakebox[meow][l]{<content>} 

meow is an identifier, all boxes with this identifier will have the same width after the second run, and l is the alignment.

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.1}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{eqparbox}
\begin{document}

Blablabla:
\medskip
\begin{itemize}
\renewcommand{\labelitemi}{$\circ$}
    \item \eqmakebox[meow][l]{Some comment:} $y^2 = x$,
    \smallskip
    \item \eqmakebox[meow][l]{Another small comment:} $a x = z$,
    \smallskip
    \item \eqmakebox[meow][l]{Insert a joke here:} $x - y = z$.
\end{itemize}
\medskip
Blablabla.
\end{document}

enter image description here

I would also like to encourage you to use the enumitem package instead of the more manual adjustments in the list. I will be happy to spell this out if needed.

7
  • 1
    What a funny tabby, you are! ;-). Is there any other trick to do this, without loading another package?
    – Cham
    Commented Jan 9, 2020 at 2:35
  • @Cham You could basically repeat what eqparbox does: collect the widths of the boxes, write them to the aux file and then make sure that all of them have the maximal width. The eqmakebox is not a big package that takes long to load.
    – user194703
    Commented Jan 9, 2020 at 2:38
  • 1
    @Cham I mean with enumitem you could just use something like \begin{itemize}[itemsep=1ex,label={$\circ$}] instead of adding \smallskip by hand and adding \renewcommand{\labelitemi}{$\circ$}.
    – user194703
    Commented Jan 9, 2020 at 2:40
  • Ah yeah, I knew that last one. Just forgot about it (there are so much options in LaTeX, I can't memorize all of them!).
    – Cham
    Commented Jan 9, 2020 at 2:42
  • Meow? What do you think of my solution below? Tabbing the tabbies may be cool. ;-)
    – Cham
    Commented Jan 9, 2020 at 2:58
3

The usage of eqparbox has already been suggested. While the answer is mostly fine and the code works, it becomes tedious and error prone having to emit a different “meow” each time the construction is used.

The problem is that in the code meow stands for an arbitrary label, but this label should be unique for each series of \eqparbox bits.

Here's a simplification that also gets rid of all your manually added skips.

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumitem,eqparbox}

\newenvironment{tabbeditems}
 {%
  \begin{itemize}[
    topsep=\medskipamount,
    itemsep=\smallskipamount,
    label=$\circ$,
  ]%
  \stepcounter{tabbeditem}
 }
 {\end{itemize}}
\newcounter{tabbeditem}
\renewcommand{\thetabbeditem}{\arabic{tabbeditem}TI}
\newcommand{\tabitem}[1]{\item\eqmakebox[\thetabbeditem][l]{#1}}

\begin{document}

Blablabla
\begin{tabbeditems}
\tabitem{Some comment:} $y^2 = x$,

\tabitem{Another small comment:} $a x = z$,

\tabitem{Insert a joke here:} $x - y = z$.
\end{tabbeditems}
Blablabla.
\begin{tabbeditems}
\tabitem{A comment:} $y^2 = x$,

\tabitem{A comment:} $a x = z$,

\tabitem{Joke:} $x - y = z$.
\end{tabbeditems}

\end{document}

As you see, the unique label is automatically supplied. It may take a couple of LaTeX run for the thing to synchronize.

enter image description here

2

Here's a solution which only requires the use of the array package.

enter image description here

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[total={6in,10in}, left=1.5in, top=0.5in,
            includehead, includefoot]{geometry}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.1}
%\usepackage{amsmath} % amsmath package is loaded automatically by mathtools package
\usepackage{mathtools}

\usepackage{array}
\newcolumntype{L}{>{$}l<{$}}
\newcommand{\listtab}[1]{\begingroup\par\medskip%
  \renewcommand\arraystretch{1.25}
  \begin{tabular}{>{$\circ$\,\,} l L @{}}
     #1
  \end{tabular}%
  \endgroup\par\medskip\noindent\ignorespaces}

\begin{document}
\noindent
Blablabla:
\listtab{
   Some comment:          & y^2 = x,\\
   Another small comment: & a x = z,\\
   Insert a joke here:    & x - y = z .}
Blablabla.
\end{document}
1

Since I was already loading the tabto package, I've found a nice solution to my issue:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.1}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{tabto}
\usepackage{enumitem}
\begin{document}

Blablabla:
\medskip
\begin{itemize}[label=$\circ$]
    \item Some comment: \tabto*{2in} $y^2 = x$,
    \smallskip
    \item Another small comment: \tabto*{2in} $a x = z$,
    \smallskip
    \item Insert a joke here: \tabto*{2in} $x - y = z$.
\end{itemize}
\medskip
Blablabla.
\end{document}

This tabby trick does the trick. However, I have to eye adjust the tabbies, so I'm not sure this is a proper solution.

About the tabto package: http://tug.ctan.org/macros/latex/contrib/tabto/tabto-doc.pdf

1
  • Meow! (no translation needed)
    – user194703
    Commented Jan 9, 2020 at 2:59
0

The following is similar to an eqparbox approach, using boxes to space things out evenly. Place the smaller items inside \makebox[0pt][l] (left-aligned, zero-width) boxes with the widest element inside a \phantom to have the appropriate horizontal spacing.

enter image description here

\documentclass{article}

\usepackage{enumitem}

\begin{document}

Blablabla:
\begin{itemize}[
  label=$\circ$,
  before=\medskip,
  itemsep=\smallskipamount,
  after=\medskip
]
  \item \makebox[0pt][l]{Some comment:}\phantom{Another small comment: }$y^2 = x$,

  \item Another small comment: $a x = z$,

  \item \makebox[0pt][l]{Insert a joke here:}\phantom{Another small comment: }$x - y = z$.
\end{itemize}
Blablabla.

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .