10

I want to write this; /camera/image_raw, but it seems impossible to compile. The forward slash is not the issue, but as soon as I put text behind it doesn't work :(

Does anyone know a solution?

3
  • 6
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. I expect the issue is the underscore character which indicates a subscript and can only be used in math mode. I suggest you use /camera/image\_raw instead. If that doesn't work you need to include a minimal working example (MWE). Commented Apr 23, 2014 at 19:57
  • 1
    _ is a special character: it is used in math formulae to denote a subscript. Write: /camera/image\_raw or \verb+/camera/image_raw+ (in the latter case it will be typeset with a teletype font).
    – Bernard
    Commented Apr 23, 2014 at 20:01
  • @Nicola Talbot: Outpaced while I was checking my comment. As usual, forgot to check that point myself.
    – Bernard
    Commented Apr 23, 2014 at 20:07

1 Answer 1

11

The underscore _ is a special character that TeX interprets as an instruction. (In this case, it's a subscript instruction for use in math mode.) To actually make an underscore symbol appear you need to use \_ (or \textunderscore). For example:

\documentclass{article}

\begin{document}

/camera/image\_raw

\end{document}

Or as Bernard mentioned, you can also use the \verb command:

\documentclass{article}

\begin{document}

\verb+/camera/image_raw+

\end{document}

However, be careful with \verb as you can't use it in the argument of a command. (See Why doesn’t verbatim work within …?.)

If your text represents a path (which it seems to) you can also use the \path command provided by the url package:

\documentclass{article}

\usepackage{url}

\begin{document}

\path{/camera/image_raw}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .