Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Let me start by saying that this is very similar to a previously posted question, How to keep a constant baselineskip when using minipages (or \parboxes)?, for which egreg gave a very nice solution. But either I'm not thinking through egreg's solution correctly or this is a closely related but nevertheless different question.

Also, I know I am doing things here that are generally frowned upon: namely, I set \parskip. But, I'm only doing this to create visually what it is that I don't want: LaTeX to think that I have a new paragraph here. LaTeX thinking there's a new paragraph does become an issue if, for example, I'm using \everypar to perform some task at the beginning of every paragraph.

Onto my question:

I occasionally find that I must align minipages to fill a line after which I do not want a new paragraph but a continuation of the current paragraph. But for some reason the interlinear spacing between the line filled with minipages and the following line is too small.

I could fix this by inserting \par~ at the end of the apparently offending minipage, or by using \\[\baselineskip] at the end of the line. But that opens up too excessive a break and visually creates the appearance of a new paragraph. My desire is not to create that visual break but rather insert the proper interlinear spacing. As mentioned already, egreg's solution introduces a new paragraph which is not what I want. When I try to use egreg's solution without introducing a new paragraph I get an error about being in horizontal mode.

I could put in a strut at the end of the minipage to add more depth, but I really hate just eye-balling it when it seems I should be able to get the interlinear spacing perfect.

Also, sometimes I can fix this by setting \hangindent. But there are times when that's really not a feasible solution. Finally, I'd also prefer to avoid using the wrapfig package because there are other contexts in which I need a similar correction but wrapping is not what is needed.

Here's my MWE:

\documentclass{article}
\usepackage{calc}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{pst-node}
\usepackage[margin=1.25in]{geometry}
%%
\newcommand{\mytext}{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}
\setlength{\parskip}{5ex}
\pagestyle{empty}
\begin{document}
\newsavebox{\righthandmatter}
\begin{lrbox}{\righthandmatter}
     \fbox{\begin{minipage}[t]{0.35\linewidth-2\fboxrule-2\fboxsep-2em}
         \vspace{-\baselineskip}
         \rule[-1cm]{0pt}{2cm} Some image or something
     \end{minipage}}
\end{lrbox}


\noindent%
\textbf{Example 1:} Interlinear spacing is undesirably small---see arrow.\\[0.5\baselineskip]
\noindent%
\begin{minipage}[t]{0.65\linewidth}
    \raisebox{0pt}[0pt][0pt]{\rput(-3ex,-8.25\baselineskip){\color{blue}\rnode{A}{$\longrightarrow$}}}
    \lipsum[2]
\end{minipage}\hspace*{\fill}%
\usebox{\righthandmatter}
\mytext

\noindent%
\textbf{Example 2:} Following \texttt{egreg}'s suggestion: \LaTeX\ thinks there's a new paragraph---see arrow.\\[0.5\baselineskip]
\noindent%
\begin{minipage}[t]{0.65\linewidth}
    \raisebox{0pt}[0pt][0pt]{\rput(-3ex,-8.25\baselineskip){\color{blue}\rnode{B}{$\longrightarrow$}}}
    \raisebox{0pt}[0pt][0pt]{\rput(3.5in,-9.0\baselineskip){\color{blue}\rnode{C}{$\longleftarrow$ \fbox{\footnotesize{}Undesired new paragraph.}}}}
    \lipsum[2]
    %% solution suggested by egreg
    \par\xdef\tpd{\the\prevdepth}
\end{minipage}\hspace*{\fill}%
\usebox{\righthandmatter}

%% enacting egreg's solution (But now I have a new paragraph).
\prevdepth\tpd%
\noindent\mytext

\vspace{1.5ex}
\noindent%
\textbf{Example 3:}  Interlinear spacing is as I want, but lines of the following text terminate too soon.\\[0.5\baselineskip]
\noindent%
\begin{minipage}[t]{0.65\linewidth}
    \raisebox{0pt}[0pt][0pt]{\rput(-3ex,-8.25\baselineskip){\color{blue}\rnode{D}{$\longrightarrow$}}}%
    \raisebox{0pt}[0pt][0pt]{\rput(4.8in,-8.75\baselineskip){\color{blue}\rnode{E}{$\longleftarrow$ \fbox{\footnotesize{}line terminates too soon.}}}}
    \lipsum[2]
    \mytext
\end{minipage}\hspace*{\fill}%
\usebox{\righthandmatter}

\end{document}

Here's an image:

,

How do I fix the interlinear spacing to get the desired effect?

To better illustrate I provide another example. The right hand matter is indivisible such as a graphic. The left hand matter consists of a variety of paragraphs, equations, spaces for student responses, and possibly more graphics.

Please keep in mind that this is a MWE so the content of the material which justifies formatting decisions is lost. But also, I usually face these sorts of formatting decisions in contexts where material resources are scarce and the luxury of using multiple pages cannot be abused too often.

enter image description here

Following StephanLehmke's suggestion of \parshape: I could write

\documentclass{article}
\usepackage{calc}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{pst-node}
\usepackage[margin=1.25in]{geometry}
%%
\setlength{\parskip}{5ex}
\newlength{\aelinewidth}
\pagestyle{empty}
\begin{document}
\setlength{\aelinewidth}{\linewidth}
\newsavebox{\righthandmatter}
\begin{lrbox}{\righthandmatter}
     \fbox{\begin{minipage}[t]{0.35\linewidth-2\fboxrule-2\fboxsep-2em}
         \vspace{-\baselineskip}
         \rule[-2.5cm]{0pt}{3.5cm}\parbox{\linewidth}{\raggedright{}Some image or something that is unbreakable}
     \end{minipage}}
\end{lrbox}

\noindent%
\begin{minipage}[t]{0.65\linewidth}
    \begin{minipage}[t]{\linewidth}
    \textbf{Question 1:}   
    Nam dui ligula, fringilla a, euismod sodales, sol- licitudin vel,
    wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at,
    lobortis vitae, ultricies et, tellus. Donec ali- quet, tortor sed\par
    \parshape 6  0pt \linewidth 0pt \linewidth 0pt \linewidth 0pt \linewidth 0pt \linewidth 0pt 6in
    \textbf{Question 2:}   
    Nam dui ligula, fringilla a, euismod sodales, sol- licitudin vel,
    wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at,
    lobortis vitae, ultricies et, tellus. Donec ali- quet, tortor sed
    accumsan bibendum, erat ligula aliquet magna, vitae ornare odio metus a
    mi. Morbi ac orci et nisl hendrerit mol- lis. Suspendisse ut
    massa. Cras nec ante. Pellentesque a nulla. Cum sociis natoque
    penatibus et magnis dis parturient montes, nascetur ridiculus
    mus. Aliquam tincidunt urna. Nulla ullamcor- per vestibulum
    turpis. Pellentesque cursus luctus mauris.  \textbf{Continuation of
    question 2's paragraph} Lorem ipsum dolor sit amet, consectetuer
    adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing
    vitae, felis.  Nam dui ligula, fringilla a, euismod sodales, sol-
    licitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero,
    pretium at, lobortis vitae, ultricies et, tellus. Donec ali- quet,
    tortor sed accumsan bibendum, erat ligula aliquet magna, vitae ornare
    odio metus a mi. Morbi ac orci et

    \end{minipage}
\end{minipage}\hspace*{\fill}%
\usebox{\righthandmatter}

\end{document}

which gives me a reasonably good result like I wanted:

enter image description here

So now my question becomes, is there an approach other than using \parshape which is more in the spirit and style of egreg's solution on the above mentioned link? Essentially, I feel that I'm not understanding something about interlinear glue. I guess I'm asking for a clarification of that glue which would be applicable in the situations I've illustrated above.

This is probably the wrong place to put this comment: But, interestingly enough, I had to embed my \parshape paragraph inside another minipage or else the width of the containing minipage is ignored. This related to an earlier question I posted minipage is wider than I wanted. The solution I got before was that it had to do something with how align worked whether the equation was tagged or not. Remove the inner wrapping minipage and there's another example whether the minipage width is ignored.

share|improve this question
1  
Independent of other considerations, \parshape should be used for this purpose. –  Stephan Lehmke Dec 6 '12 at 4:39
    
The consideration "I occasionally find that I must align minipages to fill a line after which I do not want a new paragraph but a continuation of the current paragraph." is absurd. This can't be done. You must rethink this conceptually. –  Stephan Lehmke Dec 6 '12 at 4:42
add comment

2 Answers

up vote 4 down vote accepted

I suspect you are over using minipage but anyway if you want to stitch paragraphs together you either need to ensure that the last line of the first paragraph ends flush, or you need to measure the last line and indent the next para by the same amount so they slot together.

This shows both methods:

enter image description here

\documentclass{article}
\usepackage{calc}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{pst-node}
\usepackage[margin=1.25in]{geometry}
%%
\newcommand{\mytext}{ABC Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}
\setlength{\parskip}{5ex}
\pagestyle{empty}
\begin{document}
\newsavebox{\righthandmatter}
\begin{lrbox}{\righthandmatter}
     \fbox{\begin{minipage}[t]{0.35\linewidth-2\fboxrule-2\fboxsep-2em}
         \vspace{-\baselineskip}
         \rule[-1cm]{0pt}{2cm} Some image or something
     \end{minipage}}
\end{lrbox}


\noindent%
\textbf{Example 2:} Following \texttt{egreg}'s suggestion: \LaTeX\ thinks there's a new paragraph---see arrow.\\[0.5\baselineskip]
\noindent%
\begin{minipage}[t]{0.65\linewidth}
    {\let\par\relax\lipsum[2]}%dont let lipsum end the para
    %% solution suggested by egreg
        \parfillskip0pt\par\xdef\tpd{\the\prevdepth}
\end{minipage}\hspace*{\fill}%
\usebox{\righthandmatter}

%% enacting egreg's solution (But now I have a new paragraph).
\prevdepth\tpd%
{\parskip0pt\noindent}\mytext


\noindent%
\textbf{Example 2b:} Following \texttt{egreg}'s suggestion: \LaTeX\ thinks there's a new paragraph---see arrow.\\[0.5\baselineskip]
\noindent%
\begin{minipage}[t]{0.65\linewidth}
    {\let\par\relax\lipsum[2]}%dont let lipsum end the para
\abovedisplayskip0pt
\belowdisplayskip0pt
\abovedisplayshortskip0pt
\belowdisplayshortskip0pt
    $$\xdef\pds{\the\predisplaysize}$$%
\end{minipage}\hspace*{\fill}%
\usebox{\righthandmatter}
%% enacting egreg's solution (But now I have a new paragraph).
\par\prevdepth0pt
{\par\kern-2\baselineskip\parskip0pt\noindent}\kern\pds\kern-1em \mytext

\end{document}
share|improve this answer
    
Thank you. Your first solution is exactly what I was looking for. But, I'm very intrigued by your second solution and I'm not entirely sure I understand what you're doing. I see a faux math equation and what looks like a lot of vertical parameters being set. But somehow out of that you're getting the next paragraph to indent by the necessary length. Would you mind elaborating how the code of your second example achieves its effect? –  A.Ellett Dec 6 '12 at 13:46
    
Also, thank you for showing how to get lipsum not to end the paragraph. –  A.Ellett Dec 6 '12 at 13:47
1  
well it's second time I've used that trick this week, see the comments (and commented code) in tex.stackexchange.com/questions/85315/… –  David Carlisle Dec 6 '12 at 14:17
    
beautiful and now your code makes very good sense to me. –  A.Ellett Dec 6 '12 at 14:25
1  
hmm maybe should have a MWE but looking at that code I remove 1em space actually TeX pads by 2em so it is probably better to remove 2em then add a word space change \kern-1em to \kern-2em{ } Note the spacing in the stitched together line might be a bit uneven as the first half was padded with \parfillskip glue initially so it will be natural size but the second half is set as part of the new para so the white space may be stretched or shrunk as usual. (if you were not on the main vertical list eg in a minipage you could remove the last line box and unbox it to unset its inter-word spaces. –  David Carlisle Jan 12 '13 at 23:44
show 2 more comments

Per @StephanLehmke 's comment and this solution to another question of mine, it seems combining \parshape with the \leavevmode\struc\vadjust trick of @DavidCarlisle will achieve the deisred effect.

The underlying issue is that, when I create exams and quizzes, I find I cannot rely on floats to put the images in an appropriate place. Also, I must economize on space. So, I often need to finely control the position, shape, and structure of content. This occasionally means that my text must wrap around images or other inset material such as boxes for answers or small tables of values.

The MWE that I'm posting here is a bit on the extreme edge of things since I'm wrapping around two images (I don't think I'd really want to do something this extreme in practice). Also, I do not mean to suggest this as a general all-purpose sort of answer. This is an answer for a relatively short document (such as a quiz or a handout) for which the author (not LaTeX) is primarily making the decisions about page breaks.

Here's a MWE which shows how to combine these two approaches:

\documentclass{article}
\usepackage[margin=1.25in]{geometry}
\usepackage{graphicx}
%%--------------------------------------------------------------------------------
\newlength{\imageAwidth} \setlength{\imageAwidth} {\dimexpr 6cm    \relax}   
\newlength{\imageAheight}\setlength{\imageAheight}{\dimexpr 2.5in  \relax}
\newcommand{\myImageA}{\includegraphics[width=\imageAwidth,height=\imageAheight]{example-image-a}}
%%--------------------------------------------------------------------------------
\newlength{\imageBwidth} \setlength{\imageBwidth} {\dimexpr 3cm    \relax}   
\newlength{\imageBheight}\setlength{\imageBheight}{\dimexpr 1.25in \relax}
\newcommand{\myImageB}{\includegraphics[width=\imageBwidth,height=\imageBheight]{example-image-b}}
%%--------------------------------------------------------------------------------
\pagestyle{empty}
\begin{document}
%%\raggedright%%<-- uncommenting this will result in some odd behavior.

%% Placing the image for the right-hand side
{\leavevmode\strut\vadjust{%
    \noindent\hspace*{\linewidth}%
    \makebox[0pt][r]{%
        \raisebox{\dimexpr\dp\strutbox-14.5\baselineskip\relax}[0pt][0pt]
                 {\myImageA}}}%
\ignorespacesafterend}%
%% Placing the image for the left-hand side
{\leavevmode\strut\vadjust{%
    \noindent%
    \makebox[0pt][l]{%
        \raisebox{\dimexpr\dp\strutbox-20\baselineskip\relax}[0pt][0pt]
                 {\myImageB}}}%
\ignorespacesafterend}%
%%--------------------------------------------------------------------------------
%% START: defining paragraph shape to wrap around the two images or inset material
\parshape=22
%% -- adjust for image-a to the right
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
    0pt                                     \dimexpr \linewidth - \imageAwidth - 1em \relax
%% -- squeeze text between the two images
    \dimexpr \imageBwidth + 1em \relax      \dimexpr \linewidth - \imageAwidth - 1em - \imageBwidth - 1em \relax
    \dimexpr \imageBwidth + 1em \relax      \dimexpr \linewidth - \imageAwidth - 1em - \imageBwidth - 1em \relax
    \dimexpr \imageBwidth + 1em \relax      \dimexpr \linewidth - \imageAwidth - 1em - \imageBwidth - 1em \relax
%% -- adjust for image-b to the left
    \dimexpr \imageBwidth + 1em \relax      \dimexpr\linewidth - \imageBwidth - 1em \relax
    \dimexpr \imageBwidth + 1em \relax      \dimexpr\linewidth - \imageBwidth - 1em \relax
    \dimexpr \imageBwidth + 1em \relax      \dimexpr\linewidth - \imageBwidth - 1em \relax
    \dimexpr \imageBwidth + 1em \relax      \dimexpr\linewidth - \imageBwidth - 1em \relax
    \dimexpr \imageBwidth + 1em \relax      \dimexpr\linewidth - \imageBwidth - 1em \relax
%% -- restore usual paragraph shape
    0pt                                     \linewidth
%% END: defining paragraph shape
%%--------------------------------------------------------------------------------
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.  Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis.  Curabitur dictum
gravida mauris.  Nam arcu libero, nonummy eget, consectetuer id, vulputate
a, magna.  Donec vehicula augue eu neque.  Pellentesque habitant morbi
tristique senectus et netus et malesuada A fames ac turpis egestas.  Mauris
ut leo.  Cras viverra metus rhoncus sem.  Nulla et lectus vestibulum urna
fringilla ultrices.  Phasellus eu tellus sit amet tortor gravida placerat.
Integer sapien est, iaculis in, pretium quis, viverra ac, nunc.  Praesent
eget sem vel leo ultrices bibendum.  Aenean faucibus.  Morbi dolor nulla,
malesuada eu, pulvinar at, mollis ac, nulla.  Curabitur auctor semper
nulla.  Donec varius orci eget risus.  Duis nibh mi, congue eu, accumsan
eleifend, sagittis quis, diam.  Duis eget orci sit amet orci dignissim
rutrum.  Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel,
wisi.  Morbi auctor lorem non justo.  Nam lacus libero, pretium at,
lobortis vitae, ultricies et, tellus.  Donec aliquet, tortor sed accumsan
bibendum, erat ligula aliquet magna, vitae ornare odio metus a mi.  Morbi
ac orci et nisl hendrerit mollis.  Suspendisse ut massa.  Cras nec ante.
Pellentesque a nulla.  Cum sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus mus.  Aliquam tincidunt urna.  Nulla
ullamcorper vestibulum turpis.  Pellentesque cursus luctus mauris.  Nulla
malesuada porttitor diam.  Donec felis erat, congue non, volutpat at,
tincidunt tristique, libero.  Vivamus viverra fermentum felis.  Donec
nonummy pellentesque ante.  Phasellus adipiscing semper elit.  Proin
fermentum massa ac quam.  Sed diam turpis, molestie vitae, placerat a,
molestie nec, leo.  Maecenas lacinia.  Nam ipsum ligula, eleifend at,
accumsan nec, suscipit a, ipsum.  Morbi blandit ligula feugiat magna.  Nunc
eleifend consequat lorem.  Sed lacinia nulla vitae enim.  Pellentesque
tincidunt purus vel magna.  Integer non enim.  Praesent euismod nunc eu
purus.  Donec bibendum quam in tellus.  Nullam cursus pulvinar lectus.
Donec et mi.  Nam vulputate metus eu enim.  Vestibulum pellentesque felis
eu massa.  Quisque ullamcorper placerat ipsum.  Cras nibh.  Morbi vel justo
vitae lacus tincidunt ultrices.  Lorem ipsum dolor sit amet, consectetuer
adipiscing elit.  In hac habitasse platea dictumst.  Integer tempus
convallis augue.  Etiam facilisis.  Nunc elementum fermentum wisi.  Ciao!

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.