我有以下代码:
\documentclass[letterpaper,12pt]{article}
% things needed to include figures
\usepackage{subfigure, graphicx}
% float must be included for the [H] to actually work
\usepackage{float}
% formulas
\usepackage{amsmath}
% Added to adjust captions
\usepackage[singlelinecheck=false]{caption}
% added to adjust margins at the suggestion of Dr. Matt
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{fullpage}
\begin{document}
% 2 column side by side table
\begin{table}[H]
\subtable[Half-life for $^{108}$Ag] {%
% -----------------------------------------------------%
\begin{tabular}{c@{\hskip 1cm} c}
\hline\noalign{\smallskip}
Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
(s) & (s)\\
\hline\noalign{\smallskip}
142.92 & 158 $\pm$ 7\\
\hline\noalign{\smallskip}
\end{tabular}
\label{lefttable}
% -----------------------------------------------------%
}
\subtable[Half-life for $^{110}$Ag] {%
% -----------------------------------------------------%
\begin{tabular}{c@{\hskip 1cm} c}
\hline\noalign{\smallskip}
Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
(s) & (s)\\
\hline\noalign{\smallskip}
24.6 & 21 $\pm$ 2\\
\hline\noalign{\smallskip}
\end{tabular}
\label{righttable}
% -----------------------------------------------------%
}
\caption{2 Column tables side by side}
\label{sidebysidetable}
\end{table}
\end{document}
得出的结果如下:
我想让标题左对齐。我该怎么做?
答案1
对于你的问题:
subcaption
包支持caption
包并使用其\captionsetup
接口。
\usepackage{caption}
\captionsetup[table]{justification=raggedright}
\captionsetup[subtable]{justification=raggedright}
其中raggedright
左对齐。
在问题中subfigure 和 subfig 包已弃用,subcaption
被推荐。
\usepackage{subcaption}
代替subfigure
。
我改变了你的子表环境风格:
\begin{table}[H]
\begin{subtable}[b]{0.48\textwidth}
% -----------------------------------------------------%
\caption{Half-life for $^{108}$Ag} \label{lefttable}
\begin{tabular}{c@{\hskip 1cm} c}
\hline\noalign{\smallskip}
Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
(s) & (s)\\
\hline\noalign{\smallskip}
142.92 & 158 $\pm$ 7\\
\hline\noalign{\smallskip}
\end{tabular}
% -----------------------------------------------------%
\end{subtable}
\begin{subtable}[b]{0.48\textwidth}
% -----------------------------------------------------%
\caption{Half-life for $^{110}$Ag} \label{righttable}
\begin{tabular}{c@{\hskip 1cm} c}
\hline\noalign{\smallskip}
Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
(s) & (s)\\
\hline\noalign{\smallskip}
24.6 & 21 $\pm$ 2\\
\hline\noalign{\smallskip}
\end{tabular}
% -----------------------------------------------------%
\end{subtable}
\caption{2 Column tables side by side}
\label{sidebysidetable}
\end{table}
输出是
注意,总宽度(左表 + 右表)应小于\textwidth
。并且 中的选项[b]
是该子表的垂直位置。对于您来说,相同高度的表格不会产生b
任何t
差异。
答案2
在子标题中使用\hspace*{\fill}
,例如
\caption{This table. \hspace*{\fill}}
对我来说很管用。以下是基于其他帖子的工作示例(请参阅内联注释以了解 的使用\hspace
):
\documentclass[letterpaper,12pt]{article}
\usepackage{caption, subcaption}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\begin{document}
\begin{table}[H]
\begin{subtable}[b]{0.48\textwidth}
\caption{Half-life for $^{108}$Ag \hspace*{\fill}} %NOTE
\begin{tabular}{c@{\hskip 1cm} c}
\hline\noalign{\smallskip}
Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
(s) & (s)\\
\hline\noalign{\smallskip}
142.92 & 158 $\pm$ 7\\
\hline\noalign{\smallskip}
\end{tabular}
\end{subtable}
\begin{subtable}[b]{0.48\textwidth}
\caption{Half-life for $^{110}$Ag \hspace*{\fill}} %NOTE
\begin{tabular}{c@{\hskip 1cm} c}
\hline\noalign{\smallskip}
Accepted $T_{1/2}$ & Experimental $T_{1/2}$\\
(s) & (s)\\
\hline\noalign{\smallskip}
24.6 & 21 $\pm$ 2\\
\hline\noalign{\smallskip}
\end{tabular}
\end{subtable}
\caption{2 Column tables side by side}
\end{table}
\end{document}