Hi,

I would love to present (and save for future) a solution to the problem I had with Comment environment. I wished to be able to make my comments visible with special fonts and with the background of the comment shaded (so certainly outstanding from other text), but in the same time I would love to make them invisible (for publishing document on the Internet, turning it in to my professor, etc.). This is what I did.

First of all I have to say, that I use my own class of documents, with this layout file:

  #% Do not delete the line below; configure depends on this
  #  \DeclareLaTeXClass[article]{article (like from groff)}
  # $Id: grofflike.layout,v 1.2 2003/09/02 10:35:11 matej Exp matej $

  # General textclass parameters
  Input article.layout
  Input myarticle.inc

  ClassOptions
     Other "11pt"
  End

The result is exactly the same as the normal article but for including of myarticle.inc and setting size of font to 11pt (do not believe the name of the class -- it is certainly far from being the same as groff).

myarticle.inc includes some small personal settings (redefinition of footnote, etc.) and then it includes couple of redefinitions of the standard environments (because it is not possible to have multiple Preamble in a series of .layout files--see thread ``Repeated Preamble in .layout are not read'' in the archive of this group--I prefer to have all parts which should go to the preamble in Preamble part of new Styles). So for example, I have also this redefinition of Comment style:

  Style Comment
     CopyStyle                   Comment
     Preamble
     \usepackage{ifthen} \usepackage{color}
     \definecolor{lightgray}{gray}{0.9}
     \newboolean{commentvisible} \setboolean{commentvisible}{false}
     [EMAIL PROTECTED] [EMAIL PROTECTED]
     %
     \renewenvironment{comment}%
        [EMAIL PROTECTED]
        {\end{lrbox}%
         \ifthenelse{\boolean{commentvisible}}{%
            \begin{quote}%
              \colorbox{lightgray}{%
                 [EMAIL PROTECTED]
                 [EMAIL PROTECTED]
                 [EMAIL PROTECTED]
                 [EMAIL PROTECTED]
                    [EMAIL PROTECTED]
                       \begin{sffamily}
                       \textbf{\scshape Side note:}
                       [EMAIL PROTECTED]
                       \end{sffamily}
                    }%
              }%
            \end{quote}%
         }{}
        }
     EndPreamble
  End

All business of this Style is to redefine the comment environment so that it not only works the same as the original one--by saving the content of the environment into savebox which is never used effectively eliminate the content of the environment from the document. When the Boolean variable commentvisible is set to true, then actually this savebox is used and put into the environment quote and colorbox with shaded background. Complication with this construction is to find out the allowed width of the innermost parbox. The problem is that colorbox narrows the space for its contents by width of \fboxrule and by space between boxes \fboxsep (twice for both sides of the box).

Another quirk of this construct is use of TeX primitive \unhbox, which does not include box, but its content--horizontal list of the material to be printed.

Herbert, do you think that this could go to your tips (How-To create shaded environment and recreation of LyXs Style)? Thanks.

Have a nice day all and happy LyXing!

Matej

--
Matej Cepl, http://www.ceplovi.cz/matej
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC
138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488

They never open their mouths without subtracting from the sum of
human knowledge.
     -- Thomas Brackett Reed



Reply via email to