4

Question

I want to create a page whose size is cropped to the size of the content on the page. I also want to be able to have indented paragraphs and to set the color of text and background. Is there a way to do this?

First Attempt

My first attempt was to do this with the standalone package. Here is example code:

\documentclass[varwidth]{standalone}

\usepackage[usenames,dvipsnames]{xcolor}
\pagecolor{Apricot}
\color{Sepia}

\begin{document}
This is my first paragraph. 
It is long enough to go on to the second line because I added a bunch of words to it.

This is my second paragraph. 
Notice the lack of indentation.
\end{document}

This is the output it gives me:

Notice that the colors are as I intended, but there is no indentation.

Second Attempt

Researching this issue, I found this question, but when I tried to implement their solution as follows:

\documentclass[preview]{standalone}

\usepackage[usenames,dvipsnames]{xcolor}
\pagecolor{Apricot}
\color{Sepia}

\usepackage{etoolbox}
\edef\keptparindent{\the\parindent}
\patchcmd{\preview}
  {\ignorespaces} %%% \preview ends with \ignorespaces
  {\parindent\keptparindent\ignorespaces}
  {}{}

\begin{document}
This is my first paragraph. 
It is long enough to go on to the second line because I added a bunch of words to it.

This is my second paragraph. 
Notice the colors are not right.
\end{document}

I get the following output:

as you can see the colors are not right.

1

1 Answer 1

4

The contents is put into the environment varwidth that uses minipage. Inside a minipage the paragraph indent is zero (\@parboxrestore/\@arrayparboxrestore). Workaround:

\documentclass[varwidth]{standalone}

\usepackage[usenames,dvipsnames]{xcolor}
\pagecolor{Apricot}
\color{Sepia}

\newlength\keptparindent
\keptparindent=\parindent

\begin{document}
\parindent=\keptparindent
This is my first paragraph.
It is long enough to go on to the second line because I added a bunch of
words to it.

This is my second paragraph.
Notice the lack of indentation.
\end{document}

Result

1
  • Yes, that is what I wanted. That seems to work when the preview options is used as well, as in my second attempt. This seems to me to be more elegant than using patchcmd as was suggested in the question that I linked to. Thanks! Commented May 19, 2013 at 15:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .