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.

3
  • 3
    Perhaps you should simply use the markdown package if you prefer to use the Markdown syntax with LaTeX.
    – Gaussler
    Mar 17, 2023 at 7:34
  • @Gaussler, thank you, from what I gathered, this package supports full markdown, so one then cannot use the regular latex commands,
    – false
    Mar 17, 2023 at 7:43
  • 1
    The package supports a hybrid mode where both Markdown and LaTeX syntax can be used.
    – Gaussler
    Mar 17, 2023 at 10:55

1 Answer 1

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
8
  • deprecated since 30 years? What is the recommended way then? Mar 17, 2023 at 15:51
  • @user1778602 \texttt{...}
    – egreg
    Mar 17, 2023 at 16:58
  • ... thank you, but how can I use unescaped underscored within the backticks?
    – false
    Sep 13, 2023 at 13:44
  • @false Sorry, but I don't understand what you're asking.
    – egreg
    Sep 13, 2023 at 14:17
  • Such that I can write a name with underscores directly. Currently, I need to insert a `` everywhere.
    – false
    Sep 13, 2023 at 14:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .