1

So, I'm using beamer and I wanted to make a cute little ASCII rooted tree. Something like this:

~~~~~~52\\
~~~~/~~~~\textbackslash\\
~~26~~~~~26\\
~~/\textbackslash~~~~~/\textbackslash\\
13 13 13 13

At first, I intended to use the typewriter font (\tt), but apparently the typewriter font doesn't have a backslash, even though it does have a forward slash. LaTeX, in valiant attempt to display something, decided to substitute a backslash from the serif variant of Computer Modern (I think). The result was that the two slashes looked very different, which is ugly. I can live with ugly, but this is so ugly that it's distracting, and I can't live with distracting. So I figured, fine, let's stick with the default font, which in beamer is the sans-serif variant of Computer Modern. This looks much better. Unfortunately, it still produces the warning about undefined symbols, and I try to have things compile without warnings. Should I just use the serif variant for my tree? Or maybe the entire presentation? Or is there some way to suppress this warning? Or perhaps some even nicer idea?

For completeness, the warning is:

LaTeX Font Warning: Font shape `OMS/cmss/m/n' undefined
(Font)              using `OMS/cmsy/m/n' instead
(Font)              for symbol `textbackslash' on input line 101.
Mark
  • 1,393
  • 2
    \usepackage[T1]{fontenc} perhaps? Please don't use the old style font switches such as \tt -- they are deprecated for almost 25 years by now –  Apr 10 '17 at 07:29
  • Can we pretend I said ttfamily? Also, the beamer manual cautions against use T1 unless you also switch to Latin Modern, although I tried it just now with Computer Modern and it seems to work. – Mark Apr 10 '17 at 07:38
  • By the way, what's so bad about tt and company? It's defined in terms of the "proper" command, it's less typing, and as near as I can tell, it does exactly what I want: switch to a fixed width font. And for bonus points, it even work correctly in text and in math mode, getting rid of the need to memorize commands for text and math mode. Not to mention the need to memorize suffixes: it's bfseries but ttfamily. The only downside I remember ever hearing is that the deprecated commands don't nest properly. Fine, but I don't need nesting right here. – Mark Apr 10 '17 at 07:57
  • 1
    Looks like I really do need lmodern, at least if I want to use microtype – Mark Apr 10 '17 at 08:04
  • 1
    Transporting the message 'I don't need nested font commands therefore I will stick to \tt etc' is exactly one of the reasons because the false usage still spreads nowadays –  Apr 10 '17 at 08:20
  • I'm not familiar with the expression "transporting a message" – Mark Apr 10 '17 at 08:23
  • 1
    @Mark Think about \tt like crossing a road when the traffic light is red. This time you may arrive fine on the other site of the road (next time may be different), but it is really a bad example for the school kids standing next to you. – samcarter_is_at_topanswers.xyz Apr 10 '17 at 08:23
  • The reason crossing the road on a red light is bad is that I might get hit by a car, and there is no undo button. What's the danger here? There must be one, because people who know roughly a million times more about LaTeX than I do keep saying it, but I don't see it. – Mark Apr 10 '17 at 08:27
  • 1
    @Mark see http://tex.stackexchange.com/q/41681/36296 There are a few details, such as italic correction, but overall I would say the problem is that the school kids will also go over the red light and don't know what it is like to be hit by a car -> they will not recognise that their problem is caused by \tt and therefore don't know that they need to hit the undo button. – samcarter_is_at_topanswers.xyz Apr 10 '17 at 08:39
  • Ah, so in this analogy, the school kids are the innocent people who will stumble across my parenthetical mention of \tt and think "ooh, nice I'll use that". Which explains Christian Hupfer's reaction I suppose; he's probably seen too many "near misses" for comfort. Fine. I'll try to break the habit. – Mark Apr 10 '17 at 08:47
  • 1
    @Mark Sadly such accidents still happen every day: http://tex.stackexchange.com/questions/364109/why-is-the-bf-command-applied-to-more-than-i-asked – samcarter_is_at_topanswers.xyz Apr 10 '17 at 19:02
  • Okay, wow, I did not expect that. I concede this point. – Mark Apr 10 '17 at 20:32
  • 1
    there is a backslash in \texttt, but i don't know if it's accessed by \textbackslash. what i use is not easy to represent in the markup system available here, so here it is partly in words: "\char backtick double backslash". the backtick and first backslash "escape" the last character in the string, here another backslash. i usually make a definition of this, calling it \bs for ease of use. – barbara beeton Apr 10 '17 at 20:33
  • nice! oddly enough, with the proportional width fonts, this gives an open double quotation mark. font encodings are weird. – Mark Apr 11 '17 at 02:38

1 Answers1

3

Use verbatim and declare the frame as fragile:

\documentclass{beamer}
\usetheme{Warsaw}

\begin{document}

\begin{frame}[fragile]
\frametitle{Rooted tree}

\begin{verbatim}
      52
    /    \
  26     26
  /\     /\
13  13 13  13
\end{verbatim}

\end{frame}

\end{document}

enter image description here

egreg
  • 1,121,712