0

I prepare a book of short stories. There are no too long texts, each story takes no more than two pages. The customer asks to layout two-paged stories in such a way that they would be placed starting from an even page.

Now I've written a command that layouts a box of the title of a story and a box of full text of the story. The if their total height is greater than the height of the page, the current page number is checked and a page is skipped if necessary. Afterwards, the material is put: for the title its box is used, but the text is made up again.

In this scheme, the text is made up twice: at first, when I compute the height it takes, and at second, when it actually prepared for layout. Is it possible to optimize the process somehow?

  • Welcome to TeX.SX! – Bobyandbob Dec 17 '17 at 19:39
  • Showing your code in a minimal working example (MWE) would certainly help optimizing it. – Skillmon Dec 17 '17 at 19:42
  • So where should a story start that is not longer than one page? Doesn't matter or always on next page or also on even pages? – Skillmon Dec 17 '17 at 23:26
1

You can check the value of the page number, and add blank pages as needed.

enter image description here

\documentclass{article}

\usepackage{lipsum}

\newcommand{\storytitle}[1]{%
  \clearpage% Move to next page
  \ifodd\value{page} \mbox{}\clearpage\fi% If page is odd, move to next page
  \section*{#1}% Set story title/heading
}

\begin{document}

\storytitle{First story}
\lipsum[1-7]

\storytitle{Second story}
\lipsum[8-10]

\storytitle{Third story}
\lipsum[11-16]

\storytitle{Last story}
\lipsum[17-24]

\end{document}
  • Would it not be better to use either \clearpage or \cleardoublepage in the if? – Oleg Lobachev Dec 17 '17 at 20:13
  • @OlegLobachev: If you're using the twoside option, then the pages will be cleared to an odd page. So you'll have to do some work correcting for that either way. – Werner Dec 17 '17 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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