我需要文本 CT1 1mm,另一个 CT... 被旋转并多行显示为两行。我不知道该怎么做。非常感谢 :)
\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage[dvipsnames]{xcolor}
\usepackage[geometry]{ifsym}
\usepackage{multirow}
\begin{document}
\begin {table} [H]
\centering
\begin{tabular}{|P{1cm}|P{4cm}|P{3cm}|P{2cm}|P{2cm}|}
\hline
& & Objem z DVH & a & $V_{exp}$ \\
& & [$cm^{3}$] & [cm] & [$cm^{3}$] \\
\hline
CT1 1mm & Medzi $10$ a $9,5 Gy$ & 7,82 & 0,97 & 8,73 \\
& Medzi $10,5$ a $10 Gy$ & 8,3 & 0,91 & 8,19 \\
\hline
CT1 3mm & Medzi $10$ a $9,5 Gy$ & 7,31 & 1 & 9 \\
& Medzi $10,5$ a $10 Gy$ & 8,43 & 0,98 & 8,82 \\
\hline
CT2 1mm & Medzi $10$ a $9,5 Gy$ & 8,02 & 1,01 & 9,09 \\
& Medzi $10,5$ a $10 Gy$ & 8,73 & 0,97 & 8,73 \\
\hline
CT2 3mm & Medzi $10$ a $9,5 Gy$ & 7,57 & 0,96 & 8,64 \\
& Medzi $10,5$ a $10 Gy$ & 7,91 & 0,91 & 8,19 \\
\hline
\hline
\end{tabular}
\caption{table}
\label{table}
\end {table}
答案1
我提出了三种解决方案,将旋转的标题放在两centred
行上。我在两种解决方案中加载了tabularx,
makecell to improve padding of cells and allow line breaks in cells,
booktabs`:
\documentclass[12pt]{article}
\usepackage{geometry} \usepackage{mathtools,amssymb}
\usepackage[dvipsnames]{xcolor}
\usepackage[geometry]{ifsym}
\usepackage{multirow, tabularx, makecell, rotating, graphicx, siunitx, booktabs}
\newcommand\rottitle[2]{\multirowcell{#1}{\rotatebox[origin =r]{90}{\begin{tabular}{@{}c@{}}#2\end{tabular}}}}%
\begin{document}
\begin {table}%
\centering\sisetup{table-format=1.2, table-number-alignment=center}
\setcellgapes{4pt}\makegapedcells
\begin{tabularx}{0.8\linewidth}{|c|X|*{3}{S|}}
\hline
& & {\makecell{Objem z DVH & & \\{} [\si{cm³}]}} & {\makecell{a \\{} [cm]}} & {\makecell{$V_{\text{exp}}$ \\{}[\si{cm³}]}}\\
\hline
\rottitle{2}{CT1 & & & & \\ 1\,mm} & Medzi $10$ a $9,5 Gy$ & 7,82 & 0,97 & 8,73 \\
& Medzi $10,5$ a $10 Gy$ & 8,3 & 0,91 & 8,19 \\
\hline
\rottitle{2}{CT1\\ 3\,mm}%
& Medzi $10$ a $9,5 Gy$ & 7,31 & 1 & 9 \\
& Medzi $10,5$ a $10 Gy$ & 8,43 & 0,98 & 8,82 \\
\hline
\rottitle{2}{CT2 & & & & \\ 1\,mm} & Medzi $10$ a $9,5 Gy$ & 8,02 & 1,01 & 9,09 \\
& Medzi $10,5$ a $10 Gy$ & 8,73 & 0,97 & 8,73 \\
\hline
\rottitle{2}{CT2 & & & & \\ 3\,mm }& Medzi $10$ a $9,5 Gy$ & 7,57 & 0,96 & 8,64 \\
& Medzi $10,5$ a $10 Gy$ & 7,91 & 0,91 & 8,19 \\
\hline
\hline
\end{tabularx}
\caption{table}
\label{table}
\end {table}
\begin {table}% [H]
\centering\sisetup{table-format=1.2, table-number-alignment=center}
\setcellgapes{3pt}\makegapedcells
\begin{tabularx}{0.8\linewidth}{cX*{3}{S}}
& & {\makecell{Objem z DVH & & \\{} [\si{cm³}]}} & {\makecell{a \\{} [cm]}} & {\makecell{$V_{\text{exp}}$\\{} [\si{cm³}]}}\\
\toprule
\rottitle{2}{CT1 & & & & \\ 1\,mm} & Medzi $10$ a $9,5 Gy$ & 7,82 & 0,97 & 8,73 \\
& Medzi $10,5$ a $10 Gy$ & 8,3 & 0,91 & 8,19 \\
\addlinespace
\rottitle{2}{CT1\\ 3\,mm}%
& Medzi $10$ a $9,5 Gy$ & 7,31 & 1 & 9 \\
& Medzi $10,5$ a $10 Gy$ & 8,43 & 0,98 & 8,82 \\
\cmidrule(lr){1-5}
\rottitle{2}{CT2 & & & & \\ 1\,mm} & Medzi $10$ a $9,5 Gy$ & 8,02 & 1,01 & 9,09 \\
& Medzi $10,5$ a $10 Gy$ & 8,73 & 0,97 & 8,73 \\
\addlinespace
\rottitle{2}{CT2 & & & & \\ 3\,mm }& Medzi $10$ a $9,5 Gy$ & 7,57 & 0,96 & 8,64 \\
& Medzi $10,5$ a $10 Gy$ & 7,91 & 0,91 & 8,19 \\
\bottomrule
\end{tabularx}
\caption{table}
\label{table}
\end {table}
\begin {table}% [H]
\centering\sisetup{table-format=1.2, table-number-alignment=center}
\setcellgapes{3pt}\makegapedcells
\begin{tabularx}{0.8\linewidth}{cX*{3}{S}}
& & {\makecell{Objem z DVH & & \\{} [\si{cm³}]}} & {\makecell{a \\{} [cm]}} & {\makecell{$V_{\text{exp}}$\\{} [\si{cm³}]}}\\
\cmidrule[\heavyrulewidth]{2-5}
\rottitle{2}{CT1 & & & & \\ 1\,mm} & Medzi $10$ a $9,5 Gy$ & 7,82 & 0,97 & 8,73 \\
& Medzi $10,5$ a $10 Gy$ & 8,3 & 0,91 & 8,19 \\
\cmidrule(lr){2-5}
\rottitle{2}{CT1\\ 3\,mm}%
& Medzi $10$ a $9,5 Gy$ & 7,31 & 1 & 9 \\
& Medzi $10,5$ a $10 Gy$ & 8,43 & 0,98 & 8,82 \\
\cmidrule(lr){2-5}
\morecmidrules
\cmidrule(lr){2-5}
\rottitle{2}{CT2 & & & & \\ 1\,mm} & Medzi $10$ a $9,5 Gy$ & 8,02 & 1,01 & 9,09 \\
& Medzi $10,5$ a $10 Gy$ & 8,73 & 0,97 & 8,73 \\
\cmidrule(lr){2-5}
\rottitle{2}{CT2 & & & & \\ 3\,mm }& Medzi $10$ a $9,5 Gy$ & 7,57 & 0,96 & 8,64 \\
& Medzi $10,5$ a $10 Gy$ & 7,91 & 0,91 & 8,19 \\
\cmidrule[\heavyrulewidth]{2-5}
\end{tabularx}
\caption{table}
\label{table}
\end {table}
\end{document}
答案2
好吧,我猜你想获得这样的东西:
对于上表,我添加了两个包:makecell
和,rotating
而siunitx
不是(未知)P{...}
使用标准c
,l
并使用S[...]
来自siunitx. For rotating of cells contents in the first column \the
\rothead from package
makecell`。希望代码是不言自明的......
\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
%\usepackage[dvipsnames]{xcolor}
%\usepackage[geometry]{ifsym}
\usepackage{siunitx}
\usepackage{makecell,multirow,rotating}
\renewcommand\theadfont{\normalsize}
\settowidth\rotheadsize{\theadfont 1 mm}
\begin{document}
\begin {table}[htb]
\renewcommand{\arraystretch}{1.1}
\centering
\begin{tabular}{|c|l|*{3}{S[table-format=2.3]|}}
\hline
& & {\thead{Objem z DVH\\ {[\si{cm^3}]}}}
& {\thead{a\\{[\si{cm^3}]}}}
& {\thead{$V_{exp}$\\ {[\si{cm^3}]}}} \\
\hline
\multirow{2}*[1ex]{\rothead{CT1 1mm}}
& Medzi $10$ a $9,5 Gy$ & 7,82 & 0,97 & 8,73 \\
& Medzi $10,5$ a $10 Gy$ & 8,3 & 0,91 & 8,19 \\
\hline
\multirow{2}*[1ex]{\rothead{CT1 3mm}}
& Medzi $10$ a $9,5 Gy$ & 7,31 & 1 & 9 \\
& Medzi $10,5$ a $10 Gy$ & 8,43 & 0,98 & 8,82 \\
\hline
\multirow{2}*[1ex]{\rothead{CT2 1mm}}
& Medzi $10$ a $9,5 Gy$ & 8,02 & 1,01 & 9,09 \\
& Medzi $10,5$ a $10 Gy$ & 8,73 & 0,97 & 8,73 \\
\hline
\multirow{2}*[1ex]{\rothead{CT2 3mm}}
& Medzi $10$ a $9,5 Gy$ & 7,57 & 0,96 & 8,64 \\
& Medzi $10,5$ a $10 Gy$ & 7,91 & 0,91 & 8,19 \\
\hline
\hline
\end{tabular}
\caption{My very important and nice table}
\label{table}
\end {table}
\end{document}
使用booktabs
规则并省略垂直规则表会更有吸引力: