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.

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! –  c.p. Feb 5 '13 at 14:25
add comment

1 Answer

It's not entirely clear what you want the output to look like, but it seems you are after using \multicolumn to adjust the alignment of a single cell, for example

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{tabular}{rl}
  \toprule
    \bfseries Frequency & \bfseries Callsign \\
    \multicolumn{1}{l}{kHz} \\
 \midrule
  2500 & WWV \\
  3330 & CHU \\
  \bottomrule
\end{tabular}

\end{document}

Note that longtabu (and tabu) have some 'unusual' interface choices, and for creating a demo I've stuck with the standard tabular environment.

share|improve this answer
add comment

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.