3

I'd like to print out two minus signs just after each other, like this -- (as in the C operator to subtract one). Doing -- gives one longer - sign. I've tried \char"2D\char"2D but that also just gives one longer - sign. How can this be done?

5
  • 5
    You can try -{}-, but maybe provide some more information about the context (math mode, verbatim, ...?) Mar 29 at 9:18
  • 2
    - in text is a hyphen not a minus sign. In math, $--$ does not ligature to a dash Mar 29 at 9:33
  • 2
    “as in the C operator” sounds like you try to add some kind of source code. In this case you should consider to add the source code verbatim or using a package like listings or minted, so -- wouldn't be a ligature any longer. BTW: Adding a minimal working example would help us to understand the question better and so to help you better.
    – cabohah
    Mar 29 at 9:51
  • Thank you for the replies. Yes, I am writing C-code. I use \lstdefinestyle for larger blocks of code, but I've just changed the font when writing shorter snippets of code that resides within blocks of regular text. However, -{}- did the trick for now. Mar 29 at 13:02
  • 1
    There are certain monospaced fonts, such as Fira Code or Jetbrains Mono that come with special ligatures, for example for !=, -> and the like. -- might be part of such a set of ligatures. In this case -{}- would be a temporal workaround. A better way would probably be to disable the ligature in question. However, it depends on the font whether or not this is possible and, if yes, how to do this. Mar 29 at 14:45

1 Answer 1

5
\documentclass{article}
\begin{document}
$--$
-{}-
\verb|--|
\end{document}

enter image description here

2
  • 1
    Note: -{}- does not work with LuaLaTeX. There you would have to use something like -\kern0pt- or -\/- instead.
    – cabohah
    Mar 29 at 11:27
  • Thank you, just what I needed! Mar 29 at 12:49

You must log in to answer this question.

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