2

(My first post - please let me know if/how I can improve my questions in the future!) (Modified to include a complete example file)

The code in question is automatically generated via a script. There are about a dozen other identical code snippets (only the file names change). Three of the twelve code segments demonstrate an unexpected additional indentation at the end of the section.


\documentclass[11pt, oneside,american]{book}
\usepackage[margin=1in]{geometry}                               % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper}                                  % ... or a4paper or a5paper or ...
\usepackage{graphicx}
\usepackage{float}
\usepackage[verbose]{wrapfig}
\usepackage[american]{babel}
\usepackage[babel]{csquotes}
\usepackage{etoolbox,xkeyval,ifthen,url}
\usepackage{enumitem}
\usepackage[
        backend=biber,
        annotation,
        loadfiles=true % this forces load of external annotations - based on naming convention
]{biblatex-chicago}
\usepackage{filecontents}
\usepackage[all]{nowidow}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage}
\usepackage{hyperref}
\input{bibs_index.tex}
\renewcommand*{\finentrypunct}{}%
\DeclareFieldFormat{citehyperref}{%
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links
\bibhyperref{#1}}
\savebibmacro{cite}
\renewbibmacro*{cite}{%
  \printtext[citehyperref]{%
  \restorebibmacro{cite}%
  \usebibmacro{cite}}}
\usepackage{fontspec}
\input{fonts.tex}
\providecommand{\tightlist}{%
  \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-1}
\setlist{nosep} %tighten up lists

\begin{document}
\mainmatter
\section{The Contributors}
\subsection{Jane~Smith}
\textsf{Washington, DC, USA}
\par \setlength{\columnsep}{0pt}
\begin{wrapfigure}{l}{0.25\textwidth} \centering \includegraphics[width=0.18\textwidth]{bios/iglazer.jpg}
\end{wrapfigure}
\textsf{ \input{random.txt} }
\WFclear
\subsubsection{Recommendations}\begin{enumerate}
\item \cite{Clippinger2007}
\item \cite{Richer2017}
\end{enumerate}\noindent\rule{\textwidth}{0.2pt}
\printbibliography
\end{document}

Odd indentation

  • 2
    wrapfigure doesn't have that much documentation but the one thing it does document is that it doesn't work near lists... It's usually possible to do something but it would be much easier to answer if you provided a complete small document that showed the problem, not a fragment. (you can use example-image as the image as it is available for such tests. – David Carlisle Mar 08 '19 at 16:06
  • Thanks for the feedback (and the welcome!) Hopefully the revised post is better (but please tell me if I can improve it). – Heather Flanagan Mar 08 '19 at 16:23
  • All you need to do is add a % immediately after \setlength{\columnsep}{0pt}. Wrapfigure needs to start in vmode, either between paragraphs or at the end of a line. Almost every time you end a line with } you add an extra space, taking you out of vmode. – John Kormylo Mar 08 '19 at 18:08
  • Tried that (made sure there were no spaces between 0pt} and %). Did that for every line that had a space after a command as well, just on general principles. No change to the output. – Heather Flanagan Mar 08 '19 at 18:17

2 Answers2

1

The simplest is to not have a float. Here is a possibility with the plain text macro package insbox, which defines \InsertBoxL and \InsertBoxR commands, with two mandatory arguments: the number of lines at the beginning of a paragraph which will remain untouched, and the box to be inserted. Also a final optional argument: the number of supplementary lines which should be shortened, in case the calculations of TeX would be wrong.

\documentclass[english]{article}

\usepackage{geometry}
\usepackage{graphicx}
\usepackage{lipsum} 
\input{insbox}
\makeatletter
\@InsertBoxMargin = 10pt
\makeatother

\begin{document}

\subsection*{Ian~Glazer} \textsf{Washington, DC, USA} \smallskip

\InsertBoxL{0}{\includegraphics[width=0.18\textwidth]{PepeLePew}}[-1]
\sffamily \lipsum[2-10]

\subsubsection{Recommendations}
    \begin{enumerate}
    \item \cite{Clippinger2007}
    \item \cite{Richer2017}
    \end{enumerate}\noindent\rule{\textwidth}{0.2pt}

\end{document} 

enter image description here

Bernard
  • 271,350
  • Hmm. Can't quite get that to work. (and can't figure out how to better format the comments so this is readable - grr) /usr/local/texlive/2018basic/texmf-dist/tex/generic/oberdiek/se-ascii-print.def)) Runaway argument? {\includegraphics [width=0.18\textwidth ]{bios/iglazer.jpg}[-1] \sffamily \ETC. ! File ended while scanning use of \InsertBoxL. \par <*> anbib-test.tex – Heather Flanagan Mar 08 '19 at 17:08
  • Can you compile my code? (add the [demo]option to graphicx, as I suppose you don't have my image) – Bernard Mar 08 '19 at 17:22
  • Yes. When I substitute a new image in the \InsertBoxL, is when I get the error. No other changes made. My line: \InsertBoxL{0}{\includegraphics[width=0.18\textwidth]{bios/iglazer.jpg}[-1] – Heather Flanagan Mar 08 '19 at 17:34
  • AhHA! Found it! Missing a closing curly bracket! Score!!! – Heather Flanagan Mar 08 '19 at 18:08
  • All but one of the entries now format correctly and all entries are automatically generating. The one that is not generating properly in my production file seems identical to the others but shows a mostly blank page then text and image partially overlapped. The code for that entry works when extracted into a test file. I need a drink. – Heather Flanagan Mar 08 '19 at 18:54
  • Perhaps a problem of bounding box? To test, nest your include graphics in a \fbox. – Bernard Mar 08 '19 at 19:05
  • Like this? \InsertBoxL{0}{\fbox{\includegraphics[width=0.18\textwidth]{bios/cscholefield.jpg}}} – Heather Flanagan Mar 08 '19 at 19:36
  • Yes, exactly ${}$. – Bernard Mar 08 '19 at 19:39
  • No change. I added the \fbox to the entries immediately before and after in case there was some weird inheritance going on. Absolutely nothing interesting in the log file to help. – Heather Flanagan Mar 08 '19 at 19:47
  • And the bounding box is not larger than the real image? – Bernard Mar 08 '19 at 19:55
  • @HeatherFlanagan -- You say that all but one instance of the insertion works. It sounds like that may be occurring at a page break. (Such things can get a bit squirrelly at page breaks.) Try adding a forced page break (\newpage perhaps) at the last paragraph break before the insertion. I'm not able to test; this is just an educated guess. – barbara beeton Mar 09 '19 at 01:55
  • @Bernard, how/why would the bounding box for this one image (which is roughly the same size than all the other images in this document) be different? I'm not sure how to check about the actual size of the bounding box - I'll go look that up. – Heather Flanagan Mar 09 '19 at 16:54
  • @barbarabeeton, unfortunately, the \newpage did not help. – Heather Flanagan Mar 09 '19 at 16:54
  • The document itself, with the tex revised to use the insbox layout, is public on GitHub if folks want a better idea of what I'm seeing. Page 4-5. – Heather Flanagan Mar 09 '19 at 17:40
  • Did you try \enlargethispage{n\baselineskip} (1 or 2 might be enough)? – Bernard Mar 09 '19 at 18:07
1

The package lettrine is mainly designed for dropped capitals, but it also allow put a left wrapped image at the start of a paragraph, with a very simple code. Moreover, \lettrine have several options that allow a fine-tuning of the image position.

Unfortunately for this case, it is designed for a single paragraph, with no indentation of the first line,. But for the fist problem is easy make a \fakepar and for the second the \lettrine options are enough, as show the example:

mwe

\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}        
\usepackage{lettrine}
\usepackage{graphicx}
\usepackage{lipsum} % only for dummy text
\renewcommand\familydefault{\sfdefault}
\parskip1em
\parindent2em

\def\fakepar{\hfill\mbox{}\vspace{\parskip}\newline\mbox{}\hspace{\parindent}}
\begin{document}

\subsection*{Robert Conway}
Shangri-La, Lost Horizons, Kunlun Mountains\par\bigskip

\lettrine[
lines=13,
lraise=-.1,
findent=5em,
nindent=-2em,
lhang=-.2,
depth=1,
image=true]{example-image-golden-upright}{}% 
\lipsum[1][1-4] 
\lipsum[2][1-4]\fakepar
\lipsum[3-7]

\end{document} 
Fran
  • 80,769