Suppose that I have something like:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\noindent
\begin{tikzpicture}
\draw[fill=black!40, draw = black!40, line width=2pt]
(-2, -2.5) rectangle +(\textwidth, 4cm);
\draw (2, -0.3) node[right, text
width=\textwidth-4.5cm] {This is a test as you can see and we put more text to see what happens here and there.};
\draw[red, fill=white, rounded corners = 5pt, line width=10pt]
(30:2cm) -- (150:2cm) -- (270:2cm) -- cycle;
\draw (0, 0.3) node {Hello};
\draw (0, -0.3) node {Goodbye};
\end{tikzpicture}
\end{document}
which produces something like this
I have a grayish box, a figure on the left (with red line, some text, white as filling color) and one block of text. Now if I wish to put the figure on the right hand side of that gray box so it will be exactly the same distance from right hand side of the gray box that it is now horizontally from the left hand side of the gray box, and if I wish to the same thing with the text block (put the text block on the left hand side of that gray box so it will be exactly the same distance from the left hand side of the gray box that it is now horizontally from the right hand side of the gray box), what I have to do?
Best Answer
As Sigur suggested, you can use
scopes
to shift the sign and the text:2nd version:
Although I'd prefer to do it with
nodes
and theirpositioning
capabilities.The sign is a
regular polygon
with 3 sides.Hello
andGoodbye
can be added to it with alabel=center:...
.The
text
is just a regular node which can be placedabove/below right
orabove/below left
from the sign.And the gray background can be drawn after both nodes. You have different options, thanks to
background
tikzlibrary: -show background rectangle
- a filled rectangle on background layer - filledfitting
node (needsfit
tikzlibrary) on background layerNext code shows how I did it. Second picture changes
below left
bybelow right
. That's all.