![desenhe colchetes redondos / retangulares envolvendo nós em tikz](https://rvso.com/image/298819/desenhe%20colchetes%20redondos%20%2F%20retangulares%20envolvendo%20n%C3%B3s%20em%20tikz.png)
Eu sei como desenhar uma chave com o seguinte código:
\draw[decorate,decoration={brace,amplitude=5},-] (0.8,-0.75) -- (0.8,0.75);
Mas agora quero desenhar um colchete ou retangular. Alguém pode dizer como posso fazer isso? É possível fazer isso alterando "brace" para outros valores?
O resultado deve ficar assim: (algumas fotos)
mas não {algumas fotos}
Responder1
Abaixo defino os estilos
square left brace
,square right brace
,round left paren
, eround right paren
que rende:
Notas:
- Isto é simples e adaptação do
ncbar
estilo deExiste um TikZ equivalente ao comando PSTricks \ncbar?.
Código:
\documentclass[landscape]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
%% https://tex.stackexchange.com/questions/55068/is-there-a-tikz-equivalent-to-the-pstricks-ncbar-command
\tikzset{
ncbar angle/.initial=90,
ncbar/.style={
to path=(\tikztostart)
-- ($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)
-- ($(\tikztotarget)!($(\tikztostart)!#1!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztotarget)$)!\pgfkeysvalueof{/tikz/ncbar angle}:(\tikztostart)$)
-- (\tikztotarget)
},
ncbar/.default=0.5cm,
}
\tikzset{square left brace/.style={ncbar=0.5cm}}
\tikzset{square right brace/.style={ncbar=-0.5cm}}
\tikzset{round left paren/.style={ncbar=0.5cm,out=120,in=-120}}
\tikzset{round right paren/.style={ncbar=0.5cm,out=60,in=-60}}
\begin{document}
\begin{tikzpicture}
\draw [red, thick] (0,0) to [square left brace ] (0,4);
\draw [red, thick] (1,0) to [square right brace] (1,4);
\draw [blue, thick] (3,0) to [round left paren ] (3,4);
\draw [blue, thick] (4,0) to [round right paren] (4,4);
\end{tikzpicture}
\end{document}
Responder2
Infelizmente, não há equivalente brace
para parênteses e colchetes definido na biblioteca TikZ decorations.pathreplacing
.
Depende de qual é o seu caso de uso se a recomendação a seguir é sensata ou não, mas uma maneira possível de conseguir algo parecido com o que deseja é fazer uso do\vphantom
truquee o fato de que (
e [
sãodelimitadores.
Aqui, coloquei \left(
e \right)
em seus próprios node
s que são colocados em relação ao principal node
usando a biblioteca TikZ positioning
.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{graphicx}
\usepackage{mwe}
\begin{document}
\begin{tikzpicture}
\node (picture) at (0,0) {\includegraphics[width=.5\textwidth]{image-a}};
\node (left-paren) [left = of picture] {$\left(\vphantom{\includegraphics[width=.25\textwidth]{image-a}}\right.$};
\node (right-paren) [right = of picture] {$\left.\vphantom{\includegraphics[width=.25\textwidth]{image-a}}\right)$};
\end{tikzpicture}
\end{document}