我正在显示左侧示例的 4 位数据(其中 3 位属于同一类型)。有什么方法可以改善这种情况吗?
到目前为止我想出了这样的布局:
平均能量损失
\documentclass[
a4paper
]{scrreprt}
\usepackage{
lmodern,
tikz,
siunitx,
xspace
}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{center}\small
\begin{tabular}{llll}
\begin{minipage}{2.1cm}
\tikz \filldraw[thick] (0,0) rectangle (2,2);
\end{minipage}
&
\begin{tabular}{r@{\hspace{3pt}}S}
\( a = \) & \SI{1.11}{\metre} \\
\( b = \) & \SI{2.22}{\newton} \\
\( c = \) & \SI{3.33}{\newton} \\
\( d = \) & \SI{5.13}{\newton}
\end{tabular}
&
\begin{minipage}{2.1cm}
\tikz \filldraw[thick] (0,0) rectangle (2,2);
\end{minipage}
&
\begin{tabular}{r@{\hspace{3pt}}S}
\( a = \) & \SI{1.11}{\metre} \\
\( b = \) & \SI{2.22}{\newton} \\
\( c = \) & \SI{3.33}{\newton} \\
\( d = \) & \SI{5.13}{\newton}
\end{tabular}
\end{tabular}
\end{center}
\end{document}
答案1
数据应分为三列;对于总体布局,我展示了两种方式。
注意数据子表的格式:
\begin{tabular}{
>{$}r<{{}$}
@{}
S[table-format=1.2]
@{\,}
s
}
在数学模式下,第一列右对齐;
{}
确保符号后有良好的间距=
。第二列是
S
;调整table-format
为实际格式。第三列是
s
,用于指定每个单元格中不使用的单位\si
。(感谢 Harish 重新提出此选项。)
\documentclass[
a4paper
]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{siunitx}
\usepackage[demo]{graphicx} % demo just for the example
\usepackage[export]{adjustbox}
\newcommand{\omitvalue}{\multicolumn{2}{@{}c}{---}}
\begin{document}
\begin{table}[htp]
\centering\small
\hfill
\includegraphics[height=2cm,width=2cm,valign=c]{A}\quad
\begin{tabular}{
>{$}r<{{}$}
@{}
S[table-format=1.2]
@{\,}
s
}
a = & 1.11 & \metre \\
b = & 2.22 & \newton \\
c = & 3.33 & \newton \\
d = & 5.13 & \newton
\end{tabular}
\hfill\hfill
\includegraphics[height=2cm,width=2cm,valign=c]{A}\quad
\begin{tabular}{
>{$}r<{{}$}
@{}
S[table-format=1.2]
@{\,}
s
}
a = & 1.11 & \metre \\
b = & 2.22 & \newton \\
c = & 3.33 & \newton \\
d = & \omitvalue
\end{tabular}\hspace*{\fill}
\end{table}
\begin{table}[htp]
\centering\small
\begin{tabular}{c@{\ }l@{\qquad}c@{\ }l}
\includegraphics[height=2cm,width=2cm,valign=c]{A} &
\begin{tabular}{
>{$}r<{{}$}
@{}
S[table-format=1.2]
@{\,}
s
}
a = & 1.11 & \metre \\
b = & 2.22 & \newton \\
c = & 3.33 & \newton \\
d = & 5.13 & \newton
\end{tabular}
&
\includegraphics[height=2cm,width=2cm,valign=c]{A} &
\begin{tabular}{
>{$}r<{{}$}
@{}
S[table-format=1.2]
@{\,}
s
}
a = & 1.11 & \metre \\
b = & 2.22 & \newton \\
c = & 3.33 & \newton \\
d = & \omitvalue
\end{tabular}
\end{tabular}
\end{table}
\end{document}