2

Using markdown quite a lot lately, I would like to use backticks/backquotes in the same way in Latex. Thus

Using a `tt-font`

would produce the same as

Using a {\tt tt-font}

similarly to the two $s to enable .

I am aware that such changes are problematic as the uses backticks for character codes, but I do not use these directly in my files.

false
  • 289

1 Answers1

5

First of all, you should be aware that \tt (together with all two-letter font change commands) has been deprecated for about 30 years.

Now your problem.

\documentclass{article}

\AtBeginDocument{% \begingroup\lccode~=``\lowercase{\endgroup\let~}\markdownbackquote \catcode``=\active } \begingroup \catcode``=\active \protected\gdef\markdownbackquote#1{\texttt{#1}} \endgroup

\begin{document}

This is typewriter type.

\end{document}

enter image description here

The preamble code might also be

\begingroup
\catcode``=\active
\AtBeginDocument{%
  \let`\markdownbackquote
  \expandafter\catcode\string``=\active
}
\protected\gdef\markdownbackquote#1`{\texttt{#1}}
\endgroup
egreg
  • 1,121,712