3

Tried centering but that did not work:

\begin{longtabu}{|r|r|} %\textwidth
\hline
\centering \boldmath  $X$ & \centering \boldmath $Y$ \tabularnewline
\hline 
$-9.644$ &  $93.000$   \\
\hline
$1.997$ &  $3.988$   \\
\hline
\end{longtabu}

3 Answers 3

2

without of help of any packages:

\begin{longtabu}{|r|r|} %\textwidth
\hline
\multicolumn{1}{|c|}{$\bm{X}$} & \multicolumn{1}{c|}{$\bm{Y}$} \tabularnewline
\hline 
$-9.644$ &  $93.000$   \\
\hline
$1.997$ &  $3.988$   \\
\hline
\end{longtabu}

for \bm is needed package bm

enter image description here

1
  • Added the pipes around c as in |c| and it worked fine!
    – ajeh
    Nov 17, 2016 at 19:06
1

The usual \multicolumn{1}{<alignment>}{<content>} can help. Also, use \mathbf{X} to get X bold in mathmode instead of \boldmath X. Furthermore, instead of manually switching to mathmode in each cell, the >{$} r <{$} specification in the header will suffice.

\documentclass{article}
\usepackage{longtable,tabu}
\begin{document}

\begin{longtabu}{| >{$}r<{$} | >{$}r<{$} |} %\textwidth
\hline
\multicolumn{1}{|c|}{$\mathbf{X}$} & \multicolumn{1}{c|}{$\mathbf{Y}$} \\
\hline 
-9.644 & 93.000  \\
\hline
1.997  & 3.988   \\
\hline
\end{longtabu}

\end{document}

enter image description here

0

Use tabu's \rowfont [alignment]{font spec} command:

\documentclass{article}
\usepackage{tabu}
\begin{document}

\begin{tabu} to 15em {| X[r] | X[r] |} \hline
\everyrow{\hline}
\rowfont[c]{\bfseries}
X & Y \\
-9.644 & 93.000 \\
1.997 & 3.988 \\
\end{tabu}

\end{document}

output of the above code

(If you don't want the first line bold, you could just use \rowfont[c]{}, of course.)

Unfortunately the \rowfont[c] seems ignored when in math mode, I don't get why. But if you don't need math mode it's the simplest and prettiest solution imho.

You must log in to answer this question.

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