tags:

views:

943

answers:

1

Hi, 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?

+3  A: 

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.

Martijn
Ok, thanks for the information. Actually I would prefer verbatim mode due to its shortness but if this is the way it was planned, then there is nothing to do.
Mert Nuhoglu
Thanks for this tip. Unfortunately, I can't define commands for every variable in my current model. There are lots of them :)
Mert Nuhoglu
Use \mathtt{} instead of \verb||; those \newcommands aren't going to work :)
Will Robertson
I must confess I haven't tested it. However, since \newcommand defines a macro, they will work if the first block works. Of course \mathtt also works, but this would require escaping the underscores
Martijn