# insertgraphics not respecting bindingoffset on LH pages

This is "messed up" and does not have the figure environment:

This is "not messed up" and has the figure environment:

What is causing this?

Thanks!!!

I am setting up a photobook and have everything working except the left pages with included graphics. Graphics on the right side have the bindingoffet, just not on the left side. All text sections and title pages have offset.

\documentclass[openright,twoside,12pt]{book}


Using these commands to insert images:

\newcommand{\addphoto}[1]{
\begin{figure}
\vspace*{.5cm}
\centering
\includegraphics[scale=1]{#1}
\newpage
\end{figure}
}


Which uses these packages:

\usepackage[bindingoffset=0.75in]{geometry}
\usepackage{graphicx}


Inserting test photos after text sections like this:

\section{City One}
\pagestyle{fancy}
\lipsum[1-2]
\newpage


Thank you for all help! I don't know how to get the LHS images to be centered while respecting the bindingoffset which is of course needed for printing.

mark

\documentclass[openright,twoside,12pt]{book}
\usepackage[
paperwidth=8.5in,
paperheight=8.5in,
bindingoffset=0.2in,
left=1.25in,
right=1.25in,
top=1.25in,
bottom=1.11in,
includefoot
]{geometry}
\usepackage{graphicx}
\usepackage[usenames]{xcolor}
\usepackage{fancyhdr}
\fancyhf{}
\setlength{\footskip}{45pt}
\fancyfoot[C]{\textcolor{gray}{\thepage}}
\pagestyle{fancy}
\graphicspath{ {images/} }
\begin{figure}
\vspace*{-.8cm}
\centering
\includegraphics[width=5.5in]{#1}
\newpage
\end{figure}
}
\usepackage{lipsum}
\parindent=0in
\parskip=12pt
\setcounter{secnumdepth}{0}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
\let\oldsection\section
\renewcommand{\section}{\cleardoublepage\oldsection}
\newcommand{\nosection}[1]{%
\refstepcounter{section}%
\markright{#1}}
\begin{document}
\pagestyle{empty}
\tableofcontents
\thispagestyle{empty}
\frontmatter
\section{Forward}
\lipsum[1-10]
\section{Introduction}
\lipsum[1-10]
\mainmatter
\pagestyle{fancy}
\section{City One}
\lipsum[1-3]
\newpage
\section{City Two}
\lipsum[1-2]
\newpage
\section{City Three}
\lipsum[1-2]
\newpage
\end{document};

• Remove the figure environment from your \addphoto command to start with. It doesn't make any sense at all. – Johannes_B May 1 '18 at 5:48
• Your images are not scaled. They are imported with the size they actually have. If the photo is bigger than the textwidth, it will run into the margin. – Johannes_B May 1 '18 at 5:50
• Thanks Johannes! Yes, the images have to be scaled down a tiny bit and then they work out fine. I'm still puzzled why they looked good on the RHS and not on LH pages. If I take the figure environment out, then my following sections get all scrambled! No, I'm just learning, so I appreciate that I'm probably doing everything really stupidly, but I'm trying. Thanks! – mh2000 May 1 '18 at 6:01
• A figure environment places the image for you at a good place. But i guess You want to decide where the images are placed in a photo book? – Johannes_B May 1 '18 at 6:04
• No idea, you posted just snippets. – Johannes_B May 1 '18 at 6:17

• I have trouble to understand your question. I stripped down your code to a more minimal version.
• I also removed the \begin{figure} ... \end{figure} stuff as it's useless (as I understand your intention) as already mentioned in the comments.
• I also think that \vspace*{-.8cm} will cause trouble since you use the same negative vertical distance for every instance of your pictures.
• Maybe try to use the minimal code I propose and show your problem with the minimal code.

\documentclass{book}
\usepackage{graphicx}
\usepackage{fancyhdr}

% OP's command
%\begin{figure}
%\vspace*{-.8cm}
\centering
\includegraphics[width=5.5in]{#1}
\newpage
%\end{figure}
}
\usepackage{lipsum}

\begin{document}

\pagestyle{empty}
\tableofcontents
\thispagestyle{empty}
\frontmatter

\section{Forward}
\lipsum[1-10]

\section{Introduction}
\lipsum[1-10]
\mainmatter
\pagestyle{fancy}

\section{City One}
\lipsum[1-3]

\section{City Two}
\lipsum[1-2]

\section{City Three}
\lipsum[1-2]

\end{document}

• Even in your stripped down code, the last two sections are messed up. Run your's with and without and you will see difference! Yeah, I think the \vspace*{-.8cm} has to be there because I am fighting with the figure environment. But I do need to have all my sections formatted the same and correctly. If you have a moment to run your code with and without and tell me why the the last two sections come out so differently, I'd really appreciate it! – mh2000 May 1 '18 at 15:23
• @mh2000 Please indicate in a Screenshot what you think is messed up. "messed up" is not very specific. Use my code and show what you mean. – Dr. Manuel Kuehner May 1 '18 at 15:29
• I added screen captures to show what I mean using your reduced code. The sections above the added images are "not messed up." – mh2000 May 2 '18 at 5:13

The answer to my original question was simply that without scaling the image to the width of the text, the graphic placement was unpredictable -- so ensure you are scaled to fit inside your margins! The second question regarding using the figure environment, while users here are telling me that it's "useless," others locally (PhD students who use LaTeX all the time) have told me that it is how they always do it. . . so in this case, I guess the answer is, "There's lots of ways to do things in LaTex and as long as you get the desired results, it's all good!"

Best and thanks all!

The following puts the image in a center environment that centers the image horizontally and adds some vertical space.

Also the image is set in natural size unless its width is larger than the line width. In the latter case the image is limited to the line width, see this answer of David Carlisle).

\makeatletter
\def\maxwidth#1{\ifdim\Gin@nat@width>#1 #1\else\Gin@nat@width\fi}
\makeatother

\begin{center}%
\includegraphics[width=\maxwidth\linewidth]{#1}%
\end{center}%
}


The horizontally ragged text is caused by \centering, if it is not used inside a group like the figure environment. Otherwise \centering is active until the end of the document unless overwritten by \raggedright or \raggedleft (or similar commands).

If the image should be used with \centering:

\par % end previous paragraph (it should probably not be centered)
\begingroup % group start to limit the scope of \centering
\centering
\includegraphics[width=\maxwidth\linewidth]{...}% see above
\par % center the pragraph with the image and end paragraph.
\endgroup % group ends

• Thank you Heiko!! I will play with these tonight! As I said, I've only been doing this for a week and am really trying to learn everything I can to make better books! Much better than fighting with Word for sure!! Best!! – mh2000 May 3 '18 at 22:29