0

I've attempted to create a command so that a ` --namespace=<mon-namespace> ` in markdown would produce the same fixed font, but colorized

changing this:

qui est accessible en ajoutant `--namespace=<mon-namespace>` à une commande `kubectl`.

by that:

qui est accessible en ajoutant \fonction{--namespace=<mon-namespace>} à une commande `kubectl`.

where \fonction has this definition in markdown header-includes:

\newcommand{\mauve}[1]{\textcolor{Purple}{#1}}
\newcommand{\fonction}[1]{\begingroup\small\mauve{\texttt{#1}}\endgroup}

The result is nearly what I'm willing to have, but not exactly. Here's a capture of its pdf result, below:

enter image description here

the two minus signs -- preceding namespace look like they are only one, and this is trouble prone.

It seems that \texttt should not be the Latex function, or not the only function, I should use to achieve the result I'm willing.

What should I change in my function
\newcommand{\fonction}[1]{\begingroup\small\mauve{\texttt{#1}}\endgroup}
for that?

  • Did you try \verb+#1+ instead of \texttt{#1}? – user94293 Mar 19 '23 at 06:07
  • I'm trying: \newcommand{\fonction}[1]{\begingroup\small\mauve{\verb+#1+}\endgroup}, but I'm receiving a LaTeX Error: \verb illegal in command argument. – Marc Le Bihan Mar 19 '23 at 06:46
  • 1
    The suggested duplicate is not specific for Markdown but I think at least some of the approaches would be applicable for your situation. – Marijn Mar 19 '23 at 07:58
  • An approach with verbatim could be https://tex.stackexchange.com/questions/304334/verbatim-inside-macro-with-color. Also https://tex.stackexchange.com/questions/370334/use-color-in-verbatim-environment may be useful. – Marijn Mar 19 '23 at 08:07
  • @Marijn Well, I used the \usepackage{microtype} with \DisableLigatures[-]{} trick, that looked the less disruptive, and it worked, thanks a lot! But I wonder how the text between ticks, with markdown, does itself to achieve that result of not any ligatures. Do you think it disable them, also? – Marc Le Bihan Mar 19 '23 at 10:53
  • @MarcLeBihan I don't know exactly how that works in Markdown but I suspect that backticks are a shortcut for \verb, which indeed displays all characters exactly as they are entered without further processing (i.e., verbatim). – Marijn Mar 19 '23 at 11:09

0 Answers0