Just want to point out something that may be obvious (and in your case you've surely considered already), but is often ignored: if your desire is simply that you'd like to type \or
in your personal .tex
file or in formulas, and have it treated as if you'd typed \lor
, then you can do this by processing the input (specifically, the parts entered manually by you or the user) externally, rather than via a TeX macro.
(For simplicity of illustration let's assume you want \or
treated as \lor
everywhere in your input file, not just in math mode. The example below shows that redefining \or
only in math mode can also cause issues, so there's not much to gain by treating math mode specially anyway.)
Concretely, consider the following input file:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\makeatletter
\let\@oldor\or
\def\or{\ifmmode\lor\else\expandafter\@oldor\fi}
\makeatother
\begin{equation}
(x < 0) \or (x = 0) \or (x > 0)
\end{equation}
\begin{align}
\allowdisplaybreaks[1]
a &= b \\
c &= d
\end{align}
\end{document}
It fails with a hard-to-debug error on reaching the \end{align}
line, because \allowdisplaybreaks
uses \or
internally. See the following from amsmath.sty
:
\interdisplaylinepenalty\@M
\newcommand{\allowdisplaybreaks}[1][4]{%
\interdisplaylinepenalty\getdsp@pen{#1}\relax
}
\def\getdsp@pen#1{%
\ifcase #1\@M \or 9999 \or 6999 \or 2999 \or \z@\fi
}
Instead of redefinining \or
in TeX, we can get rid of the redefinition (the part inside \makeatletter … \makeatother
above), and simply replace every occurrence of \or
with \lor
with an external script. (E.g. something like sed 's/\\or\([^a-zA-Z]\)/\\lor\1/g'
on your file will do.)
With LuaTeX (if our setup allows using that, which in your Mediawiki-texvc case probably not) we can do this inside the file itself if we want:
\documentclass{article}
\usepackage{luacode}
\usepackage{amsmath}
\begin{document}
\begin{luacode*}
luatexbase.add_to_callback('process_input_buffer',
function(line)
return line:gsub([[\or([^a-zA-Z])]], [[\lor%1]])
end,
[[Replaces each \or in the input with \lor]])
\end{luacode*}
\begin{equation}
(x < 0) \or (x = 0) \or (x > 0)
\end{equation}
\begin{align}
\allowdisplaybreaks[1]
a &= b \\
c &= d
\end{align}
\end{document}
Unlike the earlier version, this doesn't cause any issues from uses of \or
in macros that were defined earlier.
\or
, then any conditional based on\ifcase
will cease to work, no matter how you do the definition. Note that\verb
is illegal in a footnote, with any contents.\verb
in a footnote regardless of whether you have\or
in it.\footnote{\verb|or|}
fails too, albeit with a different error. The problem here is something like putting fragile code in a moving argument, although I'm not sufficiently knowledgeable to be able to explain exactly what that means :(.