旋转除一个表头之外的所有表头

旋转除一个表头之外的所有表头

我想旋转所有表格标题,除了左上角的标题。附加的 MWE 可以完成这项工作,但由于一个标题未旋转,因此那里有一些空间。我怎样才能避免这个空间并使旋转的标题左对齐,靠近栏\midrule

梅威瑟:

\documentclass[b5paper, 11pt]{report}
\usepackage{booktabs,dcolumn}
\usepackage{array,graphicx}
\newcommand*\rot{\rotatebox{90}}
\newcommand*{\leftspecialcell}[2][t]{%
  \begin{tabular}[#1]{@{}l@{}}#2\end{tabular}%
}
\begin{document}
\begin{table}[hbr]\centering
\caption{Some caption}
\label{somelabel}
\begin{tabular}{lc}
\toprule
\leftspecialcell{Type of\\heat exchanger} &     \rot{\leftspecialcell{Adjacent\\ducts}}  \\ 
\midrule
Heat wheel              &   A \\    \bottomrule
\end{tabular}
\end{table}
\end{document}

答案1

您需要将第一个标题对齐到[b]

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs,graphicx}
\newcommand*\rot{\rotatebox{90}}
\newcommand*{\leftspecialcell}[2][t]{%
  \begin{tabular}[#1]{@{}l@{}}#2\end{tabular}%
}
\begin{document}
\begin{table}
  \centering
  \caption{Some caption}
  \begin{tabular}{ l c}
    \toprule
    \leftspecialcell[b]{Type of\\heat exchanger} & \rot{\leftspecialcell{Adjacent\\ducts}} \\
    \midrule
    Heat wheel              &   A \\    \bottomrule
  \end{tabular}
\end{table}

\end{document}

答案2

基于 的简单解决方案makecell,允许在单元格中换行,并且rotating。添加了caption包以在标题和表格之间实现更好的垂直间距:

\documentclass{article}
\usepackage{booktabs, rotating, caption}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadalign{lb}
\settowidth{\rotheadsize}{\theadfont Adjacent}

\begin{document}

\begin{table}
  \centering
  \caption{Some caption}
  \begin{tabular}{ l c}
    \toprule
    \thead{Type of & \\heat exchanger} & \rothead{Adjacent\\ducts} \\
    \midrule
    Heat wheel & A \\ \bottomrule
  \end{tabular}
\end{table}

\end{document} 

在此处输入图片描述

相关内容