# Image not centering in fullwidth even page

My MWE is,

\documentclass[a4paper,twoside,openright,11pt]{scrbook}

\usepackage[left=1.5cm,right=1cm,top=3cm,bottom=1.5cm,marginparwidth=5.5cm,marginparsep=1cm,outer=8cm]{geometry}

\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{ifoddpage}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{calc}
\usepackage{showframe}

\newlength\extraWd
\setlength\extraWd{\dimexpr\marginparwidth+\marginparsep\relax}

\begin{document}

\begin{figure}[h]
\captionsetup{margin={0cm,-\extraWd}}
\checkoddpage
\edef\side{\ifoddpage c\else l\fi}
\makebox[\fullwidth][\side]{%
\fbox{\includegraphics[keepaspectratio=false,width=6cm]{example-image-a}}
}%
\caption{In the previous paragraphs, we mentioned the word “charge”. However, we need to look at its meaning in more detail.}
\end{figure}

\newpage

\begin{figure}[h]
\captionsetup{margin={0cm,-\extraWd}}
\checkoddpage
\edef\side{\ifoddpage c\else l\fi}
\makebox[\fullwidth][\side]{%
\fbox{\includegraphics[keepaspectratio=false,width=6cm]{example-image-a}}
}%
\caption{In the previous paragraphs, we mentioned the word “charge”. However, we need to look at its meaning in more detail.}
\end{figure}

\end{document}


And no problem odd page output, exactly centering, {left space 10cm, right space 10cm}

But there is a problem even page. Not exactly centering. {left space 11cm, right space 9cm}

As a matter of fact, the image is 1 cm (\marginparwidth) left shifting. Or do centering of \fullwidth. I cannot do, a few days.

I am sure, easy for you but not for me. I didn't find duplicate another question. I found like its, don't working in full my code. Does anyone know how to fix it?

Related: Let caption float into margin

• Should it center to the full pagewidth or to the textwidth part of it? For the full pagewidth, there is a problem, that your left and right margins are not equal, so it cannot center this way – user31729 Sep 13 '14 at 9:21
• pagewidth, that is [\textwidth+\marginparwidth+\marginparsep] @Christian Hupfer. – Özgür Sep 13 '14 at 9:23
• You have a 'huge' margin width -- I don't get it, why you want to center it the page width then -- it would shift the image near the margin, which looks a little bit odd, I my point of view. – user31729 Sep 13 '14 at 9:27
• Like your writing, looks a little bit. So, never mind. Response received. – Özgür Sep 13 '14 at 9:32
• I don't understand your last comment – user31729 Sep 13 '14 at 9:36

Let us analyse. First we add a \fbox around the \makebox like:

\fbox{\makebox[\fullwidth][\side]{%
\fbox{\includegraphics[keepaspectratio=false,width=6cm]{example-image-a}}
}}%


to get

for odd page and

for even page. You would want this box to cover the entire width i.e., \textwidth +\marginparwidth +\marginparsep which is true for odd page but not for even page. For even page, the box starts inside the text area which should start from the marginpar area so as to cover up to the end of text area with a center alignment.

Code:

\documentclass[a4paper,twoside,openright,11pt]{scrbook}

\usepackage[left=1.5cm,right=1cm,top=3cm,bottom=1.5cm,marginparwidth=5.5cm,marginparsep=1cm,outer=8cm]{geometry}

\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage{ifoddpage}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{calc}
\usepackage{showframe}

\newlength\fullwidth
\setlength{\fullwidth}{\dimexpr\textwidth +\marginparwidth +\marginparsep\relax}
\newlength\extraWd
\setlength\extraWd{\dimexpr\marginparwidth+\marginparsep\relax}

\begin{document}

\begin{figure}[h]
\captionsetup{margin={0cm,-\extraWd}}
\checkoddpage
\ifoddpage
\fbox{\makebox[\fullwidth][c]{%
\fbox{\includegraphics[keepaspectratio=false,width=6cm]{example-image-a}}
}}%
\else
\hspace*{-\extraWd}%
\fbox{\makebox[\fullwidth][c]{%
\fbox{\includegraphics[keepaspectratio=false,width=6cm]{example-image-a}}
}}%
\fi
\caption{In the previous paragraphs, we mentioned the word “charge”. However, we need to look at its meaning in more detail.}
\end{figure}

\newpage

\begin{figure}[h]
\captionsetup{margin={0cm,-\extraWd}}
\checkoddpage
\ifoddpage
\fbox{\makebox[\fullwidth][c]{%
\fbox{\includegraphics[keepaspectratio=false,width=6cm]{example-image-a}}
}}%
\else
\hspace*{-\extraWd}%
\fbox{\makebox[\fullwidth][c]{%
\fbox{\includegraphics[keepaspectratio=false,width=6cm]{example-image-a}}
}}%
\fi
\caption{In the previous paragraphs, we mentioned the word “charge”. However, we need to look at its meaning in more detail.}
\end{figure}

\end{document}


Without outer \fbox:

\ifoddpage
\makebox[\fullwidth][c]{%
\fbox{\includegraphics[keepaspectratio=false,width=6cm]{example-image-a}}
}%
\else
\hspace*{-\extraWd}%
\makebox[\fullwidth][c]{%
\fbox{\includegraphics[keepaspectratio=false,width=6cm]{example-image-b}}
}%
\fi


• Perfect working, This is it what I want, question [closed] @Harish Kumar. – Özgür Sep 13 '14 at 16:28
• Harish Kumar, Would you be interested in? tex.stackexchange.com/questions/200519/… – Özgür Sep 13 '14 at 20:24
• @Özgür: I think the accepted answer does what you need. Is there any thing missing? Please let me know. – user11232 Sep 14 '14 at 1:38
• It's working. But figure number not increase. Body Figure 0.1 then does not margin Figure 0.2 It is not normally counting. – Özgür Sep 14 '14 at 4:11
• @Özgür So you want body figure to be 0.1 and margin figure to be 0.2? – user11232 Sep 14 '14 at 13:32