2

€dit - New Text:

I have some content (pgfplotstable and some text) and would like to add a square brace on the left side, like this is a "bmatrix".

What is the best way to do that?
What have I to do? Using tikzmark or tikzmarknode or...?

€dit - NEW MWE, but not nice implemented at all...

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usepackage{pgfplotstable}


\begin{document}
\noindent\tikzmarknode[]{OL}{} \\
Hello World. \\
\pgfplotstabletypeset[]{
1 2 3
4 5 6
7 8 9
} \\[0.1em]
Goodbye World. \\[-3mm]
\tikzmarknode[]{UL}{}


\tikz[overlay,remember picture, red, transform canvas={xshift=-3pt}]{
\draw  (OL.center) -- +(1ex,0);
\draw (UL.center) -- +(1ex,0);
\draw[line cap=rect, blue] (OL.center) -- (UL.center);
}
\end{document}
  • You probably want to use \tikzmark and not \tikzmarknode. However, I am not sure since I do not understand "Because of pgfplotstable-content and so on, it should be tikzmark, not the normal way in the math-mode." What does that mean? BTW, what is the purpose of transform canvas={xshift=-3pt} (instead of just xshift=-3pt)? Also the gaps between the red and blue line can be avoided with line cap=rect. – Schrödinger's cat Dec 15 '19 at 17:12
  • Try with line cap=rect on the blue line. – Torbjørn T. Dec 15 '19 at 17:14
  • \documentclass{article} \usepackage{tikz} \usetikzlibrary{tikzmark} \begin{document} \noindent\tikzmarknode{OL}{\rule{5cm}{4cm}} \tikz[overlay,remember picture, red]{\draw ([xshift=-3pt,yshift=3pt]OL.north west)--++(1ex,0) ([xshift=-3pt,yshift=-3pt]OL.south west)--++(1ex,0) ([xshift=3pt,yshift=3pt]OL.north east)--++(-1ex,0)([xshift=3pt,yshift=-3pt]OL.south east) -- ++(-1ex,0); \draw[blue,line cap=rect] ([xshift=-3pt,yshift=3pt]OL.north west)--([xshift=-3pt,yshift=-3pt]OL.south west) ([xshift=3pt,yshift=3pt]OL.north east)--([xshift=3pt,yshift=-3pt]OL.south east);} \end{document} – Schrödinger's cat Dec 15 '19 at 17:28
  • New MWE! ................................................ – cis Dec 15 '19 at 17:43
4
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplotstable}
\newsavebox\cistable

\begin{document}
\begin{lrbox}{\cistable}
\pgfplotstabletypeset[]{
1 2 3
4 5 6
7 8 9
} 
\end{lrbox}%
\noindent\begin{tikzpicture}
\begin{scope}[local bounding box=OL]
 \path node(tab){\usebox{\cistable}}
 (tab.north) node[above] {Hello World.} 
  (tab.south) node[below] {Goodbye World.};
\end{scope} 
\draw[red] ([xshift=-3pt,yshift=3pt]OL.north west) -- ++(1ex,0)
 ([xshift=-3pt,yshift=-3pt]OL.south west) -- ++(1ex,0)
 ([xshift=3pt,yshift=3pt]OL.north east) -- ++(-1ex,0)
 ([xshift=3pt,yshift=-3pt]OL.south east) -- ++(-1ex,0);
\draw[blue,line cap=rect] 
([xshift=-3pt,yshift=3pt]OL.north west) -- ([xshift=-3pt,yshift=-3pt]OL.south west)
([xshift=3pt,yshift=3pt]OL.north east) -- ([xshift=3pt,yshift=-3pt]OL.south east);
\end{tikzpicture}
\end{document}

enter image description here

  • Mmmh, with content --> savebox --> tikz-node I understand and would know how to do. And there is no way with tikzmark? – cis Dec 15 '19 at 18:00
  • @cis There certainly is but the savebox it is IMHO the easiest way to control all distances precisely. – Schrödinger's cat Dec 15 '19 at 18:04
  • 2
    @cis With \savebox you also only need a single run for all things to fall into the right place. – Henri Menke Dec 15 '19 at 23:54
  • @cis In addition to what Henri is saying with this method you have full control over whether or not the braces are drawn in overlay mode. It makes IMHO more sense to not use overlay here because you may not want them to run over other stuff or the page border. – Schrödinger's cat Dec 16 '19 at 6:42
  • With savebox there should be a method for $\left[ \mysavebox \right.$. The colors has been for illustraion, not an aim. – cis Dec 16 '19 at 6:52

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.