Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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!

share|improve this question
    
See also How to look up a symbol. –  Stefan Kottwitz Jan 30 '13 at 17:13

3 Answers 3

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

share|improve this answer

I just had this problem and did $^\wedge$, that looks pretty ok.

share|improve this answer
    
Interesting, I didn't realise you could start a math mode segment with a superscript! Will try this at some point. –  j_random_hacker May 3 '11 at 15:08
2  
Even better: {\tiny$^\wedge$}. :) –  Peteris Krumins May 4 '11 at 8:10

I usually use something like this:

\texttt{\char`\^}

Inside an appropriate macro, of course. Whether this looks acceptable will depend a little on what monospace font you're using.

share|improve this answer
    
Thanks, but that looks identical to \textasciicircum and \verb|^| inside a \texttt{} -- small and high. I'll update my question. Is it possible to use multiple monospace fonts in a single document, and do all monospace fonts of the same point size have the same fixed width? If so that might let me choose a different font for just the ^ character that doesn't mess with the alignment (I need to keep most characters in the standard monospaced font). –  j_random_hacker Oct 8 '10 at 8:15
3  
Yes, and no. But you could hack around the problem. I don't see what the problem is, though—the way the caret is displayed in TeX is no different than all other fixed width fonts on my machine. –  Will Robertson Oct 8 '10 at 10:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.