2

I would like to add in my tikz picture a parenthesis like this :

parenthesis to add

I have already tried adding a \[\left( before and a \right)\] around the tikzpicture.

But it doesn't give the desired result:

enter image description here

Here's my code :

\documentclass{article}

\usepackage{tikz} \usetikzlibrary{patterns} \usetikzlibrary{decorations.pathreplacing,angles,quotes}

% defining the new dimensions and parameters \newlength{\hatchspread} \newlength{\hatchthickness} \newlength{\hatchshift} \newcommand{\hatchcolor}{} % declaring the keys in tikz \tikzset{hatchspread/.code={\setlength{\hatchspread}{#1}}, hatchthickness/.code={\setlength{\hatchthickness}{#1}}, hatchshift/.code={\setlength{\hatchshift}{#1}},% must be >= 0 hatchcolor/.code={\renewcommand{\hatchcolor}{#1}}} % setting the default values \tikzset{hatchspread=10pt, hatchthickness=0.4pt, hatchshift=0pt,% must be >= 0 hatchcolor=black} % declaring the pattern \pgfdeclarepatternformonly[\hatchspread,\hatchthickness,\hatchshift,\hatchcolor]% variables {custom north west lines}% name {\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner {\pgfqpoint{\dimexpr\hatchspread+2\hatchthickness}{\dimexpr\hatchspread+2\hatchthickness}}% upper right corner {\pgfqpoint{\dimexpr\hatchspread}{\dimexpr\hatchspread}}% tile size {% shape description \pgfsetlinewidth{\hatchthickness} \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\hatchspread+\hatchshift}} \pgfpathlineto{\pgfqpoint{\dimexpr\hatchspread+0.15pt+\hatchshift}{-0.15pt}} \ifdim \hatchshift > 0pt \pgfpathmoveto{\pgfqpoint{0pt}{\hatchshift}} \pgfpathlineto{\pgfqpoint{\dimexpr0.15pt+\hatchshift}{-0.15pt}} \fi \pgfsetstrokecolor{\hatchcolor} % \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way \pgfusepath{stroke} }

\begin{document}

\begin{center} \begin{tikzpicture} \draw fill=orange!50,draw=black rectangle (0.2,10); \draw[pattern=custom north west lines] (0,6) rectangle (0.2,7); \draw fill=orange!50,draw=black rectangle (0.2,6);

\draw fill=orange!50,draw=black rectangle (2.2,10); \draw[pattern=custom north west lines] (2,6) rectangle (2.2,7); \draw fill=orange!50,draw=black rectangle (2.2,6);

\draw fill=orange!50,draw=black rectangle (4.2,10); \draw[pattern=custom north west lines] (4,6) rectangle (4.2,7); \draw fill=orange!50,draw=black rectangle (4.2,6); \end{tikzpicture}

\end{center}

\end{document}

Does anyone have an idea? Thank you in advance !

RedWest
  • 65
  • were you able to solve your earlier question -- https://tex.stackexchange.com/questions/581384/which-latex-package-is-able-to-create-graphics – js bibra Feb 14 '21 at 12:13

1 Answers1

2

Define a suitable baseline of the picture. The parentheses \left(...\right) extend as far below the baseline as the object is high. Use e.g.

 \begin{tikzpicture}[baseline={(0,4.9)}]

For a pure tikz solution, see "draw round/rectangular bracket embracing nodes in tikz".

enter image description here

\documentclass{article}

\usepackage{tikz} \usetikzlibrary{patterns} \usetikzlibrary{decorations.pathreplacing,angles,quotes}

% defining the new dimensions and parameters \newlength{\hatchspread} \newlength{\hatchthickness} \newlength{\hatchshift} \newcommand{\hatchcolor}{} % declaring the keys in tikz \tikzset{hatchspread/.code={\setlength{\hatchspread}{#1}}, hatchthickness/.code={\setlength{\hatchthickness}{#1}}, hatchshift/.code={\setlength{\hatchshift}{#1}},% must be >= 0 hatchcolor/.code={\renewcommand{\hatchcolor}{#1}}} % setting the default values \tikzset{hatchspread=10pt, hatchthickness=0.4pt, hatchshift=0pt,% must be >= 0 hatchcolor=black} % declaring the pattern \pgfdeclarepatternformonly[\hatchspread,\hatchthickness,\hatchshift,\hatchcolor]% variables {custom north west lines}% name {\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner {\pgfqpoint{\dimexpr\hatchspread+2\hatchthickness}{\dimexpr\hatchspread+2\hatchthickness}}% upper right corner {\pgfqpoint{\dimexpr\hatchspread}{\dimexpr\hatchspread}}% tile size {% shape description \pgfsetlinewidth{\hatchthickness} \pgfpathmoveto{\pgfqpoint{0pt}{\dimexpr\hatchspread+\hatchshift}} \pgfpathlineto{\pgfqpoint{\dimexpr\hatchspread+0.15pt+\hatchshift}{-0.15pt}} \ifdim \hatchshift > 0pt \pgfpathmoveto{\pgfqpoint{0pt}{\hatchshift}} \pgfpathlineto{\pgfqpoint{\dimexpr0.15pt+\hatchshift}{-0.15pt}} \fi \pgfsetstrokecolor{\hatchcolor} % \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way \pgfusepath{stroke} }

\begin{document}

\begin{center} $\left(\quad\begin{tikzpicture}[baseline={(0,4.9)}] \draw fill=orange!50,draw=black rectangle (0.2,10); \draw[pattern=custom north west lines] (0,6) rectangle (0.2,7); \draw fill=orange!50,draw=black rectangle (0.2,6);

\draw fill=orange!50,draw=black rectangle (2.2,10); \draw[pattern=custom north west lines] (2,6) rectangle (2.2,7); \draw fill=orange!50,draw=black rectangle (2.2,6);

\draw fill=orange!50,draw=black rectangle (4.2,10); \draw[pattern=custom north west lines] (4,6) rectangle (4.2,7); \draw fill=orange!50,draw=black rectangle (4.2,6); \end{tikzpicture}\quad\right)$

\end{center}

\end{document}

gernot
  • 49,614