42

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.

doncherry
  • 54,637
user6359
  • 421

2 Answers2

37

\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.

enter image description here

Stefan Kottwitz
  • 231,401
20

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}

enter image description here

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}

egreg
  • 1,121,712
  • Does using \newcommand or \newcommand* make a difference here? – Mankka Aug 20 '20 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. – egreg Aug 20 '20 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. – Mankka Aug 21 '20 at 09:24
  • @Mankka I think you want the symbol to be a relation symbol, so \newcommand{\at}{\mathrel{\mathpalette\superimpose{{\diamond}{|}}}} should do. – egreg Aug 21 '20 at 09:57
  • I tried that, and while it might feel the logical thing to do, it has too much space. 1mu is just right. :) – Mankka Aug 21 '20 at 12:17
  • 1
    @Mankka I disagree. Anyway, I see no misalignment with 1mu at either side. – egreg Aug 21 '20 at 12:20
  • It works nicely! But I do not understand how. What is the purpose of the braces when calling the "private" macros; and what is the third parameter (or rather, the first) taken by \superimpose@@, which seems to be called only with two by \superimpose@? – Aubergine Oct 31 '22 at 20:34