# How to insert the inbuilt keywords in latex

I am creating a simple tutorial file to take a seminar. My problem is: I want to get the output as "\textbf is used for making the font bold". How can I get that? Likewise, i want to make this for some other keywords too, \textit and all the others...

If the problem is a % , i can use \% as well

But here, i want \textbf to be print in the pdf.

You can use command \verb## and environment verbatim like this:

\documentclass{article}

\begin{document}

\verb#\textbf# is used to make the font bold, for example i could write:

\verb#\textbf{This Is Boldface!}#, resulting in \textbf{This Is Boldface!}

When you have multiple lines of code, it is best to use environment \verb#verbatim#:

\begin{verbatim}
\begin{verbatim}
\textbf{} %is used to make the font bold
\textbf{} %is used to make the font bold
\textbf{} %is used to make the font bold
\textbf{} %is used to make the font bold
\end{verbatim}\vskip-10pt
\verb#\end{verbatim}#

\end{document}


When you have multiple lines of code, it is best to use environment verbatim.

It will be incomplete if listings is not mentioned for such a purpose.

\documentclass{article}
\usepackage{listings}
\lstset{ %
language={[LaTeX]TeX},
basicstyle=\small\ttfamily,
}
\begin{document}
\lstinline{\textbf} is used to make the font \textbf{bold}

\lstinline{\textit} is used to make the font \textit{italic}
\end{document}


\documentclass{article}
%\usepackage[T1]{fontenc}

\begin{document}

Hi! you can do:

\texttt{\textbackslash textbf} is used to make the font \textbf{bold}

\texttt{\textbackslash textit} is used to make the font \textit{italic}

or:

\textbackslash\texttt{textbf} is used to make the font \textbf{bold}

\textbackslash\texttt{textit} is used to make the font \textit{italic}

\end{document}


Hi! Take a look at this above: the simpler the better? I had this solution in my mind and, writing it down, I could appreciate it works with no packages (provided T1 encoding is used, thanks to @egreg).

Addendum: if you plan to use it several times, then why not making a newcommand:

\documentclass{article}
%\usepackage[utf8]{inputenc}\usepackage[T1]{fontenc}

\newcommand{\mact}[1]{\texttt{\textbackslash #1}}

\begin{document}

Hi again! you can just do:

\mact{textbf} is used to make the font \textbf{bold}

\mact{textit} is used to make the font \textit{italic}

\end{document}


Hope it helps!

• Much better, of course, provided T1 encoding is used. Nov 12, 2014 at 19:07
• @MattAllegro "it works with no packages". That is our swagger. Nov 14, 2014 at 19:55