1

I'm writing a two columns document using the package multicol. In a two levels list, I would like to tab some text to the center of the column. Since I use this tab a lot, I previously defined the following command

\newcommand{\ta}{\tabto{0.5\columnwidth}}

Now, I would expect \columnwidth to remain the width of the entire column (in the same way as \textwidth should remain the width of the body). Instead, if I have nested, the tabbed text will end up at different positions.

result with unaligned tabbed text

This is a MWE

\documentclass[a4paper,table,10pt]{article}
\usepackage{tabto}
\usepackage{multicol}
\usepackage{vmargin}
\setpapersize[landscape]{A4}

\setmarginsrb{2cm}{2cm}{2cm}{2cm}{5pt}{2pt}{5pt}{23pt}
\newcommand{\ta}{\tabto{0.5\columnwidth}}
\begin{document}

\begin{multicols*}{2}

\ta The real center

\begin{itemize}
    \item First level: \ta text
    \begin{itemize}
        \item second level:\ta unaligned
    \end{itemize}
    \item Equation:\ta $a^2=b^2+c^2$
\end{itemize}


\end{multicols*}

\end{document}

The same behaviour is observable in one-column documents using \textwidth.

Am I missing something?

  • 2
    Why don't you look into the documentation of tabto? The first sentence already says "Tab to a position relative to the left margin in a paragraph (any indentation due to a list is part of the `margin' in this context)." – Ulrike Fischer Aug 18 '17 at 17:53
  • Shame on me. I looked into the documentation of multicol (without finding the solution) before discovering that the same behaviour could be observed in one-column documents and then embarassingly enough I didn't think at a possible explanation in tabto... – David Aug 19 '17 at 7:56
1

Thanks to @Ulrike Fischer for pointing out my negligence.

To have some text tabbed to mid-column, one just have to subtract the \leftmargin parameter of the current item.

Here a shorter version without using the multicol environment

\documentclass{article}
\usepackage{tabto}

\begin{document}

\tabto{0.5\textwidth} The real center

\begin{itemize}
    \item First level: \tabto{\dimexpr 0.5\textwidth - \the\leftmargini} text
    \begin{itemize}
        \item second level:\tabto{\dimexpr 0.5\textwidth - \the\leftmargini - \the\leftmarginii} 
              aligned
    \end{itemize}
    \item Equation:\tabto{\dimexpr 0.5\textwidth - \the\leftmargini} 
          $a^2=b^2+c^2$
\end{itemize}

\end{document}

enter image description here

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.