TransWikia.com

Square bracket indicating "A or B or C"

TeX - LaTeX Asked by Cathy on February 2, 2021

How can I write $A.B.C=0$ equivalent to $A=0$ or $B=0$ or $C=0$ in this form?

I am a newbie in latex. I would like to write an expression such as the following
enter image description here

How can I do that? Thank you very much!

3 Answers

Second attempt. Thanks go to Steven B. Segelets for communicating to me that the first attempt was not what the author wanted.

documentclass{article}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{tikzmark}
begin{document}
[Acdot Bcdot C=0quadLongleftrightarrowquadhspace{1ex}
begin{aligned}
tikzmarknode{A}{A}&=0 tikzmarknode{B}{B}&=0 tikzmarknode{C}{C}&=0
end{aligned}
begin{tikzpicture}[overlay,remember picture]
 draw[semithick] ([xshift=-2pt]A.west) -- ++ (-1ex,0) |- ([xshift=-2pt]C.west)
  ([xshift=-2pt]A.west|-B) -- ++ (-1ex,0);
end{tikzpicture}
]
end{document}

enter image description here

Answered by user230294 on February 2, 2021

Here is a solution that allows any number of choices for the bracket:

enter image description here

The call for this output is orbrace[.5]{A=0,B=0,C=0,D=0}

The command orbrace takes 2 arguments, one optional. The optional .5 is the spacing in cm between each option (default is 1). The required comma-separated list gives the options to be typeset in math mode.

Here is the code:

documentclass{article}

usepackage{tikz}


newcommand{orbrace}[2][1]{begin{tikzpicture}[line cap=round, semithick, baseline={([yshift=-.88mm]current bounding box.center)}]
    foreach[var=x, count=m] in {#2}{
    ifnum m>1 draw(0,-m*#1) -- ++(0,#1); fi
    draw (0,-m*#1) -- ++(.1,0) node[right] {$x$};
    }
    end{tikzpicture}}

begin{document}

[
A.B.C.D=0 Leftrightarrow orbrace[.5]{A=0,B=0,C=0,D=0}
]

end{document}

Answered by Sandy G on February 2, 2021

I decided to put this in a second post for clarity. It is an attempt to combine the virtues of the existing answers, namely the convenience of Sandy G's post and the alignment of the baseline and the equality signs of my own. Now you can add a complete set of options, but for internal reasons and the ability to use this also in beamer you need to use & instead of &. And, unlike in ordinary aligned environments where this is sort of optional you cannot swallow the final . Other than that you can use the aligned syntax.

documentclass{article}
usepackage{amsmath}
usepackage{tikz}
usetikzlibrary{matrix,tikzmark}
tikzset{aligned/.cd,h/.initial=1ex,
    lines/.code={tikzset{aligned/linestyle/.append style={#1}}},
    linestyle/.style={line cap=round,line join=round,semithick}}
newcommand{AlignedTikZ}[2][]{begin{tikzpicture}[baseline={(tmpbase.base)},
    aligned/.cd,#1]
matrix[matrix of math nodes,cells={nodes={inner xsep=.1111em}},
    column 1/.style={nodes={anchor=base east}},
    ampersand replacement=&] (tmpmat) {#2};
pgfmathtruncatemacro{mybaserow}{(pgfmatrixcurrentrow+1)/2}
ifoddpgfmatrixcurrentrow  
path (tmpmat-mybaserow-1.base) node[anchor=base] (tmpbase){};
else
path (tmpmat-thenumexprmybaserow+1relax-1.base) --
 node[anchor=base] (tmpbase){}
(tmpmat-mybaserow-1.base);
fi
draw[aligned/linestyle] foreach X in {1,...,pgfmatrixcurrentrow}
{(tmpmat.west|-tmpmat-X-1) -- ++ (-pgfkeysvalueof{/tikz/aligned/h},0)}
([xshift=-pgfkeysvalueof{/tikz/aligned/h}]tmpmat.west|-tmpmat-1-1) --
([xshift=-pgfkeysvalueof{/tikz/aligned/h}]tmpmat.west|-tmpmat-thenumexprpgfmatrixcurrentrowrelax-1);
end{tikzpicture}}
begin{document}
[
Acdot Bcdot C=0 quadLongleftrightarrowquad 
AlignedTikZ{A&=0 B&=0 C&=0}
]

[
Acdot Bcdot C=0 quadLongleftrightarrowquad 
AlignedTikZ[lines={thick,blue}]{A&=0 B&=0 C&=0}
]

[
Acdot B_1cdot C_{12}=0 quadLongleftrightarrowquad 
AlignedTikZ{A&=0 B_1&=0 C_{12}&=0}
]

[
Acdot B_1cdot C_{12}cdot D=0 quadLongleftrightarrowquad 
AlignedTikZ{A&=0 B_1&=0 C_{12}&=0 D&=0}
]

end{document}

enter image description here

The appearance can be controlled by pgf keys. If you want to change the lengths of the horizontal bars, just add h=1em, say to the options. If you want to add features this can be done, too, without losing backwards compatibility.

Answered by user230294 on February 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP