Tell me more ×
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.

After some brute-force attempts I found out that I could right-align two lines in a longtabu cell as follows:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}

\usepackage{booktabs}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{xcolor}

\begin{document}

\newcommand{\desc}[2]{ \begin{minipage}[t]{6em} \hfill \textbf{#1}\\  \footnotesize \raggedleft #2 \end{minipage} }

\begin{longtabu} to \linewidth{r l}
 \desc{Frequency}{kHz} & \bfseries Callsign \\ \toprule
\endhead
2500 & WWV \\
3330 & CHU
\end{longtabu}

\end{document}

Both lines aligned to the right

When I change the second line to use \hfill it is aligned to the left:

\newcommand{\desc}[2]{ \begin{minipage}[t]{6em} \hfill \textbf{#1}\\  \footnotesize \hfill #2 \end{minipage} }

With hfill for both lines

And if I try to use \raggedleft for the whole minipage, like this:

\newcommand{\desc}[2]{ \begin{minipage}[t]{6em} \raggedleft \textbf{#1}\\  \footnotesize  #2 \end{minipage} }

then the document does not compile anymore. Why not? In any Office program I would just select the cell content and press the “right aligned” button, is LaTeX really that complicated?

share|improve this question
1  
Welcome to TeX.SX! – Jorge Campos Feb 5 at 14:25

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.