我使用了一份包含以下几何内容的单面文档
\usepackage{geometry}
\geometry{
top=3.5cm,
bottom=3.5cm,
outer=6cm,
inner=2cm,
heightrounded,
marginparsep=0.8cm,
marginparwidth=4.7cm
}
为了使图像达到合适的大小,我使用了以下代码将图片推入边距内
\begin{figure}[h]
\newgeometry{margin=1.8cm}
...
\restoregeometry
\end{figure}
... 看起来像:
现在我在 document-class 中将纸张改为双面文档。我还更新了几何代码,如下所示
\usepackage{geometry}
\geometry{
top=3.5cm,
bottom=3.5cm,
outer=6cm,
inner=2cm,
heightrounded,
marginparsep=0.8cm,
marginparwidth=4.7cm,
twoside=true % <--- !!!!
}
但我在偶数页上处理大图片时遇到了一些问题:
图片也应该被推入边距。有什么建议可以改变
\newgeometry{margin=1.8cm}
命令?
答案1
我最终想出了使用以下代码以及一些如何设置图片和标题的示例:
\documentclass{scrartcl}
\usepackage{scrextend}
\usepackage{geometry}
\geometry{
top=3.5cm,
bottom=3.5cm,
outer=6cm,
inner=2cm,
heightrounded,
marginparsep=0.8cm,
marginparwidth=4.7cm,
twoside=true,
hmarginratio=1:1
}
\usepackage{caption}
\usepackage{subcaption}
%\usepackage{subfig}
\captionsetup[subfigure]{labelformat=simple, labelsep=colon}
\captionsetup[figure]{position=b}
\captionsetup[subfigure]{position=b}
\newcommand*{\figurewidthaddition}{\dimexpr
\marginparwidth+\marginparsep\relax}
\newsavebox\figurebox
\usepackage{mwe}
\begin{document}
\section{Testchapter}
\blindtext
\begin{figure}
\ifthispageodd{\makebox[\textwidth][l]}%
{\makebox[\textwidth][r]}%
{\includegraphics[width=1.2\textwidth,height=2cm]{example-image}}
\caption{First test figure: \blindtext}
\end{figure}
\Blindtext
\begin{figure}
\ifthispageodd{\makebox[\textwidth][l]}%
{\makebox[\textwidth][r]}%
{\includegraphics[width=1.2\textwidth,height=2cm]{example-image}}
\caption{Second test figure: \blindtext}
\end{figure}
\blindtext
\begin{figure}
\begin{addmargin*}[0pt]{-\figurewidthaddition}
\begin{minipage}{\linewidth}
\ifthispagewasodd\else\raggedleft\fi
\includegraphics[width=.9\textwidth,height=2cm]{example-image}
\caption{Third test figure: \blindtext}
\end{minipage}
\end{addmargin*}
\end{figure}
\blindtext
\begin{figure}
\begin{addmargin*}[0pt]{-\figurewidthaddition}
\begin{minipage}{\linewidth}
\ifthispagewasodd\else\raggedleft\fi
\includegraphics[width=.9\textwidth,height=2cm]{example-image}
\caption{Fourth test figure: \blindtext}
\end{minipage}
\end{addmargin*}
\end{figure}
\blindtext
test
\begin{figure}
\savebox\figurebox{%
\includegraphics[width=1.2\textwidth,height=2cm]{example-image}%
}%
\begin{addmargin*}[0pt]{\dimexpr \textwidth-\wd\figurebox\relax}
\begin{minipage}{\linewidth}
\ifthispagewasodd\else\raggedleft\fi
\usebox\figurebox
\captionsetup{width=0.8\linewidth}
\caption{Fifth test figure:jwehfewjf\"uoiewj\"ufoijew\"uoi oewfjewoi iuhew ewpfoijewf epwoifje weoipfj ewfopijwef weopifjew fwepoifjwe fpewoij}
\end{minipage}
\end{addmargin*}
\end{figure}
\blindtext
\begin{figure}
\savebox\figurebox{%
\includegraphics[width=1.2\textwidth,height=2cm]{example-image}%
}%
\begin{addmargin*}[0pt]{\dimexpr \textwidth-\wd\figurebox\relax}
\begin{minipage}{\linewidth}
\ifthispagewasodd\else\raggedleft\fi
\usebox\figurebox
\caption{Sixth test figure: \blindtext}
\end{minipage}
\end{addmargin*}
\end{figure}
\end{document}
答案2
这演示了左移和右移的图像,其标题与文本和图像都对齐。
\documentclass{scrartcl}
\usepackage{scrextend}
\usepackage{geometry}
\geometry{
top=3.5cm,
bottom=3.5cm,
outer=6cm,
inner=2cm,
heightrounded,
marginparsep=0.8cm,
marginparwidth=4.7cm,
twoside=true,
hmarginratio=1:1
}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
%\usepackage{subfig}
\captionsetup[subfigure]{labelformat=simple, labelsep=colon}
\captionsetup[figure]{position=b}
\captionsetup[subfigure]{position=b}
\newcommand{\widebox}[1]% #1 = contents
{\ifthispageodd{\rlap{#1}\rule{\textwidth}{0pt}}%
{\rule{\textwidth}{0pt}\llap{#1}}}
\usepackage{mwe}
\begin{document}
\section{Testchapter}
\blindtext
\begin{figure}
\widebox{\includegraphics[width=1.2\textwidth,height=2cm]{example-image}}
\caption{First test figure: \blindtext}
\end{figure}
\lipsum[1-4]
\begin{figure}
\widebox{\includegraphics[width=1.2\textwidth,height=2cm]{example-image}}
\caption{Second test figure: \blindtext}
\end{figure}
\blindtext
\begin{figure}
\ifthispageodd{}{\null\hspace{-.2\textwidth}}%
\begin{minipage}{1.2\textwidth}
\includegraphics[width=\textwidth,height=2cm]{example-image}
\caption{Fourth test figure: \blindtext}
\end{minipage}%
\ifthispageodd{\hspace{-.2\textwidth}}{}%
\end{figure}
\blindtext
\begin{figure}
\ifthispageodd{}{\null\hspace{-.2\textwidth}}%
\begin{minipage}{1.2\textwidth}
\includegraphics[width=\textwidth,height=2cm]{example-image}
\caption{Fourth test figure: \blindtext}
\end{minipage}%
\ifthispageodd{\hspace{-.2\textwidth}}{}%
\end{figure}
\Blindtext
\end{document}