加载 Caption 包后,Changepage 包 [\adjustmargin] 无法与 \captionof 正确配合使用

加载 Caption 包后,Changepage 包 [\adjustmargin] 无法与 \captionof 正确配合使用

当满足以下所有条件时,文本的对齐将发生倾斜:

  • 环境\adjustmargin来自changepage包被使用。
  • 命令\captionof已使用。
  • caption程序包已加载。


平均能量损失

Lipsum 证明了\textwidth
表 1 和表 2 证明了\caption\captionof不成立\adjustmargin
表 3 和表 4 证明了\caption\captionof成立\adjustmargin

如果该caption包被注释掉,则\captionof变得正确。

\documentclass{scrartcl}

\usepackage{geometry}                   % margin/page layout settings
\usepackage{scrlayer-scrpage}           % improved header commands. [supercedes `fancyhdr' package].
\usepackage{changepage}                 % allows adjustwidth, for figures larger than the margins.

\usepackage{float}                      % improves floating objects (graphics/tables).
\usepackage{caption}                    % required for package{subcaption}.
%\usepackage{subcaption}                 % allow captions with the subcaption command.

\usepackage{lipsum}

% Margin Settings:
\newlength{\xhmargin   } \setlength{\xhmargin   }{0.750in}
\newlength{\xtmargin   } \setlength{\xtmargin   }{0.750in}
\newlength{\xbmargin   } \setlength{\xbmargin   }{1.000in}
\newlength{\xheadheight} \setlength{\xheadheight}{2.700em}
\newlength{\xheadsep   } \setlength{\xheadsep   }{0.150in}
\newlength{\xfootheight} \setlength{\xfootheight}{2.700em}
\newlength{\xfootskip  } \setlength{\xfootskip  }{0.800in}

\KOMAoptions{headheight = \xheadheight , 
             footheight = \xfootheight , 
             DIV        = current      }

\geometry{letterpaper                ,
          hmargin      = \xhmargin   ,
          tmargin      = \xtmargin   ,
          bmargin      = \xbmargin   ,
          headsep      = \xheadsep   ,
          footskip     = \xfootskip  }
\usepackage{showframe}
\savegeometry{default}




%Initialize headers and footers
\chead{\normalfont Header 1 \\ Header 2}
\cfoot{\normalfont Footer 1 \\ Footer 2}
\ofoot{\normalfont Page \thepage}




%Set margin increase.
\newlength{\hShift}
\setlength{\hShift}{0.5in}




\begin{document}
\lipsum[1]




\vspace{+1em}




\begin{table}[H]

\centering
\caption{Caption}

\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
\textbf{Adjustmargin} & \textbf{Caption}  & 
\textbf{Column C}     & \textbf{Column D} & \textbf{Column E} & 
\textbf{Column F}     & \textbf{Column G} & \textbf{Column H} \\ \hline
%
No     & caption  & 
Text C & Text D   & Text E & 
Text F & Text G   & Text H \\ \hline
\end{tabular}

\end{table}




\vspace{+1em}




\begin{table}[H]

\centering
\captionof{table}{Caption}

\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
\textbf{Adjustmargin} & \textbf{Caption}  & 
\textbf{Column C}     & \textbf{Column D} & \textbf{Column E} & 
\textbf{Column F}     & \textbf{Column G} & \textbf{Column H} \\ \hline
%
No     & captionof & 
Text C & Text D    & Text E & 
Text F & Text G    & Text H \\ \hline
\end{tabular}

\end{table}




\vspace{+1em}




\begin{table}[H]

\begin{adjustwidth}{-\hShift}{-\hShift}
%\addtolength{\textwidth}{2\hShift}            % [suggestion from another thread. was not the solution.]

\centering
\caption{Caption}

\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
\textbf{Adjustmargin} & \textbf{Caption} & 
\textbf{Column C}     & \textbf{Column D} & \textbf{Column E} & 
\textbf{Column F}     & \textbf{Column G} & \textbf{Column H} \\ \hline
%
Yes    & caption & 
Text C & Text D  & Text E & 
Text F & Text G  & Text H \\ \hline
\end{tabular}

\end{adjustwidth}

\end{table}




\vspace{+1em}




\begin{table}[H]

\begin{adjustwidth}{-\hShift}{-\hShift}
%\addtolength{\textwidth}{2\hShift}            % [suggestion from another thread. was not the solution.]

\centering
\captionof{table}{Caption}

\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
\textbf{Adjustmargin} & \textbf{Caption} & 
\textbf{Column C}     & \textbf{Column D} & \textbf{Column E} & 
\textbf{Column F}     & \textbf{Column G} & \textbf{Column H} \\ \hline
%
Yes    & captionof & 
Text C & Text D    & Text E & 
Text F & Text G    & Text H \\ \hline
\end{tabular}

\end{adjustwidth}

\end{table}




\end{document}

答案1

无需 即可将表格(或图像)居中adjustwidth。使用简单\makebox[\linewidth]{...}

在此处输入图片描述

代码:

\documentclass{scrartcl}
\usepackage{geometry}                   % margin/page layout settings
\usepackage{scrlayer-scrpage}           % improved header commands. [supercedes `fancyhdr' package].
%\usepackage{changepage}                 % allows adjustwidth, for figures larger than the margins.
\usepackage{float}                      % improves floating objects (graphics/tables).
\usepackage{caption}                    % required for package{subcaption}.
%\usepackage{subcaption}                 % allow captions with the subcaption command.
\usepackage{lipsum}

% Margin Settings:
\newlength{\xhmargin   } \setlength{\xhmargin   }{0.750in}
\newlength{\xtmargin   } \setlength{\xtmargin   }{0.750in}
\newlength{\xbmargin   } \setlength{\xbmargin   }{1.000in}
\newlength{\xheadheight} \setlength{\xheadheight}{2.700em}
\newlength{\xheadsep   } \setlength{\xheadsep   }{0.150in}
\newlength{\xfootheight} \setlength{\xfootheight}{2.700em}
\newlength{\xfootskip  } \setlength{\xfootskip  }{0.800in}

\KOMAoptions{headheight = \xheadheight , 
             footheight = \xfootheight , 
             DIV        = current      }

\geometry{letterpaper                ,
          hmargin      = \xhmargin   ,
          tmargin      = \xtmargin   ,
          bmargin      = \xbmargin   ,
          headsep      = \xheadsep   ,
          footskip     = \xfootskip  }
\usepackage{showframe}
\savegeometry{default}

%Initialize headers and footers
\chead{Header 1 \\ Header 2}
\cfoot{Footer 1 \\ Footer 2}
\ofoot{Page \pagemark}
\setkomafont{pageheadfoot}{\normalfont}

%%Set margin increase.
%\newlength{\hShift}
%\setlength{\hShift}{1in}

\begin{document}
\lipsum[1]
\begin{table}[H]
  \centering
  \captionof{table}{Caption}
  \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
    \textbf{Adjustmargin} & \textbf{Caption}  & 
    \textbf{Column C}     & \textbf{Column D} & \textbf{Column E} & 
    \textbf{Column F}     & \textbf{Column G} & \textbf{Column H} \\ \hline
    %
    No     & caption  & 
    Text C & Text D   & Text E & 
    Text F & Text G   & Text H \\ \hline
  \end{tabular}
\end{table}
\begin{table}[H]
  \centering
  \captionof{table}{Caption}
  \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
    \textbf{Adjustmargin} & \textbf{Caption}  & 
    \textbf{Column C}     & \textbf{Column D} & \textbf{Column E} & 
    \textbf{Column F}     & \textbf{Column G} & \textbf{Column H} \\ \hline
    %
    No     & captionof & 
    Text C & Text D    & Text E & 
    Text F & Text G    & Text H \\ \hline
  \end{tabular}
\end{table}

\begin{table}[H]
\centering
\caption{Caption}
\makebox[\linewidth]{%
  \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
    \textbf{Adjustmargin} & \textbf{Caption} & 
    \textbf{Column C}     & \textbf{Column D} & \textbf{Column E} & 
    \textbf{Column F}     & \textbf{Column G} & \textbf{Column H} \\ \hline
    %
    Yes    & caption & 
    Text C & Text D  & Text E & 
    Text F & Text G  & Text H \\ \hline
  \end{tabular}%
}
\end{table}

\begin{table}[H]
\centering
\captionof{table}{Caption}
\makebox[\linewidth]{%
  \begin{tabular}{|c|c|c|c|c|c|c|c|} \hline
  \textbf{Adjustmargin} & \textbf{Caption} & 
  \textbf{Column C}     & \textbf{Column D} & \textbf{Column E} & 
  \textbf{Column F}     & \textbf{Column G} & \textbf{Column H} \\ \hline
  %
  Yes    & captionof & 
  Text C & Text D    & Text E & 
  Text F & Text G    & Text H \\ \hline
  \end{tabular}%
}
\end{table}
\end{document}

相关内容