1

I am using blindtext package to draw out how the layout of the document will look like and then swapping the "dummy" parts with real text. Problem is that I would like to give some style to these text blocks to visually differentiate them from already written text.

I used simply:

\let\oldbt\blindtext
\renewcommand{\blindtext}[1]{\textcolor{gray}{\oldbt{}}}

which worked fine until I wanted to add some arguments or use \Blindtext, which internally calls \blindtext with arguments.

I found several possibilities to handle optional arguments using \xparse or \NewDocumentCommand, but none of them was enough descriptive. And I still have some blind believe it must be possible to do using standard \renewcommand. I also believe that this will be useful for more people so I am asking new question.

What is the correct way of styling blindtext, for example adding gray color?

1
  • 1
    The color is not grouped, it will also color your usual text. – Johannes_B Mar 20 '16 at 10:10
3

You have to be careful in redefining commands with an optional argument; instead of \let one should use \LetLtxMacro (see When to use \LetLtxMacro?).

\documentclass{article}
\usepackage{blindtext,letltxmacro,xcolor,xparse}
\usepackage{lipsum}% for simulating real text

\LetLtxMacro{\blindtextblindtext}{\blindtext}
\LetLtxMacro{\blindtextBlindtext}{\Blindtext}

\RenewDocumentCommand{\blindtext}{O{\value{blindtext}}}{%
  \begingroup\color{gray}\blindtextblindtext[#1]\endgroup
}
\RenewDocumentCommand{\Blindtext}{O{\value{blindtext}}O{\value{Blindtext}}}{%
  \begingroup\color{gray}\blindtextBlindtext[#1][#2]\endgroup
}

\begin{document}

\lipsum[1]

\blindtext[3]

\lipsum[3]

\Blindtext[2][3]

\lipsum[4]

\end{document}
1
  • Thanks! It worked fine. I spend too much time searching in the problem in the \renewcommand, and didn't realize there might be problem with the \let part. – Jakuje Mar 20 '16 at 10:26

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.