GNOME Bugzilla – Bug 600972
text in boxes not centred vertically when using tex / pgf export
Last modified: 2011-06-10 10:09:32 UTC
Hi, I have recently filed a bug occuring when using pgf export with dia 0.96 : the text in the boxes were not centred horizontally and vertically. [https://bugzilla.gnome.org/show_bug.cgi?id=600418] In dia 0.97 the bug is partially resolved : the text in now perfectly centred horizontally, but not vertically. I have to manually add [anchor=base] to every node in the pgf export. Step to reproduce the bug : 1. Draw any box with text centred horizontally and vertically 2. Export using tex/pgf export 3. Include the pgf export in a tex document and compile it using pdflatex. Actual results: --> In the pdf, the text in the box is centred horizontally but not vertically Expected results: --> Text hould be centred vertically and horizontally Does this happen every time? --> Yes The bug is not really annoying as it can be overcome very easily. I'm using ubuntu 9.04
Created attachment 147106 [details] The drawing as it looks like in Dia.
Created attachment 147107 [details] The corrected tex file to have a vertically centred text.
So you are using horizontally centered text and I have not made myself clear enough in the recent comment in bug #600418. For left- or right-aligned text Dia already writes anchor=west or anchor=east. How is that to be combined with anchor=base?
I do some testing of the pgf export and there is no way to combine west or east with base... So you're right, my workaround only works with horizontally centred text... I've done some testing and I've found another workaround. In the dia file, if the text is vertically aligned using 'First line' (translation form french, not sure if it's the same in english, it's the last choice you can make in the list of vertical alignement options), the text is vertically centred in the pdflatex output. Wierd ! Can this issue be related to the way the pgf export "calculate" the coordinates of the node text ? Tell me if you need more information PS : I've also done some testing with text on 2 lines with 'centred' and 'first line' vertical alignement and the text is never vertically centred. I don't know if it's a related issue... Let me know if I can help in anyway Thanks again for all the great work with dia!
First line aligns the text with it's connection point at the base line. Seems like exactly what you want and not a work-around at all. Some slight difference between display and export might result from font difference.
(In reply to comment #5) > First line aligns the text with it's connection point at the base line. Seems > like exactly what you want and not a work-around at all. Ok but it's wierd because in dia, the text is not centred vertically. Why it is in latex ?? > Some slight difference between display and export might result from font difference. I am sure it's part of the problem. I've done some testing with text boxes with various size. The text is always put X pixel down. The X doesn't change at all. It's not multiplicated by ay factor. The discrepancy is not scaled (not sure if i'm really clear here...!). I will try with several fonts to find one that match closely latex one. thanks for all your answers !
Hi, I had the same vertical alignment problems in FlowChart rectangle box when exporting to PGF. digging into Dia code, into PGF doc and with additionnal tests I got to a solution working in all the cases you mentionned and also for two or more lines of text. However, it may require some more testing. One cannont change how Dia "weirdly" computes the text position as this position seems to work well for other export plugins but one can change how PGF handles it. anchor=base west or anchor= base east combination seems to work for my pgf version (2.00-1). Stanislas had the same solution but I don't know why the combination base west did not work for him (what was his version ?) so adding a base in any anchor (even when alignment is CENTER) could do the job for vertical centering and this also corrects basic text (not in flowchart boxes) positionning according to other objetcts (see attachements). I also had horizontal positionning problems that seem to come from inner and outer padding added by PGF. Setting inner sep = 0pt and outer sep=0pt for each node does the trick. In attachement is my alignment dia file, a picture how it looks like in dia, 3 tex files (orig with version 0.97-1, corr with anchor base added everywhere and corr2 with anchor + inner sep and outer sep = 0pt) and an output test pdf rendered with pdflatex with 3 corresponding pages. The last page matches the most how dia rendering looks like. also attached is the patch. This is my first "complex" bug report + patch proposal, please be kind and explain me any mistakes in the procedure if any.
Created attachment 166122 [details] GuiHome_alignment_dia_file
Created attachment 166123 [details] GuiHome_alignment_test orig tex output
Created attachment 166124 [details] GuiHome_alignment_test corr tex output
Created attachment 166125 [details] GuiHome_alignment_test corr2 tex output
Created attachment 166126 [details] GuiHome_alignment_test pdf output
Created attachment 166127 [details] GuiHome_alignment_test dia render
Created attachment 166128 [details] [review] GuiHome proposed patch
(In reply to comment #7) > This is my first "complex" bug report + patch proposal, please be kind and > explain me any mistakes in the procedure if any. Patch looks fine, I've just pushed to master: http://git.gnome.org/browse/dia/commit/?id=5c1fccd7489e4248e0f453f5665b78a4aaa71062 Thanks and sorry for the delay.