0

Im confused at a very basic problem. My aim is to draw a brace, however make the brace look rectangular

I draw a path/line from start A to end B with some lines at the beginning and end to form the end of the bracket. Now i want to draw a line located at the center of the bracket like this:

enter image description here

To achieve this I use a very naive form in creating one node in the midway of the path and another node with a negative xshift and then draw a path connecting these two nodes:

\documentclass{article}
\usepackage{tikz,amsmath, amssymb,bm,color}
\usepackage[active,tightpage]{preview}
\usepackage[margin=0cm,nohead]{geometry}
\usetikzlibrary{shapes,arrows}
\usepackage{tikz-3dplot}
% needed for BB
\usetikzlibrary{calc}
\PreviewEnvironment{tikzpicture}
\begin{document}

\begin{tikzpicture}

\draw(-.7,0,3) to (-1,0,3) to node (mid){mid} node [xshift=-3cm](midleft) 
{midleft} (-1,3,3) to (-.7,3,3);
\draw (mid.center) to (midleft);

\end{tikzpicture}

\end{document}

Is there an easier alternative to draw a path and "using" the centerpoint of this path by say someting like path.center? Many thanks in advance.

2

Not sure if this is what you need but here is a way to compute the middle point using the calc library or also with the explicit positioning of the node.

\documentclass[tikz]{standalone}
\usetikzlibrary{calc}

\begin{document}

% Solution 1 with calc
\begin{tikzpicture}
\coordinate (A) at (-0.7,0,3);
\coordinate (B) at (-0.7,3,3);
\coordinate (M) at ($(A)!0.5!(B)+ (-0.3,0)$);
\coordinate (L) at ($(M)+ (-0.5,0) $);
\draw (A) --++ (-0.3,0,0) -- (M) ;
\draw (B) --++ (-0.3,0,0) -- (M);
\draw (M) -- (L);
\end{tikzpicture}

% Solution 2 with midway node positioning
\begin{tikzpicture}
\coordinate (A) at (-0.7,0,3);
\coordinate (B) at (-0.7,3,3);
% Option pos=0.5 can be replaced by midway
\draw (A) --++ (-0.3,0,0) --++ (0,3,0)  node[pos=0.5,inner sep=0pt,outer sep=0pt](M){} -- (B);
\draw (M) --++ (-0.5,0,0);
\end{tikzpicture}
\end{document}
  • Many thanks for your answer. Oh that seems also a little bit complex. I may then remain at my naive solution, i thought there was maybe a simple command I was missing for this. However thank you! – SRel Aug 8 '18 at 13:09
  • As far as I know, there is an easy way to draw braces in tikz with decorations, but not bracket-like braces – BambOo Aug 8 '18 at 13:19

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.