
嘗試居中但不起作用:
\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}
答案1
答案2
平常的做法\multicolumn{1}{<alignment>}{<content>}
會有幫助。另外,使用\mathbf{X}
來獲取X
在數學模式中用粗體代替\boldmath X
.此外,不必在每個單元格中手動切換到數學模式,>{$} r <{$}
標題中的規格就足夠了。
\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}
答案3
使用tabu
的\rowfont [alignment]{font spec}
命令:
\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}
\rowfont[c]{}
(如果您不希望第一行粗體,當然可以使用。)
不幸的是,\rowfont[c]
在數學模式下似乎被忽略了,我不明白為什麼。但如果你不需要數學模式,恕我直言,這是最簡單、最漂亮的解決方案。