I defined a new logical symbol in LaTeX using TikZ:

\draw[line cap=round] (0,0) --(1.4ex,0) -- (2.2ex,0.6ex);
\draw[line cap=round] (1.4ex,0) -- (2.2ex,-0.6ex);

It goes fine as long as I type $excl{}$ with an empty argument. This is quite inconvenient so I would like to get rid of the curly brackets and just type $\excl$ instead. But I simply do no know how to do it and simply deleting [1] in newcommand simply blocks compilation. Anyone to help me?

  • 2
    delete both [1] and [#1] but if then seems big or small for you try placing at the deleted [#1]'s position something like [scale=0.8] or similar... – koleygr Aug 28 '19 at 1:49
  • 4
    \newcommand{\excl}[1][]{\operatorname{ \begin{tikzpicture}[#1] \draw[line cap=round,line width=0.07em] (0,0) --(1.4ex,0) -- (2.2ex,0.6ex); \draw[line cap=round,line width=0.07em] (1.4ex,0) -- (2.2ex,-0.6ex); \end{tikzpicture} }}, i.e. make the argument optional by adding []. These optional arguments can be useful if you want, say, to change the baseline of the picture. BTW, I'd specify the line width in scalable units, too, hence the line width=0.07em. That way the symbol really adjusts to the font size. – user194703 Aug 28 '19 at 1:54
  • @Schrödinger'scat please turn your comment to an answer! – Black Mild Aug 28 '19 at 7:02
  • Thanks to all of you! I simply deleted both [1] and [#1] and that worked perfectly fine. – IanShil Aug 29 '19 at 2:03

You could just make the argument optional. However, I'd recommend adding a few more features:

  1. Make the symbol bold if the ambient text is.
  2. Use \mathchoice to make the symbol adjust its size in, say, a subscript.

\DeclareRobustCommand{\checkbold}[1]{% https://tex.stackexchange.com/a/24635/121799
\draw[line cap=round,line width=(1+0.33*\tmp)*0.06em] (0,0) --(1.4ex,0) -- (2.2ex,0.6ex)
 (1.4ex,0) -- (2.2ex,-0.6ex); 
\draw[line cap=round,line width=(1+0.33*\tmp)*0.06em] (0,0) --(1.4ex,0) -- (2.2ex,0.6ex)
 (1.4ex,0) -- (2.2ex,-0.6ex); 
\draw[line cap=round,line width=(1+0.33*\tmp)*0.045em] (0,0) --(1.05ex,0) --
 (1.05ex,0) -- (1.6ex,-0.45ex); 
\draw[line cap=round,line width=(1+0.33*\tmp)*0.035em] (0,0) --(0.85ex,0) --
 (0.85ex,0) -- (1.4ex,-0.35ex); 
\draw[line cap=round] (0,0) --(1.4ex,0) -- (2.2ex,0.6ex); 
\draw[line cap=round] (1.4ex,0) -- (2.2ex,-0.6ex); 
$A\excl B$ $X_{A\excl B}$ \boldmath $A\excl B$ $X_{A\excl B}$\unboldmath\par
$A\oldexcl B$ $X_{A\oldexcl B}$ \boldmath $A\oldexcl B$ $X_{A\oldexcl B}$\unboldmath\par
$A\excl[baseline=-0.65ex,purple] B$ 

enter image description here

The first line shows how the symbol behaves with these additional features, the second line shows what happens without them, and the third line illustrates what the optional argument(s) can be used for.

| improve this answer | |
  • Wow! I would have never thought of that. Thanks a lot for this answer, be sure I will incorporate it in my file :-) – IanShil Aug 29 '19 at 2:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.