vertical equality in

How does one get inline or at least formula space typography of the following sort in an easy to parse (for the editor) way when writing formulas, for instance:

Yes, I know, the equalities ... can be done within TikZ for commuting diagrams, like with arrows. But is there an easy way to just to use vertical equalities (and most importantly, inequalities) in this way in simple formulas, without invoking a TikZ frame, in ordinary latex math $...$.

EDIT:

I should just clarify, I meant the above image as an example. Some great solutions were posted, but how can they be generalized to allow for more or fewer levels or nested together, so that they can be robustly used without changing the basic grid above below to left to right relative framework (and thus avoiding driving the editor of a paper or coauthor mad)? For instance, also:

Most clearly: how can stacks or macros be used to create in line or in formula "above" "below" arbitrary equalities/inequalities that ignore other levels above and below?

My own attempt, which doesn't quite work, since columns cannot overlap sideways in matrices, and yet they have to look good, and the same problem with the macro approach, and of course a matrix cannot be subscript size:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsmath}
\usepackage{adjustbox}

\newcommand{\veq}{\mathrel{\rotatebox{90}{$=$}}}
\newcommand{\vneq}{\mathrel{\rotatebox{90}{$\neq$}}}

\begin{document}

This is a test. Yes it is. Of course. Look here. Yes, Here. That's right. Mhmm. Words. Filler. Indeed. Look. A paragraph. With words. Here. Yes. And where's that? Where is here? It's right here:

$\left. \frac{\partial f(A,B,C,D)}{\partial A} \right| \raisebox{.9\baselineskip}{_{\begin{array}{ccccc} A & = & B & = & Z \\ {} & {} & \vneq & {} & {} \\ C & \neq & I & \neq & W \\ \veq & {} & {} & {} & {} \\ D & = & G & \neq & Q^2+3 \end{array} }}$

\end{document}


2 Answers

Relatively straightforward with stacks. In essence, the vertical equality is the \tabbedCenterstack, using rotated equality signs \req and \rne.

For the first example, I just used a conventional stack, though for the more complex examples, a full tabular stack makes it easiest.

\documentclass{article}
\usepackage{tabstackengine}
\stackMath
\makeatletter
\renewcommand\TAB@delim[1]{\scriptstyle#1}
\def\req{\protect\rotatebox{90}{$\scriptstyle=$}}
\def\rne{\protect\rotatebox{90}{$\scriptstyle\ne$}}
\makeatother
\usepackage{graphicx}
\begin{document}
$\setstackgap{L}{.6\baselineskip} \left.\frac{\partial f(A,B,C,D)}{\partial A}\right| \raisebox{.9\baselineskip}{_{A = \tabbedCenterstack{C\\ \req\\0\\ \rne\\ D} \ne B}}$

$\setstackgap{L}{.6\baselineskip}\setstacktabulargap{0pt}\TABbinary \left.\frac{\partial f(A,B,C,D)}{\partial A}\right| \raisebox{-.2\baselineskip}% {_{\tabularCenterstack{rcl}{A = & 0&\\ &\req&\\&D& \ne B = C}}}$

$\setstackgap{L}{.6\baselineskip}\setstacktabulargap{0pt}\TABbinary \left.\frac{\partial f(A,B,C,D)}{\partial A}\right| \raisebox{.9\baselineskip}% {_{\tabularCenterstack{rcl}{L = & 0&\\ &\req&\\A = &0& \ne B = F\\ &\rne&\\ &D&\ne B\\&\rne&\\&E&}}}$
\end{document}


Note: the \TABbinary is not needed in \scriptstyle, but would be needed in \displaystyle, to place the proper spacing around the relational operators that appear immediately after a &.

• Thank you for introducing the package. Trying out various things now. But how do I install the tabstackengine package permanently ? I have the .sty file but where must I place it if I permanently install it? Right now I just put in a folder with the tex file. – Guido Jorg May 14 '14 at 22:19
• Also, is there a way to expand the macro for more/fewer levels up and horizontally, to make this a more robust solution? I'll clarify the first post with a better picture, since I meant this one as a general example. – Guido Jorg May 14 '14 at 22:38
• @GuidoJorg As to your question about installation, each version of LaTeX stores local downloads in a different directory, which you would need to know to install permanently. For MikTeX, for example, that directory, by default, is C:\Users\(Your-username)\AppData\Roaming\MiKTeX\2.9\tex\latex. After locating the new files in such a directory, then (in the case of MikTeX), the filename database (FNDB) must be updated. At that point it is ready for use. I will now tackle your 2nd question. – Steven B. Segletes May 14 '14 at 23:37
• @GuidoJorg Please see revision. – Steven B. Segletes May 14 '14 at 23:52
• Very nice! Will be working with this. – Guido Jorg May 15 '14 at 2:14

You can define a custom macro to do this for you:

The \mathclap was added to ensure that cases of wide text is handled properly:

Code:

\documentclass{article}
\usepackage{graphicx}
\usepackage{mathtools}
\usepackage{adjustbox}

\newcommand{\veq}{\mathrel{\rotatebox{90}{$=$}}}
\newcommand{\vneq}{\mathrel{\rotatebox{90}{$\neq$}}}
\newcommand*{\VerticalRelations}[5]{%
% #1 = center
% #2 = above
% #3 = symbol above
% #4 = below
% #5 = symbol below
\adjustbox{stack=cc}{%
\ensuremath{#2}\\%
\ensuremath{\mathclap{#3}}\\%
\ensuremath{#1}\\%
\ensuremath{#5}\\%
\ensuremath{\mathclap{#4}}%
}%
}%
\begin{document}
$A = \VerticalRelations{0}{C}{\veq}{D}{\vneq} \neq B$
and check appropriate spacing for longer above" and below" text:
$A = \VerticalRelations{0}{C}{\veq}{D\neq B}{\vneq} \neq B$
\end{document}

• How do I avoid the centering of the lines when I replace let's say D with D not equals B, like in: [ A = \VerticalRelations{0}{C}{\veq}{D\neq B}{\vneq} \neq B ] ? Also, is there a way to expand the macro for more/fewer levels up and horizontally, to make this a more robust solution? – Guido Jorg May 14 '14 at 22:36
• @GuidoJorg: Had updated solution to ensure that that case is properly handled. – Peter Grill May 15 '14 at 6:54
• very nice! will work a bit with the macro, too, though the first answer seems to be more robust, this is one of those cases were I'd like to give an acceptance to both answers. **** Is there a way to make the D shifted underneath the vneq and the below the other B? \hspace doesn't really work. (I'll work with this some more, maybe post a separate question about it, or add a comment here how to do it, if I figure it out.) – Guido Jorg May 15 '14 at 12:35
• The \mathclap{} command is very useful in general I have to say – Guido Jorg May 15 '14 at 12:45