PNAS ドキュメント クラスに表のキャプションが表示されない

PNAS ドキュメント クラスに表のキャプションが表示されない

使用時に表のキャプションが表示されませんPNAStwo ドキュメント クラス2008 年から (最新バージョンには不要なプリンター マークが含まれています)。

ドキュメントには「図と表のキャプションは文書の最後に入力する必要があります...「しかしキャプションとして図に表示されているように、表にも表示されるようにしたいと思います。

彼らの推奨事項が著者に対する制限として実装されていないことを期待していましたが、どうやらそうなっているようです。それとも私が何か見落としているのでしょうか? そうでない場合、私が採用できる回避策はありますか?

\documentclass{pnastwo}

\usepackage{グラフィックx}
\usepackage{pnastwoF}
\usepackage{amssymb,amsfonts,amsmath}

\begin{ドキュメント}

\begin{記事}

\begin{表}[h]
    \begin{表形式}{cc}
        1 & 2 \\
        3と4
    \end{表形式}
    \caption{表示されないキャプション。}
\end{表}

\begin{図}
    \caption{表示されるキャプション。}
\end{図}

\end{記事}

\end{ドキュメント}

答え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 2 列クラスを使用して製品品質の出力を生成する場合に修正する必要がある別の問題にほぼ確実に遭遇することになります。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環境と同じ幅でタイプセットされていることに注意してください。なぜでしょうか? わかりません。

関連情報