Latex printing single slash, backslash r, backslash n

前端 未结 1 1503
醉话见心
醉话见心 2021-01-25 23:17

I want the following line inside a *.tex file to be printed \"as is\":

while (tmp[0] == \'\\r\' || tmp[0] == \'\\n\') {tmp++;}

When I wrap it i

相关标签:
1条回答
  • 2021-01-25 23:42

    To print an actual backslash in LaTeX you use the command \backslash, so for your code:

    while (tmp[0] == '\backslash r' || tmp[0] == '\backslash n') {tmp++;}
    

    EDIT: I forgot you need this command in math mode. If you want everything "as is", this is the code you need (for the vertical lines and the curly brackets as well):

    while (tmp[0] == `$\backslash$r' $\|$ tmp[0] == `$\backslash$n') $\{$tmp++;$\}$
    

    0 讨论(0)
提交回复
热议问题