Switchable inline comments for LaTeX/LyX document.

For communication with my co-authors, I sometimes use inline comments, i.e., additional highlighted paragraphs withing the text of my PDF documents; exported from LyX/LaTeX. I know, I could also use PDF comments, but I like the inline style better. Here is how it looks like:


To create these comments, I use a redefinition of LyX's greyedout notes, turning them into an \fcolorbox (see code below). For exporting a printable/camera-ready PDF, I need to turn of the comments.  It took me some time to figure out how to tell LaTeX to completely ignore the comment's body text. I use the environ package for that. Here is the complete code (LaTeX preamble):

\usepackage{verbatim}
\usepackage{environ}
\usepackage{color}

% remove old lyxgreyedout notes
\let\lyxgreyedout\relax
\let\endlyxgreyedout\relax

% redefine lyxgreyedout notes
\NewEnviron{lyxgreyedout}{%
  \noindent %
  \fcolorbox{yellow}{yellow}{
    \begin{minipage}[t]{0.95\columnwidth}%
    \textcolor{blue}{\footnotesize{\BODY}}
  \end{minipage}
}}%

% remove notes for printing: rename the above env and the next env
\NewEnviron{lyxgreyedout2}{%
  %this will ignore all the body content in my greyedouts
  %\BODY
}
And here is the rest of my LaTeX preamble; just for reference:
% I sometimes need a little more space
\newcommand{\vs}{ \textbf{\vspace{2pt}}}

% small fancy links; clickable but still readable (without the http protocol string)
\newcommand{\lnk}[1]{{\small{(\href{http://#1}{#1})}}}

% setting pretolerance to 4500 will remove most overflowing lines, esp.
% for two-column documents. In the final version of a paper, I lower this setting
% and handtune the overflows using hyphenation hints
\pretolerance = 4500

% more penalties for misplaced paragraphs,
% (usually not required for academic paper templates)
%\clubpenalty = 10000
%\widowpenalty = 10000
%\displaywidowpenalty = 10000
Ciao,
Juve

Comments