테이블 때문에 좀 고민이네요. 테이블의 코드는 다음과 같습니다.
\documentclass{report}
\usepackage{booktabs}
\usepackage{array}
\newcommand*\rotbf[1]{\rotatebox{90}{\textbf{#1}}}
\newcommand{\specialcell}[2][c]{\begin{tabular}[#1]{@{}l@{}}#2\end{tabular}}
\begin{document}
\begin{table}[hbr]
\centering
\label{tbl:heatwheel_res}
\begin{tabular}{llll}
\toprule
\textbf{Parameter} & \specialcell{Exhaust\\air} & \specialcell{Exhaust and \\ outdoor air} & \specialcell{Heat wheel\\(80~\%)} \\
\midrule
Heat recovery [\%] & 89,6 \% & 89,6 \% & 77,4 \% \\
Real heat recovery [\%] & 50,5 \% & 52,1 \% & - \\
Net energy need for VH and SH & 27,7 & 27,0 & 15,8 \\
\specialcell{Delivered energy for\\DHW, VH and SH} & 31,1 & 27,6 & 45,6 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
\specialcell
너무 긴 요소의 줄을 끊기 위해 사용하고 있습니다 . 그러나 첫 번째 행의 텍스트를 굵게 표시하고 싶습니다. \textbf{}
내부에 추가하면 \specialcell
문서가 컴파일되지 않습니다. 오류 메시지는 " Missing } inserted
"입니다.
의견 있으십니까? \specialcell2
자동으로 굵게 표시되는 새로운 특수셀( )을 만들 수 있나요 ?
또 다른 질문: 첫 번째 열과 두 번째 열 사이의 공간을 늘리기 위해 테이블을 조금 더 넓게 만들려면 어떻게 해야 합니까? 4행에서는 1열과 2열이 너무 가까운 것 같아요.
답변1
\specialcell
굵게 표시되어야 하는 전체 외부 셀은 \bfseries
다음 바로 앞에 외부 셀에 지정될 수 있습니다 \specialcell
.
... & \bfseries\specialcell{...} & ...
이는 매크로에 넣을 수도 있습니다 \specialcellbold
. 다음 예를 참조하세요.
\documentclass{report}
\usepackage{booktabs}
\usepackage{array}
\newcommand*\rotbf[1]{\rotatebox{90}{\textbf{#1}}}
\newcommand{\specialcell}[2][c]{\begin{tabular}[#1]{@{}l@{}}#2\end{tabular}}
\newcommand{\specialcellbold}[2][c]{%
\bfseries
\begin{tabular}[#1]{@{}l@{}}#2\end{tabular}%
}
\begin{document}
\begin{table}[hbr]
\centering
\label{tbl:heatwheel_res}
\begin{tabular}{llll}
\toprule
\textbf{Parameter} &
\specialcellbold{Exhaust\\air} &
\specialcellbold{Exhaust and\\ outdoor air} &
\specialcellbold{Heat wheel\\(80~\%)} \\
\midrule
Heat recovery [\%] & 89,6 \% & 89,6 \% & 77,4 \% \\
Real heat recovery [\%] & 50,5 \% & 52,1 \% & - \\
Net energy need for VH and SH & 27,7 & 27,0 & 15,8 \\
\specialcell{Delivered energy for\\DHW, VH and SH} & 31,1 & 27,6 & 45,6 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
테이블 형식이 약간 다릅니다.
\documentclass{report}
\usepackage{booktabs}
% \usepackage{array}% It can also be loaded explicitly, implicitly it is
% loaded by siunitx
\usepackage{siunitx}
% \sisetup{output-decimal-marker={,}}% OP now wants to have the default dot
\sisetup{detect-weight, mode=text}
\newcommand*\rotbf[1]{\rotatebox{90}{\textbf{#1}}}
\newcommand{\specialcell}[2][b]{\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}
\newcommand{\specialcellbold}[2][b]{%
\bfseries
\sisetup{text-rm=\bfseries}%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}%
}
\newcommand*{\leftspecialcell}[2][b]{%
\begin{tabular}[#1]{@{}l@{}}#2\end{tabular}%
}
\begin{document}
\begin{table}[hbr]
\centering
\label{tbl:heatwheel_res}
\begin{tabular}{l*{3}{S[table-format=2.1]}}
\toprule
\textbf{Parameter} &
{\specialcellbold{Exhaust\\air}} &
{\specialcellbold{Exhaust and\\ outdoor air}} &
{\specialcellbold{Heat wheel\\(\SI{80}{\percent})}} \\
\midrule
Heat recovery [\si{\percent}] & 89,6 & 89,6 & 77,4 \\
Real heat recovery [\si{\percent}] & 50,5 & 52,1 & {---} \\
Net energy need for VH and SH & 27,7 & 27,0 & 15,8 \\
\leftspecialcell{Delivered energy for\\
\quad DHW, VH and SH} & 31,1 & 27,6 & 45,6 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
비고:
- 아래쪽에 정렬된 머리글 행입니다.
- 2열부터 4열까지 중앙에 위치합니다.
- 패키지 이용
siunitx
소수점을 정렬하고 백분율 기호를 설정합니다. - 왼쪽 셀의 첫 번째 줄 다음 줄은 들여쓰기됩니다. 정렬은 수직 중앙 정렬 대신 최종선을 따릅니다.
- 누락된 항목에 대해 하이픈 대신 엠 대시를 사용합니다.
- 중복된 백분율 기호가 제거되었습니다.
- 출력 소수점 표시를 기본 점으로 변경했습니다(참조:논평ROLF).
- 조금 조악한 것은
\siunit{text-rm=\bfseries}
. 옵션이 -columndetect-weight
내부에서 작동하지 않았습니다S
.
업데이트
저 Svend Tveskæg는 코드를 읽기가 쉽지 않다는 것을 알았습니다. 코드를 조금 정리했습니다(괜찮기를 바랍니다).
\documentclass{report}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{
% output-decimal-marker = {,},
detect-weight,
mode = text
}
\newcommand*{\specialcell}[2][b]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}%
}
\newcommand*{\specialcellbold}[2][b]{%
\bfseries
\sisetup{text-rm = \bfseries}%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}%
}
\newcommand*{\leftspecialcell}[2][b]{%
\begin{tabular}[#1]{@{}l@{}}#2\end{tabular}%
}
\begin{document}
\begin{table}[htbp]
\centering
\label{tbl:heatwheel-res}
\begin{tabular}{l *{3}{S[table-format = 2.1]}}
\toprule
\textbf{Parameter} &
{\specialcellbold{Exhaust \\ air}} &
{\specialcellbold{Exhaust and\\ outdoor air}} &
{\specialcellbold{Heat wheel \\ (\SI{80}{\percent})}} \\
\midrule
Heat recovery [\si{\percent}] & 89,6 & 89,6 & 77,4 \\
Real heat recovery [\si{\percent}] & 50,5 & 52,1 & {---} \\
Net energy need for VH and SH & 27,7 & 27,0 & 15,8 \\
\leftspecialcell{Delivered energy for \\
\quad DHW, VH and SH} & 31,1 & 27,6 & 45,6 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
답변2
단지 비교를 위해서입니다. 일반 TeX에서 이 테이블을 수행하는 방법. 그러나 LaTeX에서도 (로드된 패키지 없이) 작동합니다.
\def\toprule{\noalign{\medskip\hrule height .8pt\medskip}}
\def\midrule{\noalign{\medskip\hrule\medskip}}
\let\bottomrule=\toprule
\def\specialcell#1{$\vcenter{\halign{\hfil##\hfil\strut\cr#1\cr}}$}
\def\x{\phantom{\%}}\def\h{\hfill\null}
\halign{&\ \hfil#\unskip\ \hfil\cr
\toprule
\bf Parameter\h & \bf\specialcell{Exhaust\cr air} &
\bf\specialcell{Exhaust and\cr outdoor air} &
\bf\specialcell{Heat wheel\cr(80~\%)} \cr
\midrule
Heat recovery [\%]\h &89,6 \% & 89,6 \% & 77,4 \% \cr
Real heat recovery [\%]\h & 50,5 \% & 52,1 \% & --- \cr
Net energy need for VH and SH & 27,7 \x & 27,0 \x & 15,8 \x \cr
\specialcell{Delivered energy for\cr DHW, VH and SH\hfill}\h& 31,1 \x & 27,6 \x & 45,6 \x\cr
\bottomrule
}
\bye
답변3
바퀴를 재발명하지 마십시오. 패키지 makecell
: 그것 \thead
과 \makecell
명령은 셀의 줄바꿈과 일반적인 서식을 허용합니다. 또한 패키지 를 로드하는 경우 정의 \rothead
하고 명령합니다 . 데모:\rotcell
rotating
\documentclass{report}
\usepackage{booktabs}
\usepackage{array}
\usepackage{rotating}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\renewcommand\cellalign{lc}
\setcellgapes{2pt}
\makegapedcells
\begin{document}
\begin{table}[hbr]
\centering
\label{tbl:heatwheel_res}
\begin{tabular}{lccc}
\toprule
\makecell{\bfseries Parameter} & \thead{Exhaust\\air} & \thead{Exhaust and \\ outdoor air} & \thead{Heat wheel\\(80~\%)} \\
\midrule
\makecell{Heat recovery\\{}[\%]} & 89,6 & 89,6 & 77,4 \\
\makecell{Real heat recovery\\{}[\%]} & 50,5 & 52,1 & -- \\
\makecell{Net energy need for\\VH and SH} & 27,7 & 27,0 & 15,8 \\
\makecell{Delivered energy for\\DHW, VH and SH} & \rotcell{31,1 }& 27,6 & 45,6 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}