Question

I want to write the following equation in Latex:

resting_metabolic_rate=metabolism_of_body_cells + metabolism_of_turnovers + metabolism_of_conversions + ec

I tried using verbatim mode:

\begin{verbatim}
 resting_metabolic_rate=metabolism_of_body_cells + metabolism_of_turnovers 
                          + metabolism_of_conversions + ec
\end{verbatim}

This code doesn't produce equation number and label like equation mode. Is it possible to use \label{} and equation numbering with verbatim?

Was it helpful?

Solution

This is to be expected behavior of the verbatim environment: everything in the verbatim environment is typeset literally (except, of course, \end{verbatim}, which ends the environment).

Instead, use the inline verbatim command:

\begin{equation}\label{eq:some_name}
   \verb|resting_metabolic_rate|
     =\verb|metabolism_of_body_cells|
       + \verb|metabolism_of_turnovers| 
       + \verb|metabolism_of_conversions|
       + \verb|ec|
\end{equation}

This will typeset the equation as a normal equation, with label and all, but with your 'variables' typeset verbatim (which is probably what you're after).

For shortness, you can also define commands for the 'variables':

\newcommand{\metabody}{\verb|metabolism_of_body_cells|}
\newcommand{\metaturn}{\verb|metabolism_of_turnovers|}
\newcommand{\metaconv}{\verb|metabolism_of_conversions|}
\newcommand{\ec}{\verb|ec|}

and use a call to \metabody, \metaturn, \metaconv or \ec to print the variables.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top