我使用 sidewaystable 旋转了表格,但第一行的前 4 个单元格和后 4 个单元格的垂直对齐方式不正确。有人能解决这个问题吗?
\documentclass[twoside,b5paper,12pt,fleqn]{psd_thesis}
\usepackage{amsmath,amssymb,amsfonts} \usepackage[T1]{fontenc}
\usepackage{newtxmath,newtxtext}
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage{tabulary}
% Include the following packages
\usepackage{amsmath}
\usepackage{array}
\usepackage{booktabs} % for \toprule, \midrule, and \bottomrule macros
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
%\begin{footnotesize}
\begin{sidewaystable}
\scriptsize
\centering
\begin{tabular}{ C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} }
%\begin{tabular}{c c c c c c c c c c c c c c}
\toprule
Sv,ieq & 000436xa & 000594xa & 001715xa & 001932ya & 006040ya & 006263xa & 007162ya & 007257ya & IT0605ya & IT0790xa & emiliaeo-retro & emilians-retro \\ \midrule
0.4 & 2.447 & 2.177 & 2.304 & 4.921 & 4.298 & 2.121 & 3.928 & 3.478 & 3.462 & 1.751 & 0.875 & 0.525 \\ \hline
0.8 & 4.894 & 4.354 & 4.609 & 9.843 & 8.597 & 4.241 & 7.857 & 6.957 & 6.924 & 3.502 & 1.750 & 1.049 \\ \hline
1.2 & 7.341 & 6.530 & 6.913 & 14.764 & 12.895 & 6.362 & 11.785 & 10.435 & 10.386 & 5.252 & 2.625 & 1.574 \\ \hline
1.6 & 9.789 & 8.707 & 9.218 & 19.686 & 17.194 & 8.482 & 15.713 & 13.914 & 13.848 & 7.003 & 3.500 & 2.099 \\ \hline
2 & 12.236 & 10.884 & 11.522 & 24.607 & 21.492 & 10.603 & 19.642 & 17.392 & 17.310 & 8.754 & 4.375 & 2.624 \\ \hline
2.4 & 14.683 & 13.061 & 13.827 & 29.529 & 25.791 & 12.723 & 23.570 & 20.871 & 20.772 & 10.505 & 5.250 & 3.148 \\ \hline
2.8 & 17.130 & 15.237 & 16.131 & 34.450 & 30.089 & 14.844 & 27.498 & 24.349 & 24.234 & 12.256 & 6.125 & 3.673 \\ \hline
3.2 & 19.577 & 17.414 & 18.435 & 39.372 & 34.388 & 16.965 & 31.427 & 27.828 & 27.697 & 14.006 & 7.000 & 4.198 \\ \hline
3.6 & 22.024 & 19.591 & 20.740 & 44.293 & 38.686 & 19.085 & 35.355 & 31.306 & 31.159 & 15.757 & 7.875 & 4.723 \\ \hline
4 & 24.471 & 21.768 & 23.044 & 49.215 & 42.984 & 21.206 & 39.283 & 34.784 & 34.621 & 17.508 & 8.750 & 5.247 \\ \hline
4.4 & 26.919 & 23.945 & 25.349 & 54.136 & 47.283 & 23.326 & 43.212 & 38.263 & 38.083 & 19.259 & 9.625 & 5.772 \\ \hline
4.8 & 29.366 & 26.121 & 27.653 & 59.058 & 51.581 & 25.447 & 47.140 & 41.741 & 41.545 & 21.009 & 10.500 & 6.297 \\ \hline
5.2 & 31.813 & 28.298 & 29.957 & 63.979 & 55.880 & 27.567 & 51.068 & 45.220 & 45.007 & 22.760 & 11.375 & 6.821 \\ \hline
5.6 & 34.260 & 30.475 & 32.262 & 68.900 & 60.178 & 29.688 & 54.996 & 48.698 & 48.469 & 24.511 & 12.250 & 7.346 \\ \hline
6 & 36.707 & 32.652 & 34.566 & 73.822 & 64.477 & 31.809 & 58.925 & 52.177 & 51.931 & 26.262 & 13.125 & 7.871 \\ \bottomrule
\end{tabular}
\caption{Caption}
\end{sidewaystable}
%\end{footnotesize}
\end{document}
psd_thesis.cls报告如下:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{psd_thesis}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
\ProcessOptions
\LoadClass{report}
\renewcommand{\baselinestretch}{1.5} % Double-spaced
\usepackage[round]{natbib} % bib style
%\usepackage[tx]{sfmath} % a package of fonts
%\usepackage{helvet} % For Helvetica (Arial is just a bad copy of Helvetica)
%\renewcommand\familydefault{\sfdefault}
\renewcommand{\@makechapterhead}[1]{%
\vspace*{50\p@}% {\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\large \scshape \bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\interlinepenalty\@M
\large \bfseries #1\par\nobreak
\vskip 40\p@ }}
\renewcommand{\@makeschapterhead}[1]{%
\vspace*{50\p@}%{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\large \scshape \bfseries #1\par\nobreak
\vskip 40\p@ }}
\renewcommand{\section}{\@startsection{section}% % the name{1}% % the level{0mm}% % the indent{3.0\baselineskip}% % the before skip{2.5\baselineskip}% % the after skip{\normalfont \normalsize}} % the style
\renewcommand{\subsection}{\@startsection{subsection}% % the name
{2}% % the level{0mm}% % the indent{-\baselineskip}% % the before skip{1.5\baselineskip}% % the after skip{\normalfont \normalsize}} % the style
\endinput
答案1
我使用文档类进行了测试book
,因为您的问题与的定义有关\newcolumtype
。相反,您尝试使用:
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
第一行文本的对齐方式将变为:
在测试中,我使用geometry
带有选项b5paper
和 的页面布局包showframe
。后一个选项仅用于查看页面布局。使用此选项,您的表格太宽,因此我还添加了\setlength\tabcolsep{3pt}
。所以我的序言和几行表格是:
\documentclass[twoside,12pt,fleqn]{book}
\usepackage[b5paper,showframe]{geometry}
\usepackage[T1]{fontenc}
%\usepackage{amsmath,amssymb,amsfonts}
%\usepackage{newtxmath,newtxtext}
%\usepackage{textgreek}
\usepackage{rotating}
%\usepackage{pdflscape}
%\usepackage{tabulary}
% Include the following packages
%\usepackage{amsmath} % second time ...
\usepackage{array}
\usepackage{booktabs} % for \toprule, \midrule, and \bottomrule macros
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\begin{sidewaystable}
\scriptsize
\setlength\tabcolsep{3pt}
\begin{tabular}{ C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} }
%\begin{tabular}{c c c c c c c c c c c c c c}
\toprule
Sv,ieq & 000436xa & 000594xa & 001715xa & 001932ya & 006040ya & 006263xa & 007162ya & 007257ya & IT0605ya & IT0790xa & emiliaeo-retro & emilians-retro \\ \midrule
\end{tabular}
\caption{Caption}
\end{sidewaystable}
\end{document}
附录: 首先离题。在我看来,如果你
- 使用包
S
中的列类型siunitx
\hline
省略表中所有内容
在这种情况下代码变成:
\documentclass[twoside,12pt,fleqn]{book}
\usepackage[b5paper,showframe]{geometry}
\usepackage[T1]{fontenc}
\usepackage{rotating}
\usepackage{booktabs} % for \toprule, \midrule, and \bottomrule macros
\usepackage{siunitx} % for better formatting columns with decimal numbers
\begin{document}
\begin{sidewaystable}
\scriptsize
\setlength\tabcolsep{3pt}
\begin{tabular}{@{}S[table-format=1.1]*{12}{S[table-format=2.3]}@{}}
\toprule
\multicolumn{11}{c}{} & \multicolumn{2}{c}{retro} \\
\cmidrule{12-13}
{Sv,ieq} & {000436xa} & {000594xa} & {001715xa} & {001932ya} & {006040ya} & {006263xa} & {007162ya} & {007257ya} & {IT0605ya} & {IT0790xa} & {emiliaeo} & {emilians} \\ \midrule
0.4 & 2.447 & 2.177 & 2.304 & 4.921 & 4.298 & 2.121 & 3.928 & 3.478 & 3.462 & 1.751 & 0.875 & 0.525 \\
0.8 & 4.894 & 4.354 & 4.609 & 9.843 & 8.597 & 4.241 & 7.857 & 6.957 & 6.924 & 3.502 & 1.750 & 1.049 \\
1.2 & 7.341 & 6.530 & 6.913 & 14.764 & 12.895 & 6.362 & 11.785 & 10.435 & 10.386 & 5.252 & 2.625 & 1.574 \\
...
\bottomrule
\end{tabular}
\caption{Caption}
\end{sidewaystable}
\end{document}
并给出:
关于您评论中的其他问题:
- 我的测试中的表格位于页面的中心
- 不要这样做。表格已经占据了整个文本高度,如果再缩小表格中的字体,将使其难以阅读。标题位于表格下方或上方也是很自然的
答案2
(我无法让您的自定义文档类工作 - 错误消息太多。在下文中,我使用report
文档类,主要是因为该类psd_thesis
似乎是建立在该类之上的report
。)
首先,您需要确保表格适合文本块。(从您发布的屏幕截图可以看出,您的表格目前太宽了。)我建议您使用环境tabularx
(宽度设置为\textwidth
),而不是tabular
具有固定宽度列的环境。删除列类型\hspace{0pt}
定义中的 AFAICT 不必要的指令C
可以让您摆脱遇到的垂直间距异常。
我还想建议您将数字与各自的小数点对齐;这将使读者更容易真正理解您想要提供的信息。还请考虑删除所有\hline
指令,并在每五个数据行后添加一些垂直空格。
\documentclass[twoside,b5paper,12pt,fleqn]{report}
\usepackage{geometry,amsmath,amssymb,amsfonts}
\usepackage[T1]{fontenc}
\usepackage{newtxmath,newtxtext}
\usepackage{rotating,tabularx,booktabs,siunitx,caption}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand\mc[1]{\multicolumn{1}{C}{#1}} % handy shortcut macro
\begin{document}
\begin{sidewaystable}
\scriptsize
\captionsetup{size=scriptsize} % match font size to body of table
\setlength\tabcolsep{3pt} % less space between columns
\setlength\extrarowheight{2pt}
\begin{tabularx}{\textwidth}{@{}
S[table-format=1.1] *{11}{S[table-format=2.3]} S[table-format=1.3] @{}}
\toprule
{Sv,ieq} & \mc{000436xa} & \mc{000594xa} & \mc{001715xa} & \mc{001932ya} &
\mc{006040ya} & \mc{006263xa} & \mc{007162ya} & \mc{007257ya} &
\mc{IT0605ya} & \mc{IT0790xa} & \mc{emiliaeo-retro} & \mc{emilians-retro} \\
\midrule
0.4 & 2.447 & 2.177 & 2.304 & 4.921 & 4.298 & 2.121 & 3.928 & 3.478 & 3.462 & 1.751 & 0.875 & 0.525 \\
0.8 & 4.894 & 4.354 & 4.609 & 9.843 & 8.597 & 4.241 & 7.857 & 6.957 & 6.924 & 3.502 & 1.750 & 1.049 \\
1.2 & 7.341 & 6.530 & 6.913 & 14.764 & 12.895 & 6.362 & 11.785 & 10.435 & 10.386 & 5.252 & 2.625 & 1.574 \\
1.6 & 9.789 & 8.707 & 9.218 & 19.686 & 17.194 & 8.482 & 15.713 & 13.914 & 13.848 & 7.003 & 3.500 & 2.099 \\
2 & 12.236 & 10.884 & 11.522 & 24.607 & 21.492 & 10.603 & 19.642 & 17.392 & 17.310 & 8.754 & 4.375 & 2.624 \\
\addlinespace % a bit more space after every 5th row
2.4 & 14.683 & 13.061 & 13.827 & 29.529 & 25.791 & 12.723 & 23.570 & 20.871 & 20.772 & 10.505 & 5.250 & 3.148 \\
2.8 & 17.130 & 15.237 & 16.131 & 34.450 & 30.089 & 14.844 & 27.498 & 24.349 & 24.234 & 12.256 & 6.125 & 3.673 \\
3.2 & 19.577 & 17.414 & 18.435 & 39.372 & 34.388 & 16.965 & 31.427 & 27.828 & 27.697 & 14.006 & 7.000 & 4.198 \\
3.6 & 22.024 & 19.591 & 20.740 & 44.293 & 38.686 & 19.085 & 35.355 & 31.306 & 31.159 & 15.757 & 7.875 & 4.723 \\
4 & 24.471 & 21.768 & 23.044 & 49.215 & 42.984 & 21.206 & 39.283 & 34.784 & 34.621 & 17.508 & 8.750 & 5.247 \\
\addlinespace
4.4 & 26.919 & 23.945 & 25.349 & 54.136 & 47.283 & 23.326 & 43.212 & 38.263 & 38.083 & 19.259 & 9.625 & 5.772 \\
4.8 & 29.366 & 26.121 & 27.653 & 59.058 & 51.581 & 25.447 & 47.140 & 41.741 & 41.545 & 21.009 & 10.500 & 6.297 \\
5.2 & 31.813 & 28.298 & 29.957 & 63.979 & 55.880 & 27.567 & 51.068 & 45.220 & 45.007 & 22.760 & 11.375 & 6.821 \\
5.6 & 34.260 & 30.475 & 32.262 & 68.900 & 60.178 & 29.688 & 54.996 & 48.698 & 48.469 & 24.511 & 12.250 & 7.346 \\
6 & 36.707 & 32.652 & 34.566 & 73.822 & 64.477 & 31.809 & 58.925 & 52.177 & 51.931 & 26.262 & 13.125 & 7.871 \\
\bottomrule
\end{tabularx}
\caption{Caption}
\end{sidewaystable}
\end{document}