I want to superimpose two symbols, e.g. I want to superimpose \vee
and \wedge
and >
and <
symbols over each other (not above each other as in stackrel
) and Q
with a horizontal strike through like bar across it. I am using LyX 2.0.
2 Answers
\rlap
and \llap
can be used to print a symbol without a width. Similar, the mathtools package
provides commands \mathrlap
, \mathclap
, \mathllap
. These commands offer a quick way for overlapping symbols.
Example, overlapping \vee
, \wedge
and Q like desired in your question:
\documentclass{article}
\usepackage{mathtools}
\begin{document}
$\mathrlap{\vee}\wedge$
\rlap{Q}---
\end{document}
While \rlap
produces a zero-width box where the content sticks out to the right, \llap
does the same but to the left. \mathclap
centers to the current position.
You can define a generic \superimpose
macro and then use it for various purposes. Add also the desired math atom class for the built symbol.
Note, however, that \superimpose
only makes sense in the context of \mathpalette
.
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\superimpose}[2]{{%
\ooalign{%
\hfil$\m@th#1\@firstoftwo#2$\hfil\cr
\hfil$\m@th#1\@secondoftwo#2$\hfil\cr
}%
}}
\makeatother
\newcommand{\veewedge}{\mathbin{\mathpalette\superimpose{{\vee}{\wedge}}}}
\newcommand{\lessgreater}{\mathrel{\mathpalette\superimpose{{<}{>}}}}
\newcommand{\strikeQ}{\mathpalette\superimpose{{\textnormal{---}}{Q}}}
\newcommand{\dotineq}{\mathrel{\mathpalette\superimpose{{=}{\cdot}}}}
\begin{document}
$\veewedge_{\veewedge}\lessgreater_{\lessgreater}\strikeQ_{\strikeQ}$
$A\dotineq B$ $\scriptstyle A\dotineq B$
\end{document}
With a different and perhaps more intuitive syntax:
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand{\superimpose}[3][\mathord]{#1{\mathpalette\superimpose@{{#2}{#3}}}}
\newcommand{\superimpose@}[2]{\superimpose@@{#1}#2}
\newcommand{\superimpose@@}[3]{%
\ooalign{%
\hfil$\m@th#1#2$\hfil\cr
\hfil$\m@th#1#3$\hfil\cr
}%
}
\makeatother
\newcommand{\veewedge}{\superimpose[\mathbin]{\vee}{\wedge}}
\newcommand{\lessgreater}{\superimpose[\mathrel]{<}{>}}
\newcommand{\strikeQ}{\superimpose{\textnormal{---}}{Q}}
\newcommand{\dotineq}{\superimpose[\mathrel]{=}{\cdot}}
\begin{document}
$\veewedge_{\veewedge}\lessgreater_{\lessgreater}\strikeQ_{\strikeQ}$
$A\dotineq B$ $\scriptstyle A\dotineq B$
\end{document}
-
Does using
\newcommand
or\newcommand*
make a difference here?– MankkaCommented Aug 20, 2020 at 15:29 -
1@Mankka You could indeed use
\newcommand*{\superimpose}[2]{...}
in order to have a check for no end of paragraph in the argument. But as the macro is used as an auxiliary for defining other macros, it's not really important. For parameterless macros,*
or no*
makes no essential difference.– egregCommented Aug 20, 2020 at 15:32 -
I created a new symbol
\newcommand*{\at}{\mathpalette\superimpose{{\diamond}{|}}}
and I wanted slightly more space around it, so I tried\newcommand*{\at}{\mskip 1mu\mathpalette\superimpose{{\diamond}{|}}\mskip 1mu}
. The latter does not align the symbols in (for example)since \(x \at T_D\) is
. My random attempts did not solve this, so I would be grateful if you could suggest a solution.– MankkaCommented Aug 21, 2020 at 9:24 -
@Mankka I think you want the symbol to be a relation symbol, so
\newcommand{\at}{\mathrel{\mathpalette\superimpose{{\diamond}{|}}}}
should do.– egregCommented Aug 21, 2020 at 9:57 -
1@Mankka I disagree. Anyway, I see no misalignment with 1mu at either side.– egregCommented Aug 21, 2020 at 12:20