1

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?

1

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .