我无法在使用时显示表格标题PNAStwo 文档类从 2008 年开始(最新版本包含我不想要的打印机标记)。
文档说“图表标题应输入在文档末尾...“但作为标题是显示图形,我希望它们也能显示在表格中。
我希望他们的建议不会对作者构成限制,但看起来是,还是我遗漏了什么?如果不是,有什么解决方法可以采用吗?
\documentclass{pnastwo} \usepackage{graphicx} \usepackage{pnastwoF} \usepackage{amssymb,amsfonts,amsmath} \开始{文档} \开始{文章} \begin{表格}[h] \开始{表格}{cc} 1 & 2 \\ 3 & 4 \end{表格} \caption{未出现的标题。} \茶几} \开始{图} \caption{确实出现的标题。} \结束{图} \结束{文章} \结束{文档}
答案1
我刚刚遇到了同样的问题。(当尝试制作印刷质量的论文预印本时,这真的很烦人。)在 pnastwo.cls 中搜索后,我发现了以下修复方法:
找到 pnastwo.cls 中的第一行,内容如下
\ifx\@captype\xtable
将其更改为
\ifx\@captype\table
或者,如果您不想触及类文件,您可以将以下内容放入文档的序言中:
% Fix wierd behavior which prevents table captions from appearing for
% tables in the body of the article
\makeatletter
\long\def\@makecaption#1#2{%
\ifx\@captype\table
\let\currtabcaption\relax
\gdef\currtabcaption{
\tabnumfont\relax #1. \tabtextfont\relax#2\par
\vskip\belowcaptionskip
}
\else
\vskip\abovecaptionskip
\sbox\@tempboxa{\fignumfont#1.\figtextfont\hskip.5em\relax #2}%
\ifdim \wd\@tempboxa >\hsize
\fignumfont\relax #1.\figtextfont\hskip.5em\relax#2\par
\else
\global \@minipagefalse
\hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
\fi
\fi
}
\makeatother
补充一点:一旦修复了这个错误,如果您使用 PNAS 双列类来生成生产质量的输出,您几乎肯定会遇到另一个问题,而这个问题是您希望修复的:除非您使用 h “here” 位置定义浮点,否则它会丢失标签,因此所有图形和表格的交叉引用都会中断。这是修复方法,用于直接粘贴到文档序言中。您还可以修补宏 \DonormalEndcol pnastwo.cls,这是 6 次相同的错误...
% And another fix. PNAS class loses the label of floats unless they
% were defined with the [h] option (so not really floats at all). It
% all comes down to wrong scope in the following routine which pushes
% out the floats onto the page. This is the fixed version:
\makeatletter
\def\DonormalEndcol{%
%% top float ==>
\ifx\toporbotfloat\xtopfloat%
%% figure ==>
\ifcaptypefig%
\expandafter\gdef\csname topfloat\the\figandtabnumber\endcsname{%
\vbox{\vskip\PushOneColTopFig%
\unvbox\csname figandtabbox\the\loopnum\endcsname%
\vskip\abovefigcaptionskip%
\csname caption\the\loopnum\endcsname%
\csname letteredcaption\the\loopnum\endcsname%
\csname continuedcaption\the\loopnum\endcsname%
\csname letteredcontcaption\the\loopnum\endcsname
\ifredefining%
\csname label\the\loopnum\endcsname%
\expandafter\gdef\csname topfloat\the\loopnum\endcsname{}\fi}%
\vskip\intextfloatskip%%
\vskip-4pt %% probably an artifact of topskip??
}%
\else%
%% plate ==>
\ifcaptypeplate%
\expandafter\gdef\csname topfloat\the\figandtabnumber\endcsname{%
\vbox{\vskip\PushOneColTopFig%
\unvbox\csname figandtabbox\the\loopnum\endcsname
\vskip\abovefigcaptionskip
\csname caption\the\loopnum\endcsname
\csname letteredcaption\the\loopnum\endcsname
\csname continuedcaption\the\loopnum\endcsname
\csname letteredcontcaption\the\loopnum\endcsname
\ifredefining
\csname label\the\loopnum\endcsname
\expandafter\gdef\csname topfloat\the\loopnum\endcsname{}\fi}
\vskip\intextfloatskip %%
\vskip-4pt %% probably an artifact of topskip??
}%
\else% table ==>
\expandafter\gdef\csname topfloat\the\figandtabnumber\endcsname{%
\vbox{\vskip\PushOneColTopTab %%
\csname caption\the\loopnum\endcsname
\csname letteredcaption\the\loopnum\endcsname
\csname continuedcaption\the\loopnum\endcsname
\csname letteredcontcaption\the\loopnum\endcsname
\vskip\captionskip
\unvbox\csname figandtabbox\the\loopnum\endcsname
\ifredefining
\csname label\the\loopnum\endcsname
\expandafter\gdef\csname topfloat\the\loopnum\endcsname{}\fi
}\vskip\intextfloatskip %% why don't we need this?
\vskip-10pt}
\fi\fi%
%
\else% bottom float
%
\ifcaptypefig
\expandafter\gdef\csname botfloat\the\figandtabnumber\endcsname{%
\vskip\intextfloatskip
\vbox{\unvbox\csname figandtabbox\the\loopnum\endcsname
\vskip\abovefigcaptionskip
\csname caption\the\loopnum\endcsname
\csname letteredcaption\the\loopnum\endcsname%
\csname continuedcaption\the\loopnum\endcsname%
\csname letteredcontcaption\the\loopnum\endcsname%
\vskip\PushOneColBotFig%%
\ifredefining%
\csname label\the\loopnum\endcsname
\expandafter\gdef\csname botfloat\the\loopnum\endcsname{}\fi}}%
\else
\ifcaptypeplate
\expandafter\gdef\csname botfloat\the\figandtabnumber\endcsname{%
\vskip\intextfloatskip
\vbox{\unvbox\csname figandtabbox\the\loopnum\endcsname
\vskip\abovefigcaptionskip
\csname caption\the\loopnum\endcsname
\csname letteredcaption\the\loopnum\endcsname%
\csname continuedcaption\the\loopnum\endcsname%
\csname letteredcontcaption\the\loopnum\endcsname%
\vskip\PushOneColBotFig%%
\ifredefining%
\csname label\the\loopnum\endcsname
\expandafter\gdef\csname botfloat\the\loopnum\endcsname{}\fi}}%
\else% TABLE
\expandafter\gdef\csname botfloat\the\figandtabnumber\endcsname{%
\vskip\intextfloatskip
\vbox{\csname caption\the\loopnum\endcsname
\csname letteredcaption\the\loopnum\endcsname
\csname continuedcaption\the\loopnum\endcsname
\csname letteredcontcaption\the\loopnum\endcsname%
\vskip.5\intextfloatskip
\unvbox\csname figandtabbox\the\loopnum\endcsname%
\vskip\PushOneColBotTab
\ifredefining%
\csname label\the\loopnum\endcsname
\expandafter\gdef\csname botfloat\the\loopnum\endcsname{}\fi}}%
\fi\fi\fi}
\makeatother
答案2
与课程一起分发的模板文件显示
%----------------------------------------------------------------------------------------
% FIGURES AND TABLES
%----------------------------------------------------------------------------------------
%% Adding Figure and Table References
%% Be sure to add figures and tables after \end{article}
%% and before \end{document}
以下是示例:
\documentclass{pnastwo}
\usepackage{graphicx}
%\usepackage{pnastwoF} % this is not required
\usepackage{amssymb,amsfonts,amsmath}
\usepackage{lipsum} % just for the example
\begin{document}
\title{X}
\author{A. Uthor\affil{1}{University of Nowhere}}
\contributor{Submitted to Proceedings of the National Academy of Sciences
of the United States of America}
%----------------------------------------------------------------------------------------
\maketitle % The \maketitle command is necessary to build the title page
\begin{article}
\lipsum
\end{article}
\begin{table}[h]
\caption{A caption that appears.}
\begin{tabular}{cc}
1 & 2 \\
3 & 4
\end{tabular}
\end{table}
\begin{figure}[h]
\caption{A caption that does appear.}
\end{figure}
\end{document}
注意,表格标题的排版宽度与tabular
环境宽度相同。为什么?我不知道。