我想调整两侧边距中的边距图形的大小
这是我的 MWE
\documentclass{caesar_book}
% -- use dummy graphics
\usepackage{mwe}
%auto generate the bib file
\usepackage{filecontents}
% -- language: English --
\usepackage[english]{babel}
% -- biblatex --
\usepackage[backend=biber,style=philosophy-classic]{biblatex} % xxx
% the .bib file with the references
\usepackage{blindtext}
\begin{document}
\section*{Scaling a marginfigure in the direction of a marginside}
\blindtext[1]
\begin{marginfigure}%
\includegraphics[width=1.2\textwidth]{example-image-a}%
\caption{A small rectangle put in the margin.\label{rectangle}}%
\end{marginfigure}%
\blindtext[2]
\newpage
\blindtext[1]
\begin{marginfigure}%
\includegraphics[width=1.2\textwidth]{example-image-a}%
\caption{A small rectangle put in the margin.\label{rectangle}}%
\end{marginfigure}%
\blindtext[2]
\end{document}
当 marginfigure 位于左边距时,就会出现此问题。
调整左边距的图形大小会导致图形和文本重叠。
答案1
使用\mfincludegraphics
插入超大图片的命令;超出部分将自动地向外边距方向移动。你不需要知道图片会排版在哪一页上。
这可能需要多次运行 LaTeX 才能稳定下来。
在下面的代码中,我添加了两个空白页,因此一个图形位于左侧页面,另一个位于右侧页面,以查看差异。
\documentclass{caesar_book}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{refcount}
\usepackage{blindtext}
\newcounter{mfig}
\newcommand{\mfincludegraphics}[2][]{%
\refstepcounter{mfig}\label{\themfig}%
\makebox[\textwidth][\ifodd\getpagerefnumber{\themfig}l\else r\fi]{%
\includegraphics[#1]{#2}%
}%
}
\begin{document}
\mbox{}\newpage
\section*{Scaling a marginfigure in the direction of a marginside}
\blindtext[1]
\begin{marginfigure}
\mfincludegraphics[width=1.2\textwidth]{example-image-a}
\caption{A small rectangle put in the margin.\label{rectangle-A}}
\end{marginfigure}
\blindtext[2]
\newpage
\blindtext[1]
\begin{marginfigure}
\mfincludegraphics[width=1.2\textwidth]{example-image-a}
\caption{A small rectangle put in the margin.\label{rectangle-B}}
\end{marginfigure}
\blindtext[2]
\newpage\mbox{}
\end{document}
答案2
您可以将\marginparwidth
其放大并达到相同的效果,而无需过多的\hbox
警告。
\documentclass{caesar_book}
% -- use dummy graphics
\usepackage{mwe}
%auto generate the bib file
\usepackage{filecontents}
% -- language: English --
\usepackage[english]{babel}
% -- biblatex --
\usepackage[backend=biber,style=philosophy-classic]{biblatex} % xxx
% the .bib file with the references
\usepackage{blindtext}
\setlength{\marginparwidth}{1.2\marginparwidth}
% to center marginpar in margin given \marginparsep
%\setlength{\marginparwidth}{\dimexpr \paperwidth-\textwidth-\oddsidemargin-1in-2\marginparsep}
\begin{document}
\section*{Scaling a marginfigure in the direction of a marginside}
\blindtext[1]
\begin{marginfigure}%
\includegraphics[width=\textwidth]{example-image-a}%
\caption{A small rectangle put in the margin.\label{rectangle}}%
\end{marginfigure}%
\blindtext[2]
\newpage
\blindtext[1]
\begin{marginfigure}%
\includegraphics[width=\textwidth]{example-image-a}%
\caption{A small rectangle put in the margin.\label{rectangle}}%
\end{marginfigure}%
\blindtext[2]
\end{document}