# How to resize a line with the text height with TikZ?

I made a new style of quoting. But I have to put the line height and width of the quote manually. Someone have a solution for make a environment with just 2 or 3 parameters? The quote, the author and the width of the quote environment?

Here is my code:

\def\linesize{1.50} % The height of my line
\begin{tikzpicture}
\draw[gray!75] (0,0) -- (0,\linesize);
\draw[gray!75] (0,0.5*\linesize) node [right] {Alfred de Musset};
\draw (0,0.5*\linesize) node [left] {%
\begin{minipage}{0.25\textwidth}
\begin{flushright}
Entre presque oui et oui, il y a tout un monde.
\end{flushright}
\end{minipage}
};
\end{tikzpicture}


And a second question, how to choose the text position of my quote? (right, left of the center line) all this in an environment?

-

## 1 Answer

Luckily TikZ processes the content of nodes as box so you can exchange the { .. } with \bgroup .. \egroup and split the picture there, so it is placed in a \begin{..} and \end{..}. The linesize parameter can also be added as argument or simply calculated from the quote size.

\documentclass{article}

\usepackage{tikz}

\def\linesize{1.50} % The height of my line
\newenvironment{myquote}[2]{%
\begin{tikzpicture}
\draw[gray!75] (0,0) -- (0,\linesize);
\draw[gray!75] (0,0.5*\linesize) node [right] {#2};
\draw (0,0.5*\linesize) node [left] \bgroup
\begin{minipage}{#1}%
\begin{flushright}%
}%
{%
\end{flushright}%
\end{minipage}%
\egroup;
\end{tikzpicture}
}

\begin{document}

\begin{myquote}{.5\textwidth}{A.U.~Thor}
A quote is a quote is a quote!
\end{myquote}

\end{document}


Here an advanced version which doesn't require \linesize and uses more of the TikZ parameter instead of manual environments:

\newenvironment{myquote}[2]{%
\begin{tikzpicture}
\draw [gray!75] node [right] {#2};
\node (QUOTE) [left,text width={#1},text ragged left] \bgroup
}%
{%
\egroup;
\draw [gray!75]
([yshift=5pt]QUOTE.north east) -- ([yshift=-5pt]QUOTE.south east);
\end{tikzpicture}
}


To change the quote the the right side instead you would need to change left to right and vice versa as well es change east to west in the second implementation. You could define your own options to do this, but this would be a little overkill. I would just define the environment again e.g. as star version, which uses the same definition but with that values exchanged.

-
Thanks ! It's perfect :D –  iDavid Jul 3 '11 at 20:43