Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Did you try using an itemize list with the optional argument? –  Joseph Wright Oct 31 '11 at 17:04
3  
I'd use a tabular –  egreg Oct 31 '11 at 17:05
    
@JosephWright, Yep thanks for the suggestion. –  Jeremy Oct 31 '11 at 17:30

1 Answer 1

up vote 8 down vote accepted

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}
share|improve this answer
    
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. –  Jeremy 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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