3

I'm trying to use the \leftbar feature, but I would like the document to support two different bar colors. This issue gets the color set, but only a single global color. I would like some \leftbar to be red, others to be blue. Right now I am doing this:

 % https://tex.stackexchange.com/questions/22526/regarding-the-leftbar-environment
\renewenvironment{leftbar}[1][\hsize]
{
    \def\FrameCommand
    {
        {\color{blue}\vrule width 3pt}
        \hspace{0pt}
    }
    \MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}
}
{\endMakeFramed}

I want something like:

\leftbar{color{red}}

Any thoughts would be appreciated!

[EDIT - ADDED FINAL CODE]

\renewenvironment{leftbar}[2][\hsize]
{
    \def\FrameCommand
    {
        {\color{#2}\vrule width 3pt}
        \hspace{0pt}
    }
    \MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}
}
{\endMakeFramed}

Then to use:

\begin{leftbar}{blue}
\end{leftbar}

1 Answer 1

4

Change

 \renewenvironment{leftbar}[1]

to

\renewenvironment{leftbar}[2]

then replace blue by #2 and you can use

\begin{leftbar}{red}
1
  • Fantastic. And I learned something about how to use the files better too. Thanks!
    – DiB
    Jan 19, 2016 at 20:49

You must log in to answer this question.

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