4

I'm trying to create a new character as a superposition of $\bot$ and =, as follows:

Using the command <code>\disjointcompl</code> in regular environments

For some reason it is not working in \caption environments, as opposed to regular environments. What is wrong; where is the conflicting \if -statement?

\documentclass[a4paper,11pt,oneside,oldfontcommands]{memoir}
\usepackage{amsmath}    

% Disjoint & complete (\disjointcompl) character, as a superimpose of \bot and = .
\newcommand{\disjointcompl}{%
  \mathrel{
    \vphantom{=}\text{
      \mathsurround=0pt\ooalign{
        $\bot$\cr\raisebox{-0.89ex}{$=$}\cr
      }
    }
  }
}

\begin{document}
The disjoint \& complete context is denoted as $\disjointcompl$  

\begin{figure}
  \caption{A correspondence over a \emph{disjoint class context}. The current  context is defined as \( \disjointcompl  \)}
\end{figure}

\end{document}

This code generates the following error:

! Incomplete \iffalse; all text was ignored after line 19.
<inserted text> 
                \fi 

Wheras removing the \disjointcompl in the caption makes the code work and produces the picture above.

  • 2
    \protect\disjointcompl? Or define \newcommand{\disjointcompl} with etoolbox's \newrobustcmd: \newrobustcmd{\disjointcompl}. – moewe Jan 20 at 21:44
  • 2
    As moewe says, this is clearly a problem of a fragile command in a moving argument. \protect\disjointcompl solves it; or replace \newcommand{\disjointcompl} with \DeclareRobustCommand{\disjointcompl} – egreg Jan 20 at 21:46
  • The symbol has three horizontal bars; I guess you only want two. – egreg Jan 20 at 21:51
  • @egreg Indeed I want two bars; a matter of trial-and-error in positioning the \bot, which is dependent on the particular font sigh. – plbt Jan 20 at 22:00
  • 1
    I'm afraid that the having a definition working with every font is a dream. – egreg Jan 20 at 22:07
2

The problem is that your definition of \disjointcompl makes it a fragile command, that has to be prefixed by \protect if used in a moving argument (caption or section title).

You can use \DeclareRobustCommand, in order to avoid the issue.

Here's a modified definition of your command that works in captions and also exactly superimposes the top bar of the equal sign to the bar of \bot.

\documentclass[a4paper,11pt,oneside,oldfontcommands]{memoir}
\usepackage{amsmath}    

% Disjoint & complete (\disjointcompl) character, as a superimpose of \bot and = .
\DeclareRobustCommand{\disjointcompl}{%
  \mathrel{\text{%
    \mathsurround=0pt
    \vtop{\offinterlineskip
      \ialign{##\cr
        $\bot$\cr
        \noalign{\kern-0.1ex}
        $=$\cr
      }
    }%
  }}%
}

\begin{document}
The disjoint \& complete context is denoted as
$\disjointcompl_{\disjointcompl_{\disjointcompl}}$

\begin{figure}[htp]
  \caption{A correspondence over a \emph{disjoint class context}. The current  context is defined as \( \disjointcompl  \)}
\end{figure}

\end{document}

enter image description here

Very magnified version

enter image description here

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.