2

This question already has an answer here:

How to align all the $\rightarrow$s so that that all come in a line and not in a zig zag manner?

The MWE:

\documentclass{article}
\usepackage[english]{babel}
\begin{document}
\begin{enumerate}
\item hello $\rightarrow$ world
\item sample $\rightarrow$ test
\item Mathematics $\rightarrow$ Physics
\end{enumerate}
\end{document} 

enter image description here

marked as duplicate by Mike Renfro, karlkoeller, user31729, user13907, Malipivo Dec 27 '14 at 17:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What about the align environment (\usepackage{mathtools} is needed for that) – user31729 Dec 27 '14 at 17:22
  • Can you be more detailed @ChristianHupfer – subham soni Dec 27 '14 at 17:23
  • @subhamsoni: Use \leavevmode\rlap{hello}\phantom{Mathematics} and \leavevmode\rlap{sample}\phantom{Mathematics}. – Werner Dec 27 '14 at 17:41
  • I don't see this really as a duplicate of the mentioned post, as the linked answers don't really stick to the fact that this is a list (which breaks across the page boundary). – Werner Dec 27 '14 at 17:53
  • @Werner I'm not seeing the difference yet. I made a few dozen copies of the three \item commands, including $\rightarrow$ symbols, and the larger list broke across pages and stayed aligned. – Mike Renfro Dec 27 '14 at 18:03
5

You can specify the widest entry

\documentclass{article}
\usepackage[english]{babel}
\usepackage{tabto}

\newenvironment{tenumerate}[1]
 {\settowidth{\dimen0}{#1 }% trailing space
  \TabPositions{\dimen0}%
  \enumerate}
 {\endenumerate}

\begin{document}

\begin{tenumerate}{Mathematics}
\item hello\tab $\rightarrow$ world
\item sample\tab $\rightarrow$ test
\item Mathematics\tab $\rightarrow$ Physics
\end{tenumerate}

\end{document}

enter image description here

Without specifying the widest entry, passing twice over the environment is necessary.

Here's a way using the .aux file

\documentclass{article}
\usepackage[english]{babel}
\usepackage{tabto}

\newcounter{tenumerate}
\newlength{\tenumtab}

\newenvironment{tenumerate}
 {\stepcounter{tenumerate}%
  \ifcsname tenumerate@\romannumeral\value{tenumerate}\endcsname
    \setlength{\tenumtab}{\csname tenumerate@\romannumeral\value{tenumerate}\endcsname}%
  \else
    \setlength{\tenumtab}{0pt}%
  \fi
  \edef\currenttenumtab{\the\tenumtab}%
  \TabPositions{\tenumtab}%
  \enumerate}
 {\writetenumtab\endenumerate}
\newcommand{\titem}[1]{%
  \settowidth{\dimen0}{#1 }%
  \ifdim\dimen0>\tenumtab \setlength{\tenumtab}{\dimen0}\fi
  \item #1\tab\ignorespaces
}
\makeatletter
\def\writetenumtab{%
  \immediate\write\@auxout{%
    \global\string\@namedef{tenumerate@\romannumeral\value{tenumerate}}{\the\tenumtab}%
  }%
  \ifdim\currenttenumtab=\tenumtab
  \else
    \@latex@warning{Tab position for `tenumerate' changed}%
  \fi
}
\makeatother


\begin{document}

\begin{tenumerate}
\titem{hello} $\rightarrow$ world
\titem{sample} $\rightarrow$ test
\titem{Mathematics} $\rightarrow$ Physics
\end{tenumerate}

\begin{tenumerate}
\titem{A} XXX
\titem{B} YYY
\titem{CCC} ZZZ
\end{tenumerate}

\end{document}

You're warned if the tab position changes so you need another LaTeX run.

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