0

I want to use the outlines package, and wish to color lines of a certain level with a certain color. Here is my current document:

\documentclass[12pt,letterpaper]{article}

\usepackage{outlines}
\usepackage{enumitem}

\setenumerate[1]{label=\color{red}\Roman*.}
\setenumerate[2]{label=\color{blue}\Alph*.}
\setenumerate[3]{label=\arabic*.}
\setenumerate[4]{label=\alph*.}

\begin{document}

        \begin{outline}[enumerate]
            \1 Heading type 1
                \2 Heading type 2
                    \3 Outline type 1
                        \4 Outline type 2
        \end{outline}


\end{document}

And here is the output:

enter image description here

I would like to color the text "Heading type 1" red, and color "Heading type 2" blue, to match their prefixes. Is there any way to do this without having to use the \color tag on each heading? After all, I am using LaTeX to simplify the process of writing an outline, and a \color tag would make things unnecessarily complicated.

Thank you!

  • Welcome! Please check your code compiles before uploading it unless the fact that it doesn't compile is the problem you want help with! – cfr Aug 23 '15 at 0:40
  • @cfr Thanks, but the code compiles fine. I'm using TeXStudio, so the PDF preview pane lets me know if I have any syntax errors immediately. – Dave Cruz Aug 23 '15 at 1:30
  • Are you really saying that it compiles for you without adding xcolor or color to the loaded packages? If so, either there is something very wrong with your TeX installation or with mine! – cfr Aug 23 '15 at 1:33
1

You could do something like this. However, note that LaTeX has no way to know when the heading ends. So if there is text apart from the heading, you will need to set the colour switch manually for that case. This is because you are not marking the headings up as headings i.e. it is non-semantic mark-up.

\documentclass[12pt,letterpaper]{article}
\usepackage{outlines,enumitem,xcolor}
\colorlet{mycolour}{black}
\setlist[enumerate]{font=\color{mycolour}, after={\color{black}}}
\setlist[enumerate,1]{label=\Roman*., before={\colorlet{mycolour}{red}\color{mycolour}}}
\setlist[enumerate,2]{label=\Alph*., before={\colorlet{mycolour}{blue}\color{mycolour}}}
\setlist[enumerate,3]{label=\arabic*., before={\colorlet{mycolour}{black}\color{mycolour}}}
\setlist[enumerate,4]{label=\alph*.}
\begin{document}

\begin{outline}[enumerate]
  \1 Heading type 1
  \2 Heading type 2
  \3 Outline type 1
  \4 Outline type 2
\end{outline}

something here

\end{document}

coloured text in enumeration

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.