I'm trying to display a caret (^
) in math mode in LaTeX to represent the exclusive or operation implemented in the "C languages". By default, ^
is for creating a superscript in math mode. The closest I can seem to get is by using \wedge
, which isn't the same.
It is straightforward to insert the hat symbol in your document; you begin with the command that only requires one value (the character) between {}, denoted by the command \hat{}. The command is built-in, you don't need external packages.
Display math mode Use one of these constructions to typeset maths in display mode: \[...\] \begin{displaymath}...\end{displaymath} \begin{equation}...\end{equation}
Hypertext Help with LaTeX To get an expression, exp, to appear as a superscript, you just type ^{exp}. should display as "x3 is the third power of x". Note that the braces around the argument may be omitted if the superscript is a single character.
You might want to use the common symbol for exclusive or instead, \oplus (but give it a proper name with something like \newcommand\XOR{\oplus}
).
The caret is a bit too small to be noticeable as a binary operator. However, if you do insist using a caret instead, use this:
\newcommand\XOR{\mathbin{\char`\^}}
$x \XOR y$
The \mathbin
puts the right spacing around the symbol for a binary operator, and the \char
ensures that the glyph is obtained from the roman font.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With