I'm new to TikZ, and I'm trying to solve a problem which should be easy, I found many related examples but none helped me.
Given the following MWE:
\documentclass{article}
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage[paperwidth=99mm,paperheight=71mm,margin=0mm,showframe]{geometry}
\usepackage{tikz}
\usepackage[graphics,tightpage,active]{preview}
\PreviewEnvironment{tikzpicture}
\thispagestyle{empty}
\tikzstyle{every node}=[font=\small]
\begin{document}
\begin{tikzpicture}
\draw plot[only marks, mark=+] coordinates{(-23.3mm, 18.6mm) (-23.3mm, 10.8mm) (-23.3mm, 2.3mm ) (-23.3mm, -5.9mm ) (-23.3mm, -14.2mm) (-23.3mm, -14.2mm) (-23.3mm, -22.2mm)};
\draw (-23.3mm, 18.6mm) node[anchor=west, text width=60.3mm ]{A. This is quite short.};
\draw (-23.3mm, 10.8mm) node[anchor=west, text width=60.3mm ]{B. This is already a bit longer, it should be on two lines.};
\draw (-23.3mm, 2.3mm) node[anchor=west, text width=60.3mm ]{C. This is really the longest of all blocks and it will span a whole number of three lines!!!};
\draw (-23.3mm, -5.9mm) node[anchor=west, text width=60.3mm ]{D. This is short};
\draw (-23.3mm, -14.2mm) node[anchor=west, text width=60.3mm ]{E. This is long but not too much but should again span two lines.};
\draw (-23.3mm, -22.2mm) node[anchor=west, text width=60.3mm ]{F. This is short.};
\end{tikzpicture}
\end{document}
I would like
- the text blocks to be as aligned as possible to the
+anchors, usinganchor=west. - a minimum vertical space between blocks, which overrides the previous condition: if necessary, adjacent blocks should be displaced vertically to make room for three-lines blocks.
The preferred anchors positions, text width, image size and font are all fixed.
In the example, B should be moved up a bit, to make room for C.
The issue is that I want to automate this over several images, with different sets of text blocks, and I do not know in advance whether/where the three-line blocks will be (however I can make sure I do not have neighboring three-line blocks).
Note that if all blocks had three lines I would get out of the margins, so I cannot simply set a minimum height for all blocks. However I'm sure I have 6 blocks per image, only 1 or 2 are long, and they're not adjacent.
Note: I'm using XeLaTeX
Feel free to guess what I'm trying to do :)




positioninglibrary in the manual. – percusse May 31 '13 at 20:44