我试图避免在“表格”一词和该表格的编号引用之间换行。按照另一个问答,我检查了整个文档,并将 \ref 和表格/图形文本之间的所有空格替换为波浪号,例如:Table~\ref{table:data-from-phone}
。但是,仍然会出现换行符:
我不知道这是个错误还是我仍在做错事。我正在使用 MiKTeX 2.9 和 TexMaker 编辑器。以下是一段代码,希望对您有帮助:
A user, Mary, has painstakingly collected the following set of data and labelled
whether she was walking, running, or standing still. The data are shown in
Table~\ref{table:data-from-phone} below.
根据评论,这里有编译示例文档所需的两个文件,我遇到了这个问题(我试图使它们尽可能小):
%!TeX encoding = ISO-8859-1
\documentclass[12pt,a4paper,english
]{tutthesis2}
\begin{document}
A user, Mary, has painstakingly collected the following set of data and labelled whether she was walking, running, or standing still. The data are shown in Table~\ref{table:data-from-phone} below, consisting of two dimensions of input data and the labelled output.
\begin{table}
\begin{tabular}{lcc}
\hline\noalign{\smallskip}
2.56 & 2 & walking\\
\end{tabular}
\caption{The caption of the table}\label{table:data-from-phone}
\end{table}
\end{document}
和tutthesis2.cls
文件:
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{tutthesis2}
[2014/07/28 v0.5 Extension to basic LaTeX document class 'report']
% Load the basic template 'report.cls'.
\LoadClassWithOptions{report}
\usepackage[font=small,it, labelsep=space]{caption} % Figure caption text font and size, *
\usepackage{hyperref} % pdf links to e.g. figures and citations
\setlength\textwidth{15cm} % 15*24cm text area leaves 6cm horiz margins and 5.7cm vertical
\setlength\textheight{24cm} %
\setlength\headheight{15pt} %
\renewcommand \thetable{
\ifnum \c@chapter>\z@ \chapfigname.\fi \@arabic\c@table}
\captionsetup[table]{labelfont={bf,it},textfont={it}}
%% End of file `tutthesis2.cls'.
答案1
您的类在重新定义时有太多空格。如果您删除它们,它会按预期工作:
\renewcommand\thetable{\ifnum\c@chapter>\z@\chapfigname.\fi\@arabic\c@table}
即使你用受保护的空间来排版,它仍然会在可以换行的地方插入一个正常空格。
我已经删除了所有其他空格(个人偏好),但您实际上只需要删除或转义 后面的空格(在本例中为换行符)\thetable{
。您可以删除换行符和后面的空格,也可以使用 转义换行符%
,这样它就不再“算作”空格了。
答案2
您可以尝试以下命令
\pretolerance=9999
\hyphenpenalty=9999
在 \begin{document} 之前。您可以根据需要调整这些值。