I just try output C\C++ in LaTeX as following below:


But im getting this issue:

! Undefined control sequence.
<argument> C\backslashC 
l.141 ... \textit{C\backslashC\+\+}
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Sean Allred Nov 26 '13 at 4:40
\documentclass[preview,border=12pt]{standalone}% change it back to your own document class

I love \texttt{C/C++} but not \texttt{C\char`\\ C++}.

enter image description here

  • 1
    style of backslash is different from that of forward slash. in \texttt, use this: \char\\ (and better yet, put an open quote before the double backslash, but that's real hard to show as a literal in this markdown environment). – barbara beeton Nov 26 '13 at 3:18
  • 1
    \char`\\ (backtick backtick slash char backtick slash slash backtick backtick) is possible as a markdown. – kiss my armpit Nov 26 '13 at 3:32
  • 1
    thanks. i'm trying to do this on an ipad, and it doesn't like to do what I tell it at the best of times. anyhow, your example looks much better now. – barbara beeton Nov 26 '13 at 3:33
  • It may be helpful to explain why the OP's code did not work, or (perhaps more reasonable) point to a resource that does. – Sean Allred Nov 26 '13 at 4:40

The error message says that \backslashC is undefined. You need to put something between the command and the C so LateX can see you want \backslash followed by a C. You can use a space (ignored after a command name) or a brace group: \backslash{}C. Once that error is past, you will get several more errors: \backslash is a mathmode command, and \+ is undefined. What you want is something like \textit{C$\backslash$C++}, but the spacing is all wrong. Also, one usually uses a forward slash in combinations like this. Here are two possibilities, one using a backslash (with the spacing improved) and one with a forward slash:


Combining Donut E. Knot's answer with Prettiest way to typeset “C++” (cplusplus)? gives the following answer:

\documentclass[preview,border=12pt]{standalone}% change it back to your own document class

\newcommand{\CC}{C\nolinebreak\hspace{-.05em}\raisebox{.4ex}{\tiny\bf +}\nolinebreak\hspace{-.10em}\raisebox{.4ex}{\tiny\bf +}}

I love \texttt{C/\CC} but not \texttt{C\char`\\ \CC}.

I love C/C ++ but not C\C++

Via The Endevor

I have no idea why the original posters code does not work.

  • 3
    Because \backslashC is undefined control sequence as the error message aptly says :) – Khaled Hosny Nov 26 '13 at 5:52

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.