TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to do the not independent sign in latex without having to install or define new commands (since I am using latexIT and I cannot load new packages).

Currently I use the following sign for independent:

X{\perp\!\!\!\perp}Y

What can I use for X not independent of Y? I.e., something like this: enter image description here?

share|improve this question
1  
Related: double perpendicular symbol (for independence) – Werner Apr 29 '14 at 3:10
    
@Werner thanks, it looks ok but I'd like the diagonal line to go over the independence sign, is that impossible with the base latex system? – Dnaiel Apr 29 '14 at 4:41

The symbol can be constructed using \perp and \not. The distance between the lines of the equals symbol is taken as distance between the vertical lines in the independent symbol.

\documentclass{article}

\makeatletter
\newcommand*{\indep}{%
  \mathbin{%
    \mathpalette{\@indep}{}%
  }%
}
\newcommand*{\nindep}{%
  \mathbin{%                   % The final symbol is a binary math operator
    \mathpalette{\@indep}{\not}% \mathpalette helps for the adaptation
                               % of the symbol to the different math styles.
  }%
}
\newcommand*{\@indep}[2]{%
  % #1: math style
  % #2: empty or \not
  \sbox0{$#1\perp\m@th$}%        box 0 contains \perp symbol
  \sbox2{$#1=$}%                 box 2 for the height of =
  \sbox4{$#1\vcenter{}$}%        box 4 for the height of the math axis
  \rlap{\copy0}%                 first \perp
  \dimen@=\dimexpr\ht2-\ht4-.2pt\relax
      % The equals symbol is centered around the math axis.
      % The following equations are used to calculate the
      % right shift of the second \perp:
      % [1] ht(equals) - ht(math_axis) = line_width + 0.5 gap
      % [2] right_shift(second_perp) = line_width + gap
      % The line width is approximated by the default line width of 0.4pt
  \kern\dimen@
  {#2}%
      % {\not} in case of \nindep;
      % the braces convert the relational symbol \not to an ordinary
      % math object without additional horizontal spacing.
  \kern\dimen@
  \copy0 %                       second \perp
} 
\makeatother

\begin{document}
\[ A \indep B \nindep C = D \]
\[ \scriptstyle A \indep B \nindep C = D \]
\[ \scriptscriptstyle A \indep B \nindep C = D\]
\end{document}

Result

Version for unicode-math

\not does not work as expected, when package unicode-math is loaded. The following version uses the slash instead (the slope is slightly different).

\documentclass{article}
\usepackage{unicode-math}

\makeatletter
\newcommand*{\indep}{%
  \mathbin{%
    \mathpalette{\@indep}{}%
  }%
}
\newcommand*{\nindep}{%
  \mathbin{%                   % The final symbol is a binary math operator
    %\mathpalette{\@indep}{\not}% \mathpalette helps for the adaptation
    \mathpalette{\@indep}{/}%
                               % of the symbol to the different math styles.
  }%
}
\newcommand*{\@indep}[2]{%
  % #1: math style
  % #2: empty or \not
  \sbox0{$#1\perp\m@th$}%        box 0 contains \perp symbol
  \sbox2{$#1=$}%                 box 2 for the height of =
  \sbox4{$#1\vcenter{}$}%        box 4 for the height of the math axis
  \rlap{\copy0}%                 first \perp
  \dimen@=\dimexpr\ht2-\ht4-.2pt\relax
      % The equals symbol is centered around the math axis.
      % The following equations are used to calculate the
      % right shift of the second \perp:
      % [1] ht(equals) - ht(math_axis) = line_width + 0.5 gap
      % [2] right_shift(second_perp) = line_width + gap
      % The line width is approximated by the default line width of 0.4pt
  \kern\dimen@
  \ifx\\#2\\%
  \else
    \hbox to \wd2{\hss$#1#2\m@th$\hss}%
    \kern-\wd2 %
  \fi
  \kern\dimen@
  \copy0 %                       second \perp
}
\makeatother

\begin{document}
\[ A \indep B \nindep C = D \]
\[ \scriptstyle A \indep B \nindep C = D \]
\[ \scriptscriptstyle A \indep B \nindep C = D\]
\end{document}

Result unicode-math

share|improve this answer
    
When I try to use this solution naïvely (i.e., I haven't had time to figure out what's going on) I'm getting lots of complaints that I'm missing { and } when \nindep is used. Any thoughts as to why? edit: Just noticed that the errors aren't listing the same text as problematic: ./chapters/tutorial.tex:260: Missing { inserted. [$\nindep] ./chapters/tutorial.tex:260: Missing } inserted. [$\nindep$] or ` ./chapters/tutorial.tex:260: Missing { inserted. [[\nindep] ./chapters/tutorial.tex:260: Missing } inserted. [[\nindep]]` (there are 4 of the first and 10 of the latter line), – mpacer May 11 at 3:24
    
@mpacer Generate a minimal example, which shows the problem. This can help you to find the cause of the problem. Otherwise the MWE can then be used in a followup question. – Heiko Oberdiek May 11 at 4:38
    
The only content in the line is $\nindep$, that's why I asked. I have a MWE working, but it doesn't work when embedded in a much larger set of documents that I cannot extract it from. I was hoping you would have some insight as to why the use of \not would expect to see { or } in a way that would break the code above, as the \not seems to be the culprit. Is there anything that modifies the definition of \not to require { and } that you know of off the top of your head? I've looked and am running into lots of dead ends… – mpacer May 11 at 4:48
1  
@mpacer If you have an example, which does not show the problem, then it is not a MWE for this problem. Either strip down the larger document until the unnecessary parts are removed and the then simple document shows the problem or extend the small document until it shows the problem. Maybe a package (unicode-math or whatever) redefines command sequences (e.g., \not), needed by \nindep. – Heiko Oberdiek May 11 at 5:01
1  
@mpacer I have updated the answer with a version for unicode-math. – Heiko Oberdiek May 11 at 16:36

Without packages/commands, here's one option:

enter image description here

$X \not\!\perp\!\!\!\perp Y$

You might be better off considering using the centernot package for negating the symbol. And, if you can't load new packages, copy the required code like below:

enter image description here

\documentclass{article}

\makeatletter
% Taken from http://ctan.org/pkg/centernot
\newcommand*{\centernot}{%
  \mathpalette\@centernot
}
\def\@centernot#1#2{%
  \mathrel{%
    \rlap{%
      \settowidth\dimen@{$\m@th#1{#2}$}%
      \kern.5\dimen@
      \settowidth\dimen@{$\m@th#1=$}%
      \kern-.5\dimen@
      $\m@th#1\not$%
    }%
    {#2}%
  }%
}
\makeatother

\newcommand{\independent}{\perp\mkern-9.5mu\perp}
\newcommand{\notindependent}{\centernot{\independent}}

\begin{document}

$A \notindependent B^{C \notindependent D^{E \notindependent F}}$

$A \independent B^{C \independent D^{E \independent F}}$

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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