我想使用 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
. AFAIK,它確實改變了,\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}