3

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:

enter image description here

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.

slyx
  • 343
  • Your question is unclear –  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? – slyx May 11 '15 at 14:41
  • http://tex.stackexchange.com/questions/6834/change-paper-size-in-mid-document 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? – slyx 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
  • Or ebook functionality? – Johannes_B May 11 '15 at 15:04
  • Sorry, I have no complete answer. – pst May 11 '15 at 15:06
  • Yes, the result would look like one webpage per each chapter. – slyx May 11 '15 at 15:07
  • There was a similar question not that long ago under the 'featured' tab. Does anybody remember enough to search for it? – cfr May 11 '15 at 15:32
  • An example document would be useful. What is the possible range of sizes, for example? I suppose you know already that TeX is not the best tool to accomplish this: it isn't what it is really designed to be good at. – cfr May 11 '15 at 15:34
  • @cfr How an example is helpful? It would be just a 'hello world', if I make an example. For my real document, one chapter has 5-10 pages in b5 paper size. – slyx May 11 '15 at 16:40
  • It makes it easier for people to try out solutions. Otherwise, they have to create an example first. – cfr May 11 '15 at 17:35
  • @cfr - Do you mean http://tex.stackexchange.com/questions/198712/infinite-canvas ? – John Kormylo May 11 '15 at 20:55
  • @JohnKormylo I don't think so. It had something to do with automatically getting pages of different dimensions according to the content to be typeset. Or maybe the last page was meant to be sized to just fit the contents or something like that. – cfr May 11 '15 at 22:01

1 Answers1

3

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}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120