Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

FAQ /

ShadedBox

Categories: Tag me
<< | Page list | >>

> I've got an ERT for defining a shaded box with a line around it. I'm
> trying to make my own environment for it, but I'm just not getting the
> Preamble right.

Well, after spending a few hours reading 'The Not So Short Guide to LaTex' and 'A Simplified Introduction to LaTeX' and pulling some of Herbert Voss' pages out of Google's catch (a few transatlantic links have been spotty, so I can't get there directly) I've got this, which works quite nicely:

 
\usepackage{color,calc}
\definecolor{shade}{gray}{0.8}
\newenvironment{myshadedbox}[1][]%
        {
        %\setlength{\fboxsep}{-\fboxrule}
        \footnotesize\normalfont\ttfamily\raggedright
        \setlength{\rightmargin}{\leftmargin}
        \setlength{\itemsep}{-12pt}
        \setlength{\parsep}{20pt}
        \begin{lrbox}{\@tempboxa}%
        \begin{minipage}{\linewidth-2\fboxsep}
        }%
        {
        \end{minipage}%
        \end{lrbox}%
        \fcolorbox{black}{shade}{\usebox{\@tempboxa}}\newline\newline
        }%
  

Just figured I'd post it in case anyone else was curious how to do it. (From: Peter Harkins)

If you want to redefine the 'Box (Minipage, shaded background)' you can the same construct only slightly adjusted:

 
\usepackage{calc}
\renewenvironment{shaded}[1][]%
        {
        %\setlength{\fboxsep}{-\fboxrule}
        \footnotesize\normalfont\ttfamily\raggedright
        \setlength{\rightmargin}{\leftmargin}
        \setlength{\itemsep}{-12pt}
        \setlength{\parsep}{20pt}
        \begin{lrbox}{\@tempboxa}%
        \begin{minipage}{\linewidth-2\fboxsep}
        }%
        {
        \end{minipage}%
        \end{lrbox}%
        \fcolorbox{black}{shadecolor}{\usebox{\@tempboxa}}\newline\newline
        }%
  

You can set the shaded colour in Document > Settings > Colors. If you put this construct in the Preamble then the 'Box (Minipage, shaded background)' will automatically become 'Box (Minipage, shaded background, simple frame)', although LyX will not display the box label as such.


Tag me

<< | FAQ.PageList | >>

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2013-06-04 15:54 UTC