8

If we use the book class, the output looks like the following screenshot.

enter image description here

But if we use the article class, the output looks better as follows.

enter image description here

The MWE is given as follows. Note: please enable -shell-escape!

\documentclass[12pt]{article}% please change to article and compare the output.

\usepackage{filecontents}
\begin{filecontents*}{"article sample.tex"}
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1-20]
\end{document}
\end{filecontents*}

\usepackage{showexpl}

\lstset
{
    breaklines=true,
    breakindent=0pt,
    tabsize=2,
    columns=flexible,
    language={[LaTeX]TeX},
    basicstyle=\small\ttfamily\hbox{},
}

\newcount\x

\newcommand\MyLTXinputExample[2][2mm]{%
% #1: length of gap,
% #2: filename with .tex, 
    \lstinputlisting[caption=\url{#2.tex}]{"#2.tex"}
    \bgroup
        \parskip=#1\relax
        \fboxsep=0pt
        \pdfximage{#2.pdf}%
        \x=0
        \loop
            \ifnum\x<\pdflastximagepages
                \advance\x by 1
                \noindent\hfill
                \fbox{\includegraphics[width=0.5\dimexpr\linewidth-4\fboxrule-#1\relax,page=\x]{"#2"}}%                     
            \ifnum\x<\pdflastximagepages
                \advance\x by 1
                \hfill
                \fbox{\includegraphics[width=0.5\dimexpr\linewidth-4\fboxrule-#1\relax,page=\x]{"#2"}}%
            \fi
                \hfill\null\par
        \repeat
    \egroup
}

\PassOptionsToPackage{obeyspaces}{url}
\usepackage{hyperref}

\begin{document}
\immediate\write18{pdflatex "article sample"}
\MyLTXinputExample{article sample}
\end{document}

How to prevent book class from vertically justifying the contents? In other words, I want to use the book class but its output (only the justification is under consideration) must look like the output that article class produces.

0

1 Answer 1

20

Put a \raggedbottom into your preamble.

1
  • Today I have learnt a new thing, \raggedbottom. Thank you! Feb 15, 2013 at 10:41

Not the answer you're looking for? Browse other questions tagged .