-1

When I try to write the above expression I get an error stating: "Undefined control sequence".

The same when I try to write this: ‘\r\n’.

Any ideas?

2
  • You should add more proper data to what you have done so far.. Jun 2 at 7:59
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. For future questions, it might help to explain a bit what you're doing and why. For example, I agree with Fran that it looks like you're trying to typeset code of some sort, in which case there are a few package that make that go much easier.
    – Teepeemm
    Jun 2 at 12:48
7

Any character sequence (word or single character) preceded by a backslash (\<whatever>) is a command (=control sequence) in LaTeX, but whereas \r is defined (to type characters as \r{a}), \n has not a predefined function (is "undefined"), so your alternatives to remove the error are type it verbatim (\verb|\n|) or as plain text (\textbackslash n), or
defining it to make something, i.e., make a LaTeX macro:

\newcommand\n{\textbackslash n}
\n

If what you show is part of a code listing, then you should consider use a verbatim environment:

\begin{verbatim}
----------\n\t  
\end{verbatim}

Or use some package for powered verbatim typesetting or syntax highlight.

0

You may use \textbackslash{} to printout the \ character without a problem.

In your case:

\texttt{--------------\textbackslash{r}\textbackslash{n}}

Output:

--------------\r\n

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.