How to create a new LaTeX team that behaves like \ verb?

I use LaTeX after a while, but never got dirty hands announcing a new team as I try to avoid this.

However, I need to add monospaced text often in my document, and I use it \verbfor that, which is good, except that the font size of the verb is larger than the regular font of the text. So I need to resize the font and cancel it like \small{}\verb#My monospace code#\normalsize{}. This is not very convenient and error prone.

Is there a better way to do this? Can I define a new team for this? How?

+3
source share
5 answers

Defining new commands that act like verbatim commands is actually quite complicated. The LaTeX package verbatimcontains some materials that will help.

If you use the package times, Computer Modern text font is not suitable for PostScript times fonts. For a more suitable font font (typewriter) try

\renewcommand{\ttdefault}{aett}
+1
source

Why not use the command \texttt{}to get a monospaced text?

, \verb , ( \verb , , \texttt{}). , , :

\newcommand{\smalltt}[1]{{\small\texttt{#1}}}

[1] , ( .) , , \smalltt{my smaller monospaced text.}.

+3

, \verb . , :

\documentclass{article}
\begin{document}
Text and \verb|verbatim % text|.
\end{document}

, , . fancyvrb .

+1

.sty, : \ Renewcommand {\ @} {\ ttfamily\}

+1

:

\newcommand{\zope}{Zope}

, \zope , , . , , .

\newcommand{\bi}{\begin{itemize}}
\newcommand{\ei}{\end{itemize}}

:

\bi
\item 1st item
\item 2nd item 
\item and so on...
\ei

, .

.

\newcommand{\filepath}[1]{\verb!#1!}

, - \filepath{abc.xml}, \verb!abc.xml! .

:

\newcommand{\ida}[1]{\textcolor{blue}{#1}}

\ida{myVariable} \textcolor{blue}{myVariable}

Hope this little tutorial helps serve the purpose.

0
source

Source: https://habr.com/ru/post/1723492/


All Articles