
여러 단어와 열이 있는 테이블이 있습니다.
\documentclass[12pt, twocolumn]{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{lipsum}
\begin{document}
\lipsum
\begin{table}[ht]
%\vspace{-.15cm}
\caption{Power Consumption measured in mW}
%\vspace{-.1cm}
\centering
\begin{tabular}{c c c cc c cc }
\toprule
\multirow{2}{*}{\parbox[c]{.1\linewidth}{\centering }}
& Labeled & & \multicolumn{2}{c}{FBF ($q = 16$)} & & \multicolumn{2}{c}{FBF ($q = 64$)} \\
\cmidrule{2-2} \cmidrule{4-5} \cmidrule{7-8}
& size & & {Reduction in size(\%)} & Power & & {Reduction in size(\%)} & Power \\
\midrule
s1 & 125 & & 59.2 & 7.32 & & 26.4 & 0.35 \\
c2 & 81 & & 72.8 & 0.37 & & 25.9 & 0.36 \\
\bottomrule
\end{tabular}
\label{table:power_consumption}
\vspace{-.35cm}
\end{table}
\lipsum
\end{document}
컴파일할 때 열이 너무 넓은 테이블이 있습니다.
조정이 좀 필요한 것 같아요 Reduction in size(%)
. 해당 열을 더 좁게 만드는 방법은 무엇입니까?
답변1
makecell
다음은 패키지, 더 작은 글꼴 크기 및 caption
캡션과 표 사이의 올바른 수직 간격을 위한 패키지를 사용하는 방법입니다 .
\documentclass[twocolumn,12pt]{article}%
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{lipsum}
\usepackage{makecell, caption}
\renewcommand\cellalign{bc}
\begin{document}
\lipsum
\begin{table}[!ht]
\footnotesize\setlength\tabcolsep{4pt}\vspace{2pt}
\captionsetup{labelfont = bf}
\caption{Power Consumption measured in mW}
\centering
\begin{tabular}{@{\,}c@{\,}c@{\,}ccc@{\,}ccc@{\,}}
\toprule
& Labeled & & \multicolumn{2}{c}{FBF ($q = 16$)} & & \multicolumn{2}{c}{FBF ($q = 64$)} \\
\cmidrule{2-2} \cmidrule{4-5} \cmidrule{7-8}
& Size & & \makecell{Reduction\\ in size(\%)} & Power & & \makecell{Reduction\\ in size(\%)} & Power \\
\midrule
s1 & 125 & & 59.2 & 7.32 & & 26.4 & 0.35 \\
c2 & 81 & & 72.8 & 0.37 & & 25.9 & 0.36 \\
\bottomrule
\end{tabular}
\label{table:power_consumption}
\vspace{-2.5ex}
\end{table}
\lipsum
\end{document}
답변2
이것은 제안입니다. 고정관념에서 벗어나려고 노력했기 때문에 원래 디자인에 정확히 충실하지는 않습니다.
\documentclass[12pt, twocolumn]{article}
\usepackage{booktabs}
\usepackage{lipsum}
\usepackage{siunitx}
\usepackage[tableposition=above]{caption}
\begin{document}
\lipsum
\begin{table}[ht]
%\vspace{-.15cm}
\caption{Power Consumption in mW}
%\vspace{-.1cm}
\centering
\begin{tabular}{c
S[table-format = 3.0]
*3c
}
\toprule
& & & Size & \\
& {Size} & q & Reduction & Power \\
\addlinespace
& {(-)} & (-) & (\si{\percent}) & (\si{mW})\\
\midrule
s1 & 125 & 16 & 59.2 & 7.32 \\
& & 32 & 26.4 & 0.35 \\
\addlinespace
c2 & 81 & 16 & 72.8 & 0.37 \\
& & 32 & 25.9 & 0.36 \\
\bottomrule
\end{tabular}
\label{table:power_consumption}
\vspace{-.35cm}
\end{table}
\lipsum
\end{document}
결과는 다음과 같습니다.
코멘트:
어떤 경우든 코드에서 두 줄을 사용하여 테이블 헤더를 정의한 것처럼 긴 열 제목 "크기 감소"를 두 줄로 나눌 수 있습니다.
또한
siuntix
패키지를 사용하여 "크기" 열의 숫자를 정렬했습니다.multirow
실제로 필요하지 않았기 때문에 사용을 제거했습니다 .테이블 제목을 더 잘 배치하기 위해
caption
옵션과 함께 패키지를 사용했습니다 .tableposition=above
답변3
항상 가능한 것은 아니지만 글꼴 크기와 열 너비를 변경하는 대신 테이블이 두 열에 걸쳐 있도록 할 수도 있습니다. 별표 표시된 버전으로 호출할 수 있습니다.
\begin{table*}...\end{table*}
h
이 경우 배치 문자는 전혀 권장되지 않습니다. 이는 그림(및 다른 부동 개체가 정의된 경우)에도 적용됩니다.
documentclass[12pt, twocolumn]{article}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{multirow}
\usepackage{lipsum}
\begin{document}
\lipsum
\begin{table*}[tb]
\caption{Power Consumption measured in mW}
\label{table:power_consumption}
\centering
\begin{tabular}{c c c cc c cc }
\toprule
\multirow{2}{*}{\parbox[c]{.1\linewidth}{\centering }}
& Labeled & & \multicolumn{2}{c}{FBF ($q = 16$)} & & \multicolumn{2}{c}{FBF ($q = 64$)} \\
\cmidrule{2-2} \cmidrule{4-5} \cmidrule{7-8}
& size & & {Reduction in size(\%)} & Power & & {Reduction in size(\%)} & Power \\
\midrule
s1 & 125 & & 59.2 & 7.32 & & 26.4 & 0.35 \\
c2 & 81 & & 72.8 & 0.37 & & 25.9 & 0.36 \\
\bottomrule
\end{tabular}
\end{table*}
\lipsum
\end{document}
답변4
한 가지 해결책은 다음과 같습니다.
\documentclass[12pt, twocolumn]{article}
\usepackage{booktabs,tabularx}
\usepackage{multirow}
\usepackage{lipsum}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\lipsum
\begin{table}[ht]
\centering
\footnotesize
\setlength{\tabcolsep}{3pt}
\caption{Power Consumption measured in mW}
\label{table:power_consumption}
\begin{tabularx}{\hsize}{@{}ccCcCc@{}}
\toprule
& Labeled
& \multicolumn{2}{c}{FBF ($q = 16$)}
& \multicolumn{2}{c}{FBF ($q = 64$)} \\
\cmidrule(lr){2-2} \cmidrule(lr){3-4} \cmidrule(lr){5-6}
& size & Reduction\newline
in size (\%)
& Power & Reduction\newline
in size (\%)
& Power \\
\midrule
s1 & 125 & 59.2 & 7.32 & 26.4 & 0.35 \\
c2 & 81 & 72.8 & 0.37 & 25.9 & 0.36 \\
\bottomrule
\end{tabularx}
\end{table}
\lipsum
\end{document}
tabularx
테이블 너비를 열 너비에 맞게 조정하기 위해 패키지를 사용하고 \footnotesize
열이 좁아지도록 글꼴을 변경합니다. 셀 중앙에 맥아즙 '크기'를 갖고 싶다면 multirow
유사한 솔루션을 사용해야 합니다.