# Make only one page for each chapter

Is it possible to generate only one page per chapter(or section) without splitting the document file?

The page width is fixed but the page height should be automatically adjusted by the content length of each chapter(or section), so each page height may differ depending on each chapter.

For instance, the PDF result woud look like:

Note that there should be no page break in each chapter.

My document class is memoir and I'm using pdflatex but, if I have to change class or compiler to accomplish this, I will.

Thank you.

• Your question is unclear – user31729 May 11 '15 at 14:38
• @ChristianHupfer Thank you for comment. I want each page broken at end of each chapter only and never broken in the middle of chapter. What information do you want to know more? – xylosper May 11 '15 at 14:41
• tex.stackexchange.com/questions/6834/… is related. – pst May 11 '15 at 14:47
• @pst Thank you. In order to use the method in your link, do I have to adjust page size for each chapter whenever the content changed? Or, can I calculate the chapter content height within LaTeX? – xylosper May 11 '15 at 14:59
• So, what you want is more or less the idea of a web page, that is, only ends when the text ends. – Sigur May 11 '15 at 15:02

Since standalone class doesn't define things like chapters, you will have to do your own formatting.

\documentclass[border=.25in,multi={minipage}]{standalone}
\usepackage{lipsum}

\setlength{\textwidth}{5in}% constant width document
\newcounter{chapter}
\newcommand{\chapter}[1]{% Chapter title
\refstepcounter{chapter}%
\centerline{\large\textbf{Chapter \thechapter}}%
\smallskip\par
\parbox{\textwidth}{\centering\Large #1}%
\medskip\par}

\begin{document}
\begin{minipage}{\textwidth}
\chapter{First}
\lipsum[1-2]
\end{minipage}
\begin{minipage}{\textwidth}
\chapter{Second}
\lipsum[3-7]
\end{minipage}
\end{document}

• standalone with multi option worked for me. Thank you! – xylosper May 12 '15 at 3:12