我进行了左对齐表格捕获,但无法将捕获内容与表格一起向右移动。尝试在 \begin{table} 之后执行 shift 命令,并且 \leftskip=2cm 会移动表格但不移动标题。而 \hspace{2cm} 不会移动任何内容。我怎样才能将标题与表格一起移动?
\begin{table}[h]
\leftskip=2cm
\caption{Table caption}
\label{tab:time}
\begin{tabular}{|c|c|c|} \hline
Borders expand: & 1,0-1,4 & size FRT \\\hline
Apodization: & 0,25-0,30 & size FRT \\\hline
Border extrude: & 0,25-0,50 & size FRT \\\hline
\end{tabular}
\end{table}
我可以做如下事情:
\begin{table}[h]
\leftskip=2.5em
\caption{%
\leftskip=2.5em
The table caption that longer than table so will hiphenated}
\label{tab:time}
\begin{tabular}{|c......
但我想在表格环境开始时使用单个 shift 命令。
刚才在 \@caption 定义中注释掉 \@parboxrestore 并且可以使用单个 shift 命令。
\long\def\@caption#1[#2]#3{%
\par
\addcontentsline{\csname ext@#1\endcsname}{#1}%
{\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\begingroup
%\@parboxrestore
\if@minipage
\@setminipage
\fi
\normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup}
这次评论动作安全吗?
答案1
使用threeparttable
(测量表格宽度)和caption
(用于标题的左对齐):
\documentclass{article}
\usepackage[utf8]{inputenc}%
\usepackage{fourier, erewhon}
\usepackage[showframe]{geometry}
\usepackage{caption, threeparttable}
\begin{document}
\begin{table}[h]
\leftskip=2cm
\begin{threeparttable}
\captionsetup{singlelinecheck=off, skip=4pt}
\caption{Table caption}
\label{tab:time}
\begin{tabular}{|c|c|c|} \hline
Borders expand: & 1,0-1,4 & size FRT \\\hline
Apodization: & 0,25-0,30 & size FRT \\\hline
Border extrude: & 0,25-0,50 & size FRT \\\hline
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
如果您想要一个长标题到右边距,而不是与表格宽度相同,您可以使用adjustwidth
以下环境changepage
:
\documentclass{article}
\usepackage[utf8]{inputenc}%
\usepackage{fourier, erewhon}
\usepackage[showframe]{geometry}
\usepackage{caption}
\usepackage{changepage}
\begin{document}
\begin{table}[!htbp]
\begin{adjustwidth}{2cm}{0cm}
\captionsetup{singlelinecheck=off, skip=4pt, width =\dimexpr \textwidth-2cm\relax}%
\caption{Table caption. A very very long caption. A very very long caption. A very very long caption. A very very long caption}
\label{tab:time}
\begin{tabular}{|c|c|c|} \hline
Borders expand: & 1,0-1,4 & size FRT \\\hline
Apodization: & 0,25-0,30 & size FRT \\\hline
Border extrude: & 0,25-0,50 & size FRT \\\hline
\end{tabular}
\end{adjustwidth}
\end{table}
\end{document}