0

If I have a commercial book of 10 chapters. Is it possible to generate free preview/sample material of different chapters: lets say the sample material will include (/frontmatter + chapter1, chapter3, chapter10 + /backmatter). I am using memoir.

Requirements: 1. Maintain page numbering 2. Keep the TOC intact

The only way I found is to do it manually as follows: 1. Compile full version 2. Extract TOC and the desired chapters using [pdftk in.pdf cat out.pdf] 3. concatenate the different pdf files.

However, is there away to do this directly in latex, xetex, etc.?

I provided sample material as my MWE if anyone have a solution.

\documentclass{memoir}
\usepackage{lipsum}
\begin{document}
\frontmatter
{\mbox{}\vfill  \HUGE \bfseries A Very Interesting Book \vfill \mbox{}}
\newpage
\chapter{Preface}
\lipsum
\newpage
\tableofcontents

\mainmatter
\chapter{One}
This is a sample preview chapter.
\chapter{Two}
\lipsum
\chapter{Three}
This is a sample preview chapter.
\chapter{Four}
\lipsum
\chapter{Five}
\lipsum
\chapter{Six}
\lipsum
\chapter{Seven}
\lipsum
\chapter{Eight}
\lipsum
\chapter{Nine}
\lipsum
\chapter{Ten}
 This is a sample preview chapter.
\end{document}
3

you can help yourself with use includeonly macro:

\includeonly{
%    One,
%    Two,
    Three,  % tha case when you like to compile only this chapter
%    Four,
%    Five,
%    Six,
%    Seven,
%    Eight,
%    Nine,
%    Ten
            }
%---------------------------------------------------------------%
    \documentclass{memoir}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \begin{document}
%---------------------------------------------------------------%
    \frontmatter
\tableofcontents                                 
%---------------------------------------------------------------%
    \mainmatter
    \include{One}
    \include{Two}
    \include{Three}
    \include{Four}
    \include{Five}
    \include{Six}
    \include{Seven}
    \include{Eight}
    \include{Nine}
    \include{Ten}
%---------------------------------------------------------------%
    \backmatter
\include{bibliogrphy}     % literatura
%---------------------------------------------------------------%
\end{document}
  • This will maintain page numbering? – Sari Mar 30 '18 at 11:35
  • 1
    this will maintain all, tableofcontents, page numbering, chapter, section ... figures, tables equation numbering :-). just make short test with your real document. – Zarko Mar 30 '18 at 11:40

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.