我想使用 KOMA-Script 的 addmargin 环境(仅限单面文档)来有时使用文档的整个宽度书写内容,该文档分为 2/3 文本区域和 1/3 边距。
这有效......直到我意识到标题命令没有按照我想要的那样占据整个宽度,请参阅(我当前的代码(我认为只有必要的部分)):
\documentclass[fontsize=12pt,twoside=false,paper=a4,DIV=15,BCOR=0mm,twocolumn=false,footinclude=true,headinclude=true,mpinclude=false]{scrreprt}% KOMAScript
\AfterCalculatingTypearea{%
%% Margin
\addtolength{\evensidemargin}{-\marginparwidth}%
\addtolength{\textwidth}{\marginparwidth}%
\setlength{\marginparwidth}{.333\textwidth}%
\addtolength{\textwidth}{-\marginparwidth}%
\addtolength{\evensidemargin}{\marginparwidth}%
}\recalctypearea%
\newlength{\overhang}%
\setlength{\overhang}{\marginparwidth}%
\addtolength{\overhang}{\marginparsep}%
\newenvironment{fullwidth}{%
\begin{addmargin}[0em]{-\overhang}%
}{%
\end{addmargin}%
}%
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{float}
\usepackage{showframe}
\usepackage{lipsum}
\begin{document}
%% Works as intended
\lipsum[1]
\begin{fullwidth}
\lipsum[1]
\end{fullwidth}
%% Problem with caption
\newpage
\begin{figure}[H]\centering
\includegraphics[width=0.5\linewidth]{example-image-a}
\caption{This caption is centered as it should be. \lipsum[1]}
\end{figure}
\begin{figure}[H]
\begin{fullwidth}\centering
\includegraphics[width=0.5\linewidth]{example-image-a}
\caption{The image is centered, but the caption is NOT ugh... \lipsum[1]}
\end{fullwidth}
\end{figure}
\end{document}
输出为: 有人能向我解释如何解决这个问题吗?我只是想让标题使用整个宽度作为图像。如果可能的话,使用 addmargin 环境,因为我已经在文档中经常使用它了。:D
答案1
addmargin
是trivlist
。据我所知,它确实会改变\linewidth
,但 也\textwidth
不会改变\hsize
。但\caption
宽度似乎取决于这些。因此,例如使用:
\documentclass[fontsize=12pt,twoside=false,paper=a4,DIV=15,BCOR=0mm,twocolumn=false,footinclude=true,headinclude=true,mpinclude=false]{scrreprt}% KOMAScript
\AfterCalculatingTypearea{%
%% Margin
\addtolength{\evensidemargin}{-\marginparwidth}%
\addtolength{\textwidth}{\marginparwidth}%
\setlength{\marginparwidth}{.333\textwidth}%
\addtolength{\textwidth}{-\marginparwidth}%
\addtolength{\evensidemargin}{\marginparwidth}%
}\recalctypearea%
\newlength{\overhang}%
\setlength{\overhang}{\marginparwidth}%
\addtolength{\overhang}{\marginparsep}%
\newenvironment{fullwidth}{%
\begin{addmargin}[0em]{-\overhang}%
\textwidth\linewidth\hsize\linewidth% added
}{%
\end{addmargin}%
}%
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{float}
\usepackage{showframe}
\usepackage{lipsum}
\begin{document}
%% Works as intended
\lipsum[1]
\begin{fullwidth}
\lipsum[1]
\end{fullwidth}
%% Problem with caption
\newpage
\begin{figure}[H]\centering
\includegraphics[width=0.5\linewidth]{example-image-a}
\caption{This caption is centered as it should be. \lipsum[1]}
\end{figure}
\begin{figure}[H]
\begin{fullwidth}\centering
\includegraphics[width=0.5\linewidth]{example-image-a}
\caption{The image is centered, but the caption is NOT ugh... \lipsum[1]}
\end{fullwidth}
\end{figure}
\end{document}