![使用 tocloft 对齐表格列表中的长表格标题](https://linux22.com/image/271929/%E4%BD%BF%E7%94%A8%20tocloft%20%E5%AF%B9%E9%BD%90%E8%A1%A8%E6%A0%BC%E5%88%97%E8%A1%A8%E4%B8%AD%E7%9A%84%E9%95%BF%E8%A1%A8%E6%A0%BC%E6%A0%87%E9%A2%98.png)
我正在使用该tocloft
包,以便 Table 一词显示在表格列表中的数字之前。当我这样做时,带有长标题的表格会换行到下一行,但不会对齐。这是我正在使用的代码。
\documentclass [12pt] {article}
\usepackage{times, url}
\usepackage[left=1.5in,top=1in,bottom=1in,right=1in,footskip=0.5in]{geometry}
\usepackage{float}
\usepackage{booktabs,threeparttable}
\usepackage[subfigure]{tocloft}
\usepackage{subfigure}
\usepackage[justification=centering]{caption}
\renewcommand{\cfttabfont}{Table }
\begin{document}
\listoftables
\begin{table}[htbp]
\begin{threeparttable}
\captionsetup{font=normalsize}
\caption{Summary Statistics for Structural Housing Characteristics. Central Kentucky Data, 2000-2011. N=142,164.}
\centering
\footnotesize
\label{table:sumstatsfull}
\begin{tabular}{lcccc} \hline
Variable & Mean & Std. Dev. & Min & Max \\ \hline
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
`
I want the Table to precede the table number but I want the caption to be aligned like it is when the code below is used
`
\documentclass [12pt] {article}
\usepackage{times, url}
\usepackage[left=1.5in,top=1in,bottom=1in,right=1in,footskip=0.5in]{geometry}
\usepackage{float}
\usepackage{booktabs,threeparttable}
\usepackage[subfigure]{tocloft}
\usepackage{subfigure}
\usepackage[justification=centering]{caption}
%\renewcommand{\cfttabfont}{Table }
\begin{document}
\listoftables
\begin{table}[htbp]
\begin{threeparttable}
\captionsetup{font=normalsize}
\caption{Summary Statistics for Structural Housing Characteristics. Central Kentucky Data, 2000-2011. N=142,164.}
\centering
\footnotesize
\label{table:sumstatsfull}
\begin{tabular}{lcccc} \hline
Variable & Mean & Std. Dev. & Min & Max \\ \hline
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
答案1
\cfttabfont
旨在用于引入标题和前面数字的字体属性的变化,因此使用它添加一些字符串会产生不良的副作用,就像您注意到的那样。
添加单词“Table”和一个空格\cfttabpresnum
,然后使用\cfttabnumwidth
来增加为数字保留的空间:
\documentclass[12pt]{article}
\usepackage{times, url}
\usepackage[left=1.5in,top=1in,bottom=1in,right=1in,footskip=0.5in]{geometry}
\usepackage{float}
\usepackage{booktabs,threeparttable}
\usepackage[subfigure]{tocloft}
\usepackage{subfigure}
\usepackage[justification=centering]{caption}
\newlength\mylen
\renewcommand\cfttabpresnum{Table }
\settowidth\mylen{\cfttabpresnum\cfttabaftersnum}
\addtolength\cfttabnumwidth{\mylen}
\begin{document}
\listoftables
\begin{table}[htbp]
\begin{threeparttable}
\captionsetup{font=normalsize}
\caption{Summary Statistics for Structural Housing Characteristics. Central Kentucky Data, 2000-2011. N=142,164.}
\centering
\footnotesize
\label{table:sumstatsfull}
\begin{tabular}{lcccc} \hline
Variable & Mean & Std. Dev. & Min & Max \\ \hline
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
如果希望“表格”刷新到左边距,请添加
\setlength\cfttabindent{0pt}