我正在尝试将命令插入\bfseries
到每一行\makecell
,但无法编译。MWE 如下:
\documentclass{article}
\usepackage{makecell}
\begin{document}
\begin{tabular}{l}
\makecell[{t}{>{\bfseries}l}]{Multi\\Line} \\ % error here!
Another Line
\end{tabular}
\begin{tabular}{>{\bfseries}l}
\makecell[{t}{l}]{Multi\\Line} \\ % works okay
Another line
\end{tabular}
\end{document}
答案1
要使 所有行具有通用格式\makecell
,您可以使用\renewcommand{\cellset}{…}
:
\documentclass{article}
\usepackage{makecell}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{l}
\renewcommand{\cellset}{\bfseries\color{red}}\makecell[tl]{Multi-\\Line} \\
\addlinespace
Another Line \\
\addlinespace
\makecell[lt]{Another\\multi-\\line}
\end{tabular}
\end{document}
答案2
该包makecell
已定义\thead
,您可以为其定义使用的字体参数。makecell
建议使用 执行以下操作:
\documentclass{article}
\usepackage{makecell}
\renewcommand\theadfont{\normalsize\bfseries}
\begin{document}
\begin{tabular}{l}
\thead{Multi\\Line} \\
Another Line
\end{tabular}
\qquad
\begin{tabular}{>{\bfseries}l}
\makecell{Multi\\Line} \\
Another line
\end{tabular}
\end{document}
结果是: