Custom text style for outlines (enumerate) levels

1,499

Solution 1

Do you want something like this?

Cats, dots and goldfish

\documentclass[]{article}
\usepackage[T1]{fontenc}
\usepackage{outlines}
\makeatletter
\newenvironment{myoutline}[1][]{%
  \ifthenelse{\equal{#1}{}}{}{\renewcommand{\[email protected]}{#1}}%
  \[email protected]%
  \newcommand{\0}{\[email protected]\[email protected]}%
  \newcommand{\1}{\[email protected]\scshape\bfseries\LARGE\[email protected]\item}%
  \newcommand{\2}{\[email protected]\normalfont\normalsize\bfseries\[email protected]\item}%
  \newcommand{\3}{\[email protected]\normalfont\normalsize\[email protected]\item}%
  \newcommand{\4}{\[email protected]\normalfont\normalsize\[email protected]\item}%
}{%
  \[email protected]\[email protected]%
}
\makeatother

\begin{document}

\begin{myoutline}[enumerate]
  \1 Cat
      \2 Tiny cat
      \2 Medium cat
  \1 Dog
      \2 Big dog
          \3 Types of big dogs
      \2 Another large dog
      \2 A similarly sized dog
      \2 An enormous goldfish belongs here, too
\end{myoutline}

\end{document}

Solution 2

You can redefine the commands for each of the levels:

enter image description here

Code:

\documentclass[11pt,a4paper]{article}        
\usepackage{outlines}

\begin{document}

\begin{outline}[enumerate]
\let\OldOne\1%
\let\OldTwo\2%
\let\OldThree\3%
\renewcommand*{\1}{\normalsize\normalfont\OldOne\bfseries\Large\scshape}%
\renewcommand*{\2}{\normalsize\normalfont\OldTwo\bfseries}%
\renewcommand*{\3}{\normalsize\normalfont\OldThree\small}%
\1 Cat
    \2 Tiny cat
    \2 Medium cat
        \3 Types of big cats
        \3 Types of bigger cats
\1 Dog
    \2 Big dog
        \3 Types of big dogs
        \3 Types of bigger dogs
\end{outline}

\end{document}
Share:
1,499

Related videos on Youtube

synaptik
Author by

synaptik

Updated on April 13, 2020

Comments

  • synaptik
    synaptik over 2 years

    I'm using the outlines package, and I'm curious to know how to modify the font properties of the text at different levels. For example, how can I make text beside \1 bold and small-caps and slightly larger than the normal size? And how can I make text beside \2 bold?

    That is, I want to change this:

    \begin{outline}[enumerate]
    \1 Cat
        \2 Tiny cat
        \2 Medium cat
    \1 Dog
        \2 Big dog
            \3 Types of big dogs
    \end{outline}
    

    to this:

    \begin{outline}[enumerate]
    \1 \textsc{\textbf{ \LARGE Cat}}
        \2 \textbf{Tiny cat}
        \2 \textbf{Medium cat}
    \1 \textsc{\textbf{ \LARGE Dog}}
        \2 \textbf{Big dog}
            \3 Types of big dogs
    \end{outline}
    

    But without having to specify the font options for every item.

    Here's a working example:

    \documentclass[11pt,a4paper]{article}        
    \usepackage{outlines}
    
    \begin{document}
    
    \begin{outline}[enumerate]
    \1 Cat
        \2 Tiny cat
        \2 Medium cat
    \1 Dog
        \2 Big dog
            \3 Types of big dogs
    \end{outline}
    
    \begin{outline}[enumerate]
    \1 \textsc{\textbf{ \LARGE Cat}}
        \2 \textbf{Tiny cat}
        \2 \textbf{Medium cat}
    \1 \textsc{\textbf{ \LARGE Dog}}
        \2 \textbf{Big dog}
            \3 Types of big dogs
    \end{outline}
    
    \end{document}
    
    • cfr
      cfr over 8 years
      Please complete your code so that it constitutes a Minimal Working Example i.e. a complete small document. Complete code is much more useful than mere fragments.
    • cfr
      cfr over 8 years
      Thanks for adding your MWE. Please see if my answer approximates the kind of thing you are looking for. Note that I added fontenc since the small-caps failed to materialise without switching to T1.
  • synaptik
    synaptik over 8 years
    Why did you add this line? \usepackage[T1]{fontenc}
  • cfr
    cfr over 8 years
    @synaptik My \scshape seemed to have no effect otherwise. Besides, T1 is far superior to OT1 so it should be there anyway ;).
  • synaptik
    synaptik over 8 years
    This solution doesn't work for the very first level, the first 1. The numeral size is smaller than the other \1 levels. Why is that?
  • synaptik
    synaptik over 8 years
    @crf your solution doesn't work for me for the non-first \2 entries. Only the first \2 entry is modified.
  • cfr
    cfr over 8 years
    @synaptik Not sure what to say without seeing the error or whatever. I get the output I posted ;) i.e. it works for all the \2s.
  • synaptik
    synaptik over 8 years
    @crf See what I just added to my original question.... the "blah blah" text
  • synaptik
    synaptik over 8 years
    So, it looks like if you put a \1 then a \2 then a \3, then if you next put a \2, this next \2 doesn't work.
  • cfr
    cfr over 8 years
    @synaptik See my update. Does this help?
  • synaptik
    synaptik over 8 years
    Yes! :) Thank you very much. What, in a nutshell, did you fix?
  • cfr
    cfr over 8 years
    @synaptik I think the numeral is typeset before the font switch with this method. To get consistent numbering you need to add \normalsize to \normalfont but the labels will not match the size or weight of the following text in that case.
  • cfr
    cfr over 8 years
    @synaptik In my first solution, I had this fixed for level 1 because the font switches came after \[email protected]. But in the other cases, I put the font switches after. I think they need to be first for all the levels. Otherwise, the label is typeset in whatever font is active before you type \item and the switch only affects the following text. Does that make sense?
  • synaptik
    synaptik over 8 years
    Yes, it does. I need to learn more about the tex macro language :)
  • cfr
    cfr over 8 years
    @synaptik This is pure LaTeX... nothing low level.
  • synaptik
    synaptik over 8 years
    @crf In that case, I need to learn more about LaTeX :O)
  • cfr
    cfr over 8 years
    @synaptik Also, it doesn't work for the first item of the third level. This is more obvious if you add a second \3.
  • Peter Grill
    Peter Grill over 8 years
    @synaptik: I am not sure exactly what is not working. Can you try the new updated code and let me know.
  • cfr
    cfr over 8 years
    Do you really get small-caps? Incidentally, although @synaptik unaccepted my answer to accept yours, I think synaptik has most probably decided to use my updated code. (Judging by the comments.) ;) But I think your answer better reflects the example in the question...
  • Peter Grill
    Peter Grill over 8 years
    @cfr: Yep, I get the output as posted. I see that he has toggled from accepting mine to yours and then back to mine.
  • cfr
    cfr over 8 years
    Do you have any idea why I can only get small-caps if I switch to T1? This is why I used fontenc in my answer - without it, \scshape had no effect. Exactly the same with your code. It seems that my system substitutes bx in a different shape rather than b in the same shape when OT1 is active...
  • Peter Grill
    Peter Grill over 8 years
    @cfr: I also don't get small caps with your solution if I remove the T1 encoding. I don't know much about fonts but I suspect that since I am not redefining the entire macro (but just adding to it) that perhaps you missed something. Also, you are not using the outline environment as I am. That might make a good question, as I can't seem to get your example to work without T1. Perhaps there is an underlying problem lurking in my solution related to small caps -- Don't know.
  • cfr
    cfr over 8 years
    Maybe but I don't get small caps with your code either. That is, if I cut, paste and compile your code just as it is, it compiles but it substitutes upright for small caps.
  • Peter Grill
    Peter Grill over 8 years
    @cfr: Hmmmm... Seems that there is some problem with one of our distributions. I am using TeXLive2013 but haven't updated packages in a while.
  • cfr
    cfr over 8 years
    I have TL 2013 entirely up to date. If you look in the output, are there any font substitutions? It is hard to tell from the image but it looks as though you are actually getting medium series small-caps rather than bold whereas I am getting bold upright rather than small-caps. In the base font definition file ot1cmr.fd, no bold sc is defined. That means the substitution depends on whatever fallback substitutions LaTeX defines.
  • cfr
    cfr over 8 years
    Incidentally, it makes sense that you might get different results with my code. In mine, I switch shape and then series whereas you switch series and then shape. If things are set up properly, this shouldn't matter. But if something peculiar is going on, it might. If you switch the switches, does that make a difference?
  • Peter Grill
    Peter Grill over 8 years
    @cfr: I do have this warning that I did not notice before: Font shape OT1/cmr/bx/sc' undefined using OT1/cmr/bx/n' instead on input line 13.. BTW, don't see any difference in switching the order.
  • cfr
    cfr over 8 years
    Something very odd is going on. You said you don't know much about fonts so excuse me if I'm stating the obvious but that warning is telling you that LaTeX cannot find bold small-caps and is substituting bold upright instead. That's the warning I get. But my output reflects that warning whereas yours does not.
  • cfr
    cfr over 8 years
    The order was just a guess. Obviously not a good one ;).
  • synaptik
    synaptik over 8 years
    Sorry for going back and forth on accepted solutions. Ultimately, I did go with cfr's, so I just accepted that one (again).