3

I would like to create a custom page size like that :

  • A fixed width size (exemple 8inch)
  • An adaptable height size

Something like with the standalone package. If the page contains one line, then the pdf will be 8inch per something little that correspond to one line. But if the page contains 20 lines I would like do adapt the same way.

Any idea how I could do that ?

EDIT : I forgot to say that I have 4 pages on my pdf file, and I would like to have different size for every page. I'm not sure if it's possible..

Here is my current code (I use standalone to adapt the size of each page but that doesn't correspond to what I want)

\documentclass[border=1pt, class=scrreprt]{standalone}
\KOMAoptions{fontsize=15pt}
\DeclareFontShape{OMX}{cmex}{m}{n}{%
   <-> cmex10%
   }{}
\pagestyle{empty}

\standaloneenv{page}

\begin{document}
\nopagecolor

\begin{page}
\nopagecolor
Question : test n°1
\end{page}

\begin{page}
\nopagecolor
Anwser n°1 : $x$
\end{page}

\begin{page}
\nopagecolor
Anwser n°2 : 
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sodales ante a libero lacinia mattis in sed ex. Sed efficitur non erat in consequat. Praesent gravida sem quis egestas pretium. Phasellus non magna luctus, elementum nibh eget, fermentum nisl. Nam imperdiet ipsum nisi, id sagittis ligula vestibulum eget. Nullam finibus elit sed tempor ultricies. Pellentesque pharetra purus ut fermentum varius. Aliquam vitae sapien vel nisl fermentum pulvinar tempus vitae nunc. Praesent eu tincidunt sem, at fermentum diam. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras ligula justo, dignissim a sollicitudin viverra, scelerisque nec sapien. Nulla facilisi.

Morbi venenatis, erat non cursus pretium, enim ante bibendum turpis, in fermentum velit mi maximus enim. Duis dictum ligula vitae scelerisque ullamcorper. Nullam a tristique nisi. In in mi eu libero pellentesque efficitur. Sed dictum tristique dolor. Cras eget lectus vel odio egestas bibendum sed eu lorem. Praesent pharetra fringilla enim quis convallis. Donec maximus lobortis ex sit amet vehicula. Sed vulputate commodo sem, maximus pretium tortor mattis quis. Sed venenatis, eros ac vestibulum cursus, arcu ipsum venenatis sem, a interdum ante justo eu erat.

Proin quis gravida mauris, sit amet mattis ex. Proin id ex non enim egestas maximus consectetur vitae eros. Vestibulum vel metus auctor, porta libero ac, hendrerit lorem. Duis auctor dui in felis ullamcorper lacinia. Pellentesque rutrum diam at lectus viverra placerat. Ut vitae pretium velit. Praesent rhoncus tellus sit amet erat varius, ut cursus magna tincidunt. Morbi vitae faucibus purus. Aliquam iaculis eget neque quis gravida. Suspendisse pulvinar, turpis et viverra accumsan, leo dui finibus velit, in sollicitudin magna nisi ut nisl.
\end{page}

\begin{page}
\nopagecolor
Anwser n°3 : 
$x^2$
\end{page}
\end{document}
  • Welcome to TeX.SX! Please show us your basic setup as an MWE. – TeXnician Aug 22 '17 at 10:58
  • Thank you @TeXnician, I added a sample of code with a random text. – Yohann Lereclus Aug 22 '17 at 11:11
3

Maybe this? The vertical height will match the content, plus the given border. I have EDITED to introduce the environment fixedpagewidth, to create a single page of the provided page width, while accounting for the class border specifications.

\documentclass[border=.1in]{standalone}% DEFINE BORDER AS OPTION
\edef\svparindent{\the\parindent}
\standaloneenv{page}
\makeatletter\newenvironment{fixedpagewidth}[1]
  {\begin{page}\begin{minipage}{\dimexpr#1-\sa@border@left-\sa@border@right\relax}%
    \parindent\svparindent\relax}
  {\end{minipage}\end{page}}
\makeatother
% YOU CAN ADD PACKAGES HERE
\usepackage{lipsum}
% END OF YOUR PACKAGES
\begin{document}
\begin{fixedpagewidth}{8in}
\lipsum[1-2]
\end{fixedpagewidth}
\begin{fixedpagewidth}{4in}
\lipsum[3]
\end{fixedpagewidth}
\begin{fixedpagewidth}{2in}
\lipsum[4]
\end{fixedpagewidth}
\end{document}

enter image description here

  • Great that's working ! Even with multiple pages (with some modification). Thanks a lot – Yohann Lereclus Aug 22 '17 at 11:34
  • @YohannLereclus I have edited to incorporate your use of multiple pages. – Steven B. Segletes Aug 22 '17 at 11:36
  • @YohannLereclus Please see my edit, which makes it even easier with an environment. – Steven B. Segletes Aug 22 '17 at 11:43
  • Yes thank you ! That's better than what I did because every page size is customizable. – Yohann Lereclus Aug 22 '17 at 12:17

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.