36

I would like to align some text similar to how the align math environment works. I don't want to put the text in a table, because I don't want it to float. I tried putting the text in a tabular environment, but that doesn't flow well with the text before and after.

An example:

Here is some text before by aligned text
    S  Isomeric state
    Z  Atomic number
    A  Atomic mass number
Some text after the aligned text

Does that example make sense?

lockstep
  • 250,273
jlconlin
  • 10,172

2 Answers2

34

There are numerous ways to achieve this depending on the complexity of the alignment.

One way is to use \makebox to set the text into a fixed width size:

enter image description here

\documentclass{article}

\begin{document}
Here is some text before by aligned text\par
    \makebox[1.5cm]{S}  Isomeric state\par
    \makebox[1.5cm]{Z}  Atomic number\par
    \makebox[1.5cm]{A}  Atomic mass number\par
Some text after the aligned text
\end{document}

Depending on the complexity of the alignment, you can define macros to make the entry as above easier.


If you only have a list as in the example you have given, you could use simply use a list environment. Here is an an example use the enumitem package

\documentclass{article}
\usepackage{enumitem}

\begin{document}
\noindent
Here is some text before by aligned text
\begin{itemize}[leftmargin=2.0cm,labelsep=0.5cm]
\item[S] Isomeric state
\item[Z] Atomic number
\item[A] Atomic mass number
\end{itemize}
Some text after the aligned text
\end{document}

You could also use the tabular environment and not put it in a float:

\documentclass{article}

\begin{document}
\noindent
Here is some text before by aligned text

\begin{tabular}{rl}
    S& Isomeric state\\
    Z& Atomic number\\
    A& Atomic mass number
\end{tabular}

\noindent
Some text after the aligned text
\end{document}

Yet another option is to use the tabbing environment (suggested by @GonzaloMedina):

\documentclass{article}

\begin{document} 
\noindent
Here is some text before by aligned text
\begin{tabbing}
\hspace*{1em}\= \hspace*{2em} \= \kill % set the tabbings
    \> S\>  Isomeric state \\
    \>Z  \>Atomic number \\
    \>A  \>Atomic mass number
\end{tabbing}
Some text after the aligned text
\end{document}
David Carlisle
  • 757,742
Peter Grill
  • 223,288
  • Thank you for this answer. I had forgotten about the optional argument to the \item command. That is the way to go for my simple example. – jlconlin Oct 31 '11 at 17:31
  • Could you consider adding the use of a tabbing environment to your answer? I could then delete my answer, since yours covers a wider range of options. – Gonzalo Medina Oct 31 '11 at 17:31
  • @GonzaloMedina: Updated solution to include tabbing environment. – Peter Grill Oct 31 '11 at 17:41
6

Obviously not the most practical or elaborate solution, but I tend to simply use align in conjunction with \text{}, for not knowing anything else that is close enough from an exact replica of align without math display.

For example :

\documentclass{article}

\usepackage{amsmath}

\begin{document}

Here is some text before by aligned text
\begin{align*}
&\text{S}  &&\text{Isomeric state}\\
&\text{Z}  &&\text{Atomic number}\\
&\text{A}  &&\text{Atomic mass number}
\end{align*}
Some text after the aligned text.

\end{document}

which gives :

enter image description here

or

\documentclass{article}

\usepackage{amsmath}

    \begin{document}

        Here is some text before by aligned text
        \begin{align*}
         \text{S} \qquad &\text{Isomeric state}\\
        \text{Z}  \qquad &\text{Atomic number}\\
        \text{A}  \qquad &\text{Atomic mass number}
        \end{align*}
        Some text after the aligned text.

    \end{document}

for closer spacing :

enter image description here

  • I agree with you. The align environment is so good that, in some contexts, it is easier to use it. If it is not possible, I would suggest an aligned environment. If yet not possible, a tabular environment should work. – R. W. Prado Dec 01 '22 at 17:06