Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In LaTeX, how to escape to print out a block of text

Tags:

latex

The Problem: I just want to print a sequence like this in plain text:

                     a (10)
                   _/ \_
                  /     \
             (4) b       c (4)
               _/ \___
              /       \
         (8) d       _ e _ (5)
            / \     /  |  \
           f   g   h   i   j
          (2) (4) (1) (1) (6)

I would like to avoid escaping all characters along the way, including special characters for preserving spaces. Essentially, I am drawing an ASCII picture!

like image 855
user1949902 Avatar asked May 28 '15 13:05

user1949902


People also ask

How do you escape text in LaTeX?

Outside \verb , the first seven of them can be typeset by prepending a backslash; for the other three, use the macros \textasciitilde , \textasciicircum , and \textbackslash .

How do I ignore a character in LaTeX?

Bookmark this question. Show activity on this post. \ignore{^&%$###___} that outputs exactly ' ^&%$###___ ' in the pdf document?

How do you make special characters in LaTeX?

If you simply want the character to be printed just as any other letter, include a \ in front of the character. For example, \$ will produce $ in your output. The exception to the rule is the \ itself because \\ has its own special meaning. A \ is produced by typing $\backslash$ in your file.

How do you write text in math mode in latex?

Write Text inside Math Mode: Tips + Examples 1 Method 1: \text {} command. In LaTeX, the command \text {} with package amsmath is used to add normal text in math in LaTeX. 2 Method 2: \textrm {} command. The command \textrm forces the roman font style for text and keeps font parameters from the current text font. 3 Method 3: \mbox {} command. ...

How to escape special characters from a block?

Just in case anyone is looking for another way to escape special characters, this can be done with the listings package. Since all characters will be displayed as they are, it is not possible to execute any command inside the block. Update: the inline listing \lstinline supports the math mode by including the mathescape option.

Does latex give too much space to the first two characters?

? Taking a closer look at the first two characters of “fraction” in math mode shows that LaTeX assigns them more space, giving the word a somewhat unnatural appearance. Here is another example where switching to normal text is desirable.

What are special characters in latex?

The following characters play a special role in LaTeX and are called"special printing characters", or simply "special characters". Whenever you put one of these special characters into your file, you aredoing something special. If you simply want the character to be printedjust as any other letter, include a \in front of the character.


1 Answers

For a pure ASCII-picture interpretation, use the verbatim environment:

enter image description here

\documentclass{article}
\begin{document}

\begin{verbatim}
             a (10)
           _/ \_
          /     \
     (4) b       c (4)
       _/ \___
      /       \
 (8) d       _ e _ (5)
    / \     /  |  \
   f   g   h   i   j
  (2) (4) (1) (1) (6)
\end{verbatim}

\end{document}

The verbatim environment sets interprets spaces, line breaks and special characters as-is.

like image 121
Werner Avatar answered Nov 09 '22 15:11

Werner