When I google this, it seems that \XOR is how you would get an XOR symbol in LaTeX, however that is giving me the 'undefined control sequence' error. How does one get the xor symbol?
Asked
Active
Viewed 2.6e+01k times
7 Answers
47
-
18I think the
\mathbinisn't strictly necessary because\oplusis already a binary operator. – Philipp Oct 09 '10 at 09:31 -
2
15
What you're looking for is \veebar in amssymb.
\usepackage{amssymb}
$\veebar$
If you like, you can create a new command \lxor, named to match \lor and \land:
\providecommand{\lxor}{\veebar}
Scott H.
- 11,047
Jonathan Baldwin
- 250
-
1
-
For reference, the veebar symbol is ⊻, though in LaTeX it might not have a space between the ∨ and the bar – mic Nov 19 '20 at 04:17
5
Another way of representing the XOR connective is by using a W-like symbol (as in p W q), also used in Set Theory to refer to disjunctive union. Since this symbol does not seem to appear in the Comprehensive LaTeX symbol list, you can create it by joining two "or" connectives together through the following command:
\newcommand{\xor}{%
\mathbin{%
{\vee}\mspace{-2.9mu}\nonscript\mspace{0.3mu}{\vee}%
}%
}
that however doesn't work on second levels subscripts/superscripts
Full example:
\documentclass{article}
\usepackage{amsmath}
\newcommand{\xor}{%
\mathbin{%
{\vee}\mspace{-2.9mu}\nonscript\mspace{0.3mu}{\vee}%
}%
}
\begin{document}
$A\xor B_{x \xor y}$
\end{document}
egreg
- 1,121,712
-
1Welcome! Please provide a complete example. What defines
\mspace? It is not a default LaTeX command. – cfr Apr 21 '16 at 01:38 -
1Thanks! It would still be better to give a complete example even though other answers to this question don't. Also, I'm pretty sure this can't possibly be a good way to do it, but I've up-voting anyway as I appreciate the effort ;). (It can't be right to add space like that in maths mode and shouldn't this be declared as a maths symbol?) – cfr Apr 21 '16 at 01:50
-
You're right about the example, the spaces and the symbol declaration. The command still needs some fine-tuning. Thanks for the feedback and advice! – Maxime Sainte-Marie Apr 21 '16 at 05:15
-
4I've taken the liberty of turning your good idea into working code;
\DeclareMathOperatorwas not the correct tool and\ooaligndid nothing; using\mspaceandmuunits allows for making it work also in sub/superscripts (alas, not in second level ones). – egreg Apr 21 '16 at 08:01
4
I found a bit lame solution, but it works for me. Just do:
\underline{\vee}
Stefan Kottwitz
- 231,401
Mush
- 41
0
Hard to believe this one was overlooked. In Overleaf, I type the following:
P \dot{\lor} Q
results in:
P ̇∨ Q
Svend Tveskæg
- 31,033
JeffL
- 1
-
Actually to provide some spacing consistent with embedded functions, such as P v Q, one can include an inelegant pair of hspaces: – JeffL Dec 22 '21 at 16:20
-
-
People are just not using the same notation as you. // You should [edit] the answer to add more information; also you can add image to answers. – user202729 Dec 22 '21 at 16:25
-
2
-
No one above suggested \dot\lor from what I saw above. Either way will work. Yours is more compact or "proper". Note my acknowledgement of "inelegant". – JeffL Dec 23 '21 at 04:44

symbolsdoes not list\xor, so I can’t help you without knowing what the symbol looks like. Have a look at “How to look up a math symbol?” for ideas how you can easily find a particular symbol. – Caramdir Oct 09 '10 at 04:07\oplusis clearly superior to\mathbin{\oplus}or\newcommand*\xor{\mathbin{\oplus}}. – Eric Feb 18 '16 at 07:51