6

This is my code

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}
\usepackage{array}

\begin{document}
\begin{enumerate}
    \item Tomas\verb+           +Thomas
    \item Maine\verb+           +Main
    \item Patty\verb+           +Patti
    \item Roberts\verb+         +Robertson
    \item Springfield\verb+     +Springvale
    \item Nixon\verb+           +Dixon

\end{enumerate}
\end{document}

What I am trying to achieve is to allow the names on the second column to aligh with each other. But the output is not what I wanted. First I tried to simply type space bar, but that failed because LaTex seems to treat multiple space as only one space Secondly I tried to use the \verb command to enclose the space. Again that failed. Haven't figured out why it is wrong though. Aren't \verb supposed to treat text within the delimiters to be verbatim?enter image description here I

Anyway, I guess I can input what I want into a tabular environment and adjust the size of the column, but that is so complicated. I wonder if there is an easier solution here?

  • To address the questions why the approaches you tried didn't work: (1) It's built into TeX to compress successive spaces into a single space; this makes it possible (not just much easier) to control uniform spacing and line breaking. (2) \verb uses a monospace font, while the "printable" elements starting the line use a proportionally spaced font, in which the width of each glyph may be different from others, and not the same width as the space. – barbara beeton May 1 at 12:53
  • The tabbing environment is also handy in such situations. (Added as a comment rather then an answer since the proposed solutions are a better fit) – Carel May 1 at 21:15
12

Perfect use of the tabto package:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}
\usepackage{array,tabto}

\begin{document}
\begin{enumerate}
    \item Tomas\tabto{1.5in}Thomas
    \item Maine\tabto{1.5in}Main
    \item Patty\tabto{1.5in}Patti
    \item Roberts\tabto{1.5in}Robertson
    \item Springfield\tabto{1.5in}Springvale
    \item Nixon\tabto{1.5in}Dixon
\end{enumerate}
\end{document}

enter image description here

| improve this answer | |
6

You can modify this to your needs

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}
\usepackage{array}
\newcommand{\abc}[1]{\makebox[5cm][l]{#1}}
\begin{document}
    \begin{enumerate}
        \item \abc{Tomas}           +Thomas
        \item \abc{Maine}           +Main
        \item \abc{Patty}           +Patti
        \item \abc{Roberts}         +Robertson
        \item \abc{Springfield}     +Springvale
        \item \abc{Nixon}           +Dixon

    \end{enumerate}
\end{document}
| improve this answer | |
5

There is great difference of the level of solution if you allow to put some tag before first word or only between them. If such tag is allowed then you can use the TeX primitive construction \hbox to<dimen> {text\hfil} which gives the box of declared size:

\def\p #1 {\leavevmode\hbox to4cm {#1\hfil}}

Then you can use

\item \p Tomas                  Thomas
\item \p Maine                  Main
\item \p Patty                  Patti
\item \p Roberts                Robertson
\item \p Springfield            Springvale
\item \p Nixon                  Dixon

The second case is much more complicated. I don't show it here unless the explicit needs are specified here.

| improve this answer | |
  • Although this works very well when only a single word is in the first column, it would fail if a two-part name (e.g., "de Gaulle") was in that position. – barbara beeton May 1 at 12:44

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.