1

How can I make only one word "verbatim" in LaTeX?

For example:

\usepackage{verbatim}
\begin{document}
The\begin{verbatim} TableForm[]\end{verbatim} shown below is a trig table which....

The only thing I want to be "verbatim" is TableForm[]. But when I do begin{verbatim} TableForm[] \end{verbatim}, the rest of hte words I have become deleted

I want my final output to look like this:

enter image description here

This is what i have so far:

\documentclass[12pt]{book}
\usepackage{verbatim}
\usepackage{amsmath, amssymb,graphicz,wasysym}

\begin{document}
\begin{verbatim}
\item{The \texttt{TableForm[]} shown below is a trig table which shows sine, cosine, and tangent values for integer angles from $0^{\circ}$ through $90^{\circ}$ in steps of $3^{\circ}$. Like we said in class, we could save \verb|TableForm[]|  as a PDF and import it like we've done a few times.}
\bigskip
\end{verbatim}
  • 3
    The \verb|TableForm[]| shown... where the same token is used to delimit the start and end of the \verb (i.e., \verb+TableForm[]+ would work equally well). – Steven B. Segletes May 21 at 0:14
  • that didn't work for me, is there a certain package I need to use in order to use this? – user130306 May 21 at 0:16
  • When I used it, I got the same output as always – user130306 May 21 at 0:16
  • 6
    No package required. But if you provide us with a complete working example, including your documentclass, preamble, and code that doesn't work, perhaps more suggestions could be made. – Steven B. Segletes May 21 at 0:17
  • 3
    \verb|TableForm[]| would work, but you do not need verbatim, as there are no special characters so you could simply use \texttt{TableForm[]} – David Carlisle May 21 at 0:29
3

Your code works fine when the extra verbatim environment and \item are removed:

\documentclass[12pt]{book}

\begin{document}
The \texttt{TableForm[]} shown below is a trig table which shows sine, cosine,
and tangent values for integer angles from $0^{\circ}$ through $90^{\circ}$ in
steps of $3^{\circ}$. Like we said in class, we could save \verb|TableForm[]|
as a PDF and import it like we've done a few times.
\end{document}

enter image description here

\begin{verbatim} ... \end{verbatim} outputs the text ... literally as given in your code, so all LaTeX commands in it are ignored. You should only use this environment if you want to typeset longer listings of source code or similar.

  • thanks so much, I took that part out and used just texttt{} and it worked. – user130306 May 21 at 16:28

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.