overlay symbols

EDITED to condense the syntax.

Here I provide \mo[<alignment>]{<symbol list>}. I have set it up to use a space as a symbol list separator (though note that a macro as a symbol will require a trailing {} in order for the subsequent space to be recognized). Alignment can be l, c, or r (default c).

The macros X{<horizontal shift in ex>} and \Y{<vertical shift in ex>}{} are also provided.

BY POPULAR DEMAND, additional macros are provided: \FH[<scale>]{<symbol>} for horizontal flipping, \FV[<scale>]{<symbol>} for vertical flipping in the same footprint as the original glyph, \R{<angle>}{<symbol>} for rotating the symbol about its center, and \SC{<scale>}{<symbol>} for scaling a symbol. The 2nd and 4th lines of the output demonstrate these new capabilities.

  \setstackEOL{ }% 
\mo{/ \textbackslash}
\mo{O \sffamily I \Y{.23}{$-$}}
\mo[l]{$|$ \X{.21}=}
\mo{$-$ )\X{.1} \X{.1}(}
\mo{. \Y{.1}{\sd\X{.2}\sd} \Y{.4}{\sd\X{.4}\sd} \Y{.9}{\sd\X{.6}\sd} \Y{1.6}{\sd\X{.8}\sd}}

\mo{\FH{b} b}
\mo{\FH[.7]{b} \SC{.7}{b}}
\mo{\R{45}{b} \R{-45}{\FH{b}}}
\mo{Q \FV{Q}}
\mo{\R{90}{j} \FV{j}}}

enter image description here

You can use \ooalign; the only problem is finding a suitable syntax: here's an attempt.

  • The *-variant uses text mode
  • The optional argument should be a math type selector (by default the type is ordinary)
  • Items to be overlaid are separated by commas, with a possible [<length>] prefix to denote a shift.

Note that shifting may push the symbol outside the overall bounding box.

The overlay scales in sub/superscripts.


\cs_new_protected:Nn \dissonance_ooalign:n
\cs_generate_variant:Nn \dissonance_ooalign:n { V }

    \cs_set_eq:NN \__dissonance_maybemath:n \use:n
    \cs_set_eq:NN \__dissonance_maybemath:n \ensuremath
  \seq_set_split:Nnn \l_dissonance_ooalign_in_seq { , } { #3 }
  \tl_clear:N \l_dissonance_ooalign_out_tl
  \tl_gclear:N \g__dissonance_ooalign_phantom_tl
  \seq_map_inline:Nn \l_dissonance_ooalign_in_seq
    \tl_put_right:Nn \l_dissonance_ooalign_out_tl
      \__dissonance_ooalign_item ##1 \q_stop
  #2 { \dissonance_ooalign:V \l_dissonance_ooalign_out_tl }
  \vphantom{ \tl_use:N \g__dissonance_ooalign_phantom_tl }

% slight abuse for using optional arguments
  \tl_gput_right:Nn \g__dissonance_ooalign_phantom_tl
    \__dissonance_maybemath:n { #2 }
  \__dissonance_maybemath:n { #2 }

\seq_new:N \l_dissonance_ooalign_in_seq
\tl_new:N \l_dissonance_ooalign_out_tl







\overlaysymbols*{O,\sffamily I, \raisebox{.23ex}{$-$}}


enter image description here