I'm trying to typeset some computer code which involves a caret (for powers); for example


The trouble here is that the caret produced is rather flat. I could use a wedge instead:

\texttt{x\pwr 3+x\pwr 2-1}

but the wedge here is too pointy, as well as being the wrong weight for the typewriter font. What I want to know is: is there a symbol, which comes halfway between caret and wedge in shape, and is the same weight as a typewriter caret (so can be used within \texttt{})?

I've tried replacing \verb!^! with {{}\large\textasciicircum} and this sort of works, but is still clearly not an optimum solution.

4 Answers 4


The appearance of the care symbol depends on the used font. For example, Courier or TeX Gyre Cursor has a symbol that is something between the caret of the Computer Modern fonts and the \wedge solution.

The following example uses \lstinline instead of \verb, because a symbol can more easily be replaced via option literate:

    \fontfamily{qcr}% TeX Gyre Cursor
    %\fontfamily{pcr}% Courier

\verb|\verb|: &
  \verb|x^3+x^2-1| \\
\verb|\wedge|: &
  \texttt{x$^\wedge$3+x$^\wedge$2-1} \\
\verb|\lstinline| + \verb|\caret|: &
  \lstverb|x^3+x^2-1| \\



An admittedly complicated attempt for automatic use of a different symbol in verbatim modes; I use a vertically scaled circumflex in a "bold non extended font".


\verb|x^2+y^2| --- \texttt{x\textasciicircum2+y\textasciicircum2}


enter image description here

You can compare the result with the usual one (first line right) and see that the symbol occupies the correct amount of space.


You can use the scalerel package to stretch the wedge symbol to the desired height. In the example below, I first show your two original attempts, followed by the wedge at 60% of its original height. Obviously, any fractional setting can be used.



\texttt{x\pwr 3+x\pwr 2-1}

\texttt{x\pwr 3+x\pwr 2-1}


enter image description here


Thanks, folks. I ended up making my own character with a tikz kludge:

    \draw[color=white] (0,0) rectangle (1.3ex,1.5ex);%
    \draw[line width=1pt,line cap=round] (0.15ex,1.2ex) -- (0.65ex,1.7ex) -- (1.15ex,1.2ex);}}

and then in the body of the document:

\texttt{x\crt 3+x\crt 2-1}

Clearly my kludge is not very portable; I would need to be smarter in having TiKZ use the dimensions of the current characters, so it would always be the correct size.

enter image description here

  • What do you need the white rectangle for?
    – einpoklum
    Jun 20, 2013 at 20:12
  • For a bounding box: otherwise the spacing isn't right. I could replace this with \draw[white,use as bounding box] (0ex,0ex) rectangle (1.4ex,2ex); As it is the spacing is just right for cmtt10.
    – Alasdair
    Jun 20, 2013 at 21:07
  • But what if the background is non-white, or not even a uniform color? Can't you draw a 'phantom' or transparent rectangle?
    – einpoklum
    Jun 21, 2013 at 13:18
  • Sure, in fact what I've done since is to use \draw[opacity=0...] which provides for complete transparency. And I've found a way to use the size of the character: \newcommand*{\crt}{\tikz[baseline=(X.south),inner sep=0pt]{\node[opacity=0] (X) {\char88};\draw[line width=0.7pt,line cap=round,scale=.75] (X.north west) -- ($(X.north west)!0.5/cos(40)!40:(X.north east)$) -- (X.north east);}} I've found that an angle of 40 for the caret seems to given (at least to me) the most pleasing result.
    – Alasdair
    Jun 21, 2013 at 23:36

You must log in to answer this question.

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