[Tex/LaTex] How to create a full-size circumflex in typewriter font

fontssymbolstypewriter

I have some C source code and would like to show the circumflex or caret (^) in the way it is typically shown in source code — as a full-size character. The source code will be appearing in typewriter font, and I'd like for the character to have the same (i.e. fixed) width as all the other characters.

Things that I tried (all inside \texttt{}) that don't work satisfactorily:

  • \textasciicircum produces a small, high circumflex

  • \char`\^ same

  • \verb|^| same

  • \wedge in math mode produces a symbol that is too big and too wide, upsetting alignment of subsequent columns

I'm also interested in showing a full-size tilde (~), though I see that has already been beaten to death here. I really hope the same hijinks won't be needed for the circumflex, but it would be good to know for sure either way!

Best Answer

As Will Robertson says, the rendering of the caret depends on the font. Here I give three examples:

  1. Computer Modern Typewriter in OT1 encoding
  2. Computer Modern Typewriter in T1 encoding
  3. Inconsolata

In all three the first caret is obtained with \textasciicircum and the second one with \^{}. In the first row the two carets are the same, in the second row the first caret is sligthly bigger and a bit lower; this is the symbol used by \verb if the default encoding is T1.

enter image description here