3

I'm in need of argument text formatters for use in some environments that use macros to redefine properties (e.g., enumitem).

I need to underline text but there is no equivalent argumentless macro (what do you call these types of macros? They seem to be important in some cases but I can't easy find info on them) that does this.

http://en.wikibooks.org/wiki/LaTeX/Fonts#Font_styles

I can use \bfseries in my macros: e.g., \setlist[1]{style=standard,label=\\,before=\huge\color{black}\bfseries} Here \textbf does not work since it requires an argument.

I need an equivalent for \underline and/or \emph, e.g.,

\setlist[1]{style=standard,label=\\,before=\huge\color{black}\ulseries}

All the 4a___s should be underlined(the 3rd level)

\documentclass[11pt]{article} % use larger type; default would be 10pt
\usepackage[margin=0.4in]{geometry}
\usepackage{booktabs}
\usepackage{enumitem,color}
%\usepackage[normalem]{ulem}

%\useunder{\uline}{\ulined}{}

\setlist[1]{style=standard,label=\\,before=\huge\color{black}\bfseries}
\setlist[2]{style=standard,label=\\,before=\large\color{black}\bfseries}
\setlist[3]{style=standard,label=\\,before=\normalsize\color{black}\mdseries\slshape}
\setlist[4]{style=standard,before=\small\color{black}\mdseries\normalfont\itshape}

\begin{document}


\begin{itemize}
    \item item Root) \hfill
    \begin{itemize}
    \item item2
    \item item3
    \item item4
        \begin{itemize}
        \item item 4a
            \begin{itemize}
                \item 4ai
                \item 4aii
            \end{itemize}
        \item item 4b
            \begin{itemize}
                \item 4bi
            \end{itemize}
        \end{itemize}
        \item item 5   
    \end{itemize}
    \clearpage\huge\item Noon \hfill \\
\end{itemize}

\end{document} 
cfr
  • 198,882
  • These are called 'switches' usually. For underlining specifically, see Custom switches (such as for underlining). This isn't quite the general solution you are looking for, however. It's not clear that \emph itself can be made into a switch, but for your purposes I don't see why you couldn't just use \itshape instead. – Alan Munn Apr 13 '15 at 00:45
  • @AlanMunn I do use \itshape but I've used some package ulem to turn emph into underline. Either case I need to underline and \itshape doesn't do that. \emph and \underline do not work. – user4780446 Apr 13 '15 at 00:52
  • I've also tried the ulined link you send but when replacing \bfseries nothing chances(except the bf part). It may be a n issue with enumitem. – user4780446 Apr 13 '15 at 01:02
  • Actually the linked question doesn't work in your case. So that others can play with your code, can you turn your two code fragments into a complete compilable document. Is the issue that you want to define the list using emph and then have ulem automatically change it to underlining? – Alan Munn Apr 13 '15 at 01:05
  • @AlanMunn 1. I am simply creating a nested list of itemize. To make this look good I'm trying to "style" it in the same sense of CCS with html. 2. I'm using enumitem to do this since it has the \setlist macro. 3. All I'm trying to do is have the 3rd level's items be underlined. So I don't have to do \item \underline{my item} or 1000 items. e.g., on the 1st level I use setlist to make all the items bold. It works fine. I can easily change one line and all the top level items get changed(say I want to use italics or whatever). But since I have bold and italics I need underline for the 3rd level. – user4780446 Apr 13 '15 at 01:11
  • 1
    If you have 1000 items underlined, and (?) 1000 items in italics, and (?) 1000 items in bold, I hope you have 1000^3 items in a regular 'Roman' font...! More seriously, though, underlining is (AFAIK) usually 'delimited' for TeXnical reasons. I'm not sure a robust \ulseries command is that feasible. – jon Apr 13 '15 at 01:17
  • @jon, thanks, but for my case it works fine. It is a document it only for me. Thanks for worring!!! – user4780446 Apr 13 '15 at 01:22
  • 2
    Underlining is different. In the other cases, you are switching to a different font - a different weight, size or shape and/or family. But that's not available for underlining. There is no underlined font in most font families. Unless you are using a family which includes such a font, this cannot work in anything like the same way. How about using colour? Or upright italics or bold and italic or something? Anything where there is a font you can switch to. – cfr Apr 13 '15 at 01:34
  • Or switch to sans-serif or typewriter or small-caps... – cfr Apr 13 '15 at 01:36
  • Ok, well, that sucks. Now we know. I'll find another option then. – user4780446 Apr 13 '15 at 02:20
  • @cfr could that be the answer? I think it might be in this case. – Paul Gessler Apr 27 '15 at 11:41
  • @PaulGessler Well, it doesn't exactly answer the question. It is more a this-cannot-be-done-this-way because the two cases are disanalogous i.e. underlining just isn't like switching to a different font...? Do you think that counts as an answer? – cfr Apr 27 '15 at 18:00
  • @cfr, yes, in this case (especially considering the OP's latest comment) I think there is no better answer, unfortunately. :-( – Paul Gessler Apr 27 '15 at 18:17
  • @PaulGessler OK. As you wish... ;). – cfr Apr 27 '15 at 21:29
  • The switch version of \emph is \em – Mark Apr 27 '15 at 22:20

1 Answers1

3

Font switches such as \itshape, \mdseries and \scshape tell LaTeX to switch to a different font. The font LaTeX switches to depends on the currently active family, and the various fonts corresponding to the different attributes (weight, shape etc.) are usually defined in a font definition file.

Simplifying reality somewhat, when you say \itshape this is roughly what happens: LaTeX looks for a mapping from {current family + current series + current size + italic shape} to a font. Provided it finds this mapping, it switches to typesetting with that font.

The same thing is true for size switches such as \large except that, in this case, LaTeX may scale the font by an appropriate factor if necessary. Again, the switch causes LaTeX to switch to typesetting with the appropriate font.

If you had a font family which included an underlined font, then you could extend this system to provide similar switches for underlining. However, most font families do not provide such a font. Instead, underlining is added onto the existing characters as part of typesetting. So the font you are getting stays the same. All that changes is that a line is also drawn in the appropriate place.

But typesetting stuff and drawing a line under that stuff is very different from simply typesetting stuff in a different font. So it is not possible to extend the font switching commands to cover this case because you are not actually switching fonts at all. You are instead continuing to use your current font and drawing lines under it.

So the cases are disanalogous and underlining cannot be supported in the same way as a switch to a different font, unless a pre-underlined font is available as part of the current font family and appropriate extensions to LaTeX's font-handling facilities are defined.

I'm not aware of any readily available font family which provides a pre-underlined font. To demonstrate the way in which the font handling of LaTeX can be extended, therefore, I'll use the non-standard upright italic of Latin Modern.

By default, there is no high level way of accessing this font. To use it, you would need to use lower level font-switching commands and ensure appropriate mappings. However, the shape can be accessed if you use the cfr-lm package. This provides an extended set of font definition files for Latin Modern. In addition, it loads nfssext-cfr which provides commands analogous to the standard LaTeX font switches. For example \uishape enables the upright italic shape in approximately the same way as \itshape enables the regular italic shape in standard LaTeX.

So you could use upright italic for the third level of the itemisation, which is easier to distinguish from the oblique shape than the regular italic.

For example:

\documentclass{article}
\usepackage{enumitem,color}
\usepackage[rm=lining,sf=lining,tt=lining]{cfr-lm}

% Note that style=standard has no effect: in a description, it is default; in an itemize or enumerate, it doesn't apply
\setlist[itemize]{before=\color{black}}
\setlist*[1,2,3,itemize]{label={}}
\setlist*[1,2,itemize]{before*=\bfseries}
\setlist*[1,itemize]{before*=\huge}
\setlist*[2,itemize]{before*=\large}
\setlist*[3,itemize]{before*=\normalsize\mdseries\uishape}
\setlist*[4,itemize]{before*=\small\normalfont\slshape}

\begin{document}
  \begin{itemize}
    \item item Root)
    \begin{itemize}
      \item item2
      \item item3
      \item item4
      \begin{itemize}
        \item item 4a
        \begin{itemize}
          \item 4ai
          \item 4aii
        \end{itemize}
        \item item 4b
        \begin{itemize}
          \item 4bi
        \end{itemize}
      \end{itemize}
      \item item 5
    \end{itemize}
    \item Noon
  \end{itemize}
\end{document}

shape switching

cfr
  • 198,882