I am attempting to center two subfigures relative to the page. However due to \setlength\oddsidemargin{15mm}, the figures are slightly shifted to the right.
I have uploaded the current output in the first output below. The second figure is the output I wanted. Thank you for your help.

Asked
Active
Viewed 89 times
0
-
3Does this answer your question? Center figure that is wider than \textwidth – steve Apr 18 '20 at 16:16
-
@ABlueChameleon - \makebox will center the contents relative to the text area which, in this case, is not centered relative to the page. – John Kormylo Apr 18 '20 at 16:39
-
@JohnKormylo That's a very fair point, my bad. Sorry! – steve Apr 18 '20 at 18:25
1 Answers
0
Since floats may not appear on the same page they are created on, I used the ifoddpage package. It may take two runs to get the left margin correct.
Note: your desired image showed the caption in the text area, but it would also go into the \fullwidth field. You can also use \centering etc. inside.
\documentclass{book}
\usepackage{graphicx}
\usepackage{ifoddpage}
\usepackage{lipsum}% MWE only
\newcommand{\fullwidth}[1]% #1 = text for full width
{\bgroup% for local \dimen0
\checkoddpage
\ifoddpage \dimen0=\oddsidemargin
\else \dimen0=\evensidemargin
\fi
\advance\dimen0 by 1in
\parskip=0pt% overkill
\par\noindent\rlap{\hskip-\dimen0\parbox{\paperwidth}{#1}}\par
\egroup}
\begin{document}
\begin{figure}
\fullwidth{%
\includegraphics[width=0.45\paperwidth]{example-image-a}\hfill
\includegraphics[width=0.45\paperwidth]{example-image-b}}
\caption{\LipsumPar{1}}
\end{figure}
\lipsum[1-5]
\end{document}
John Kormylo
- 79,712
- 3
- 50
- 120
