I have the same problem as in this question, but the answers just circle around how to best use quotation marks. This is fine as long as you actually want a quotation mark. However, I explicitly don't want it.
And there is one legitimate reason: I want to display code. Verbatim. Without any change.
So I put that in \texttt
, or in a special command I have defined that also just does this.
MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
% you may add magic here to make it ignore/escape any special characters
\newcommand{\inlinecode}{\texttt}
% disable " making strange characters, it breaks our code quotations
% \shorthandoff{"} % does not fully work (see below)
\title{shorthandoff}
\date{August 2020}
\begin{document}
\maketitle
\section{Introduction}
This is a JSON snippet:
\inlinecode{"example\_string\_mentioned": "yes\_no"} \\
\inlinecode{"okay"} \\
\inlinecode{"yikes"}\\
\inlinecode{"ohno"}\\
\end{document}
This resullts in this:
This is a JSON snippet: ëxample string mentioned": "yes no"
ökay"
"yikes"
öhno"
Obviously this is bad. Obviously I don't want to use typographically correct quotation marks.
Already tried:
- Escape as
{"}
(caused display errors and showed errors in the console)¹ or as\"
(did not help). - Actually escape the
{e}
inexample
– did not work either. \shorthandoff
is a good recommendation from the already linked question and helps. Unfortunately, if you uncomment it above, it still does mangle with thee
: We do not getökay
anymore, but we do getëxample
.- This answer pointed me to
\verb
. While this works, this meansI a) cannot put it init prevents any line breaks at the line end.\texttt
anymore, it refuses that, and worse, b)
Edit: It accidentally uses typewriter (same-width) font already, which I want in this case, but which may not be desired in other use cases.
¹ Actually, it seems to force a line break and showed this:
Argument of \language@active@arg" has an extra }.
I basically just want Markdown-like behaviour of the
`.
In other words: How do I really escape "
in LaTeX?
TexLive 2019
\shorthandoff{"}
behind \begin{document}, or load babel with\usepackage[ngerman,shorthands=off]{babel}
. – Ulrike Fischer Aug 29 '20 at 14:12o
, but not fore
??? BTW, feel free to submit an answer to this question, so I can accept it and give you the credit for solving this. – rugk Aug 29 '20 at 14:29\verb|example_string_mentioned": "yes_no"|
? – David Carlisle Aug 29 '20 at 15:31\begin{verbatim}
I did not understand your comment about not allowing\texttt
as\verb
uses the texttt font. – David Carlisle Aug 29 '20 at 17:36