2

I am getting an error when I am using the verb command in align.

I prefer not to use \texttt because the underscore isn't the right length for a single underscore or a double underscore - the right length is somewhere in the middle.

Here's my code:

\begin{align}
    \Verb|Phot_Flag| 0 \\
    \Verb{class_star} > 0.9
\end{align}
  • 1
    please post a fully compilable MWE. – Raaja Dec 29 '18 at 22:13
  • You should get the same underscore in verb or texttt – David Carlisle Dec 29 '18 at 23:15
  • Which error do you get? Check the log file. – Martin Scharrer Jan 7 at 12:16
3

There is an examplep package you can use.

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{examplep}
\begin{document}

\begin{align}
    \PVerb{Phot_Flag } 0 \\
    \PVerb{class_star} > 0.9
\end{align}

\end{document}

enter image description here

2

You just need to detokenize the input, if all you want is being able to use _.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\vtt}[1]{%
  \text{\normalfont\ttfamily\detokenize{#1}}%
}

\begin{document}

\begin{align}
\vtt{Phot_Flag}  &= 0 \\
\vtt{class_star} &> 0.9
\end{align}

\end{document}

enter image description here

1

An approach using verbatimbox.

\documentclass{article}
\usepackage{verbatimbox,amsmath}
\begin{document}
\begin{myverbbox}{\PF}Phot_Flag\end{myverbbox}
\begin{myverbbox}{\CS}class_star\end{myverbbox}
\begin{align}
    \PF &= 0 \\
    \CS &> 0.9
\end{align}
\end{document}

enter image description here

You can also give optional directives to the verb boxes:

\documentclass{article}
\usepackage{verbatimbox,amsmath,xcolor}
\begin{document}
\begin{myverbbox}[\scriptsize]{\PF}Phot_Flag\end{myverbbox}
\begin{myverbbox}[\itshape]{\CS}class_star\end{myverbbox}
\begin{align}
    \PF &= 0 \\
    \CS &> 0.9
\end{align}
\end{document}

enter image description here

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.