From ifinvers at ucalgary.ca Wed Sep 6 14:56:32 2006 From: ifinvers at ucalgary.ca (Ivars Finvers) Date: Wed, 6 Sep 2006 12:56:32 -0600 Subject: [Tioga-users] font size change using tex_preview_fontsize results in incorrect label positioning Message-ID: <0453B1A0-F016-4F59-B04E-79DEE11071AE@ucalgary.ca> Hi, I tried to use the command tex_preview_fontsize to change the font size of the axis labels on my plots. The result is that the axis labels are of the correct size, but are incorrectly placed. If the new font size is larger than 10pt, the labels can partially overlap the axes. The problem is that the fontsize of the text is changed, but its location isn't. Looking into the .txt file which contains the text placement commands such as: \put(96,435){\scalebox{0.70}{\makebox(0,0)[cc]{\tiogasetfont{-0.10}}}} the \makebox command uses a [cc] location option, meaning that the text is center both horizontally and vertical at the specified point. As the text size changes, the text will grow equally in all directions. Therefore the y-axis label eventually overlap the y-axis. A quick fix is to change the location options to [rc] (horizontally right-aligned, vertically centered) for the left y-axis labels and [ct] for the bottom x-axis. In this way, the labels will grow in size away from the axis. Unfortunately the labels often collide with the axis title text. There is no easy fix for this other than manually changing the title's location in the \put command. To me, it appears that fontsize changes must be accounted for by the routine that generates the \put commands for the .txt file. And this routine must know the true size of the text that is being placed (possibly by running tex for each text fragment and reading extracting the box size -- ugly!). The reason I'm using the fontsize command is that I want to generate a figure whose absolute size is controlled and whose fontsize is identical to the accompanying article text. For example, I want a final pdf whose bounding box is 3in wide and the text font is Times at 12pt. So far I haven't succeeded in doing this. I'm using Tioga 1.14. Ivars From vincent.fourmond at 9online.fr Wed Sep 6 17:02:09 2006 From: vincent.fourmond at 9online.fr (Vincent Fourmond) Date: Wed, 06 Sep 2006 23:02:09 +0200 Subject: [Tioga-users] font size change using tex_preview_fontsize results in incorrect label positioning In-Reply-To: <0453B1A0-F016-4F59-B04E-79DEE11071AE@ucalgary.ca> References: <0453B1A0-F016-4F59-B04E-79DEE11071AE@ucalgary.ca> Message-ID: <44FF3751.6070608@9online.fr> Hello ! > A quick fix is to change the location options to [rc] (horizontally > right-aligned, vertically centered) for the left y-axis labels and > [ct] for the bottom x-axis. This probably should be made default for the next versions of Tioga. I'll have a look at that when I can. > In this way, the labels will grow in size > away from the axis. Unfortunately the labels often collide with the > axis title text. There is no easy fix for this other than manually > changing the title's location in the \put command. What about the f.ylabel_shift=. That really seems to do what you want. > To me, it appears that fontsize changes must be accounted for by the > routine that generates the \put commands for the .txt file. And this > routine must know the true size of the text that is being placed > (possibly by running tex for each text fragment and reading > extracting the box size -- ugly!). This is way too complex to implement - and you wouldn't want to wait five minutes for one figure just because we need to launch LaTeX dozens of times, followed by gv (or similar) dozens of times to get the PDF's bounding box... > The reason I'm using the fontsize command is that I want to generate > a figure whose absolute size is controlled and whose fontsize is > identical to the accompanying article text. For example, I want a > final pdf whose bounding box is 3in wide and the text font is Times > at 12pt. So far I haven't succeeded in doing this. I agree that this is something difficult to do. If you want that all text is the same size as you article (say 12), try that: xaxis_numeric_label_scale = 1.0 (to make sure the axis ticks is at the right scale); the same for y. You might want to have a look at all _scale functions available in Tioga if you still have text with not the right scale (look in the .txt file, it should be fairly straightforward to find). If you en up with too many ticks, you can start to play with xaxis_locations_for_major_ticks and the like, but I agree it will be a little tedious. I'll need Then, you need to make sure that the Tioga font is what you want. For that, make sure you are including the figure in your article with \tiogafigureshow and try \settiogafontsize{12.0}[12pt] and you'll probably need to fiddle with \settiogafontfamily, but I can't remember how to use times with that. (JJ, any ideas ?) I'll be glad to know if you succeeded or not, and in both cases what you did. Thanks for raising the question, and thanks for you interest in Tioga ! Vincent From paxton at kitp.ucsb.edu Wed Sep 6 20:12:52 2006 From: paxton at kitp.ucsb.edu (Bill Paxton) Date: Wed, 6 Sep 2006 17:12:52 -0700 Subject: [Tioga-users] font size change using tex_preview_fontsize results in incorrect label positioning In-Reply-To: <0453B1A0-F016-4F59-B04E-79DEE11071AE@ucalgary.ca> References: <0453B1A0-F016-4F59-B04E-79DEE11071AE@ucalgary.ca> Message-ID: Hi Ivars, Thanks for the email. I'm glad you're willing to help dig into this one to get a good solution. Attached is a first rough effort to make a figure with a 3 inch square bbox and using 12pt Times. Once we getting a scheme that works, we'll need to provide a nicer packaging to make things pretty. -------------- next part -------------- A non-text attachment was scrubbed... Name: fixed_size.rb Type: text/x-ruby-script Size: 2230 bytes Desc: not available Url : http://rubyforge.org/pipermail/tioga-users/attachments/20060906/78cb6a99/attachment.bin -------------- next part -------------- The figure is 'splines' taken from samples/plots -- with the addition of an initial call to setup the page. def page_setup t.tex_preview_tiogafigure_command = 'tiogafiguresized' t.tex_preview_fullpage = false set_size(3,3) set_bbox_to_fill_page t.tex_preview_preamble = t.tex_preview_preamble + "\n\t\ \usepackage{times}\n" t.set_default_font_size(12) t.title_scale = 1 t.xlabel_scale = 1 t.ylabel_scale = 1 t.set_frame_sides(0.2,0.8,0.8,0.2) # left, right, top, bottom in page coords end The set_size routine adjusts the device pagesize and the preview figure size. def set_size(width,height) # in inches units_per_inch = 720 t.set_device_pagesize(width*units_per_inch, height*units_per_inch) t.tex_preview_figure_width = width.to_s + 'in' t.tex_preview_figure_height = height.to_s + 'in' end The set_bbox_to_fill_page routine sets the frame to cover the entire page and then adds points at the four corners to set the bbox. def set_bbox_to_fill_page t.set_frame_sides(0,1,1,0) # left, right, top, bottom in page coords t.set_bounds( 'left_boundary' => 0, 'right_boundary' => 1, 'top_boundary' => 1, 'bottom_boundary' => 0) t.update_bbox(0,0) t.update_bbox(0,1) t.update_bbox(1,0) t.update_bbox(1,1) end In page_setup, I've added a \usepackage{times} -- this might be better done by changing the tex_preview_fontfamily, but I haven't tried that. The default font size is changed to 12 and the scales for title and labels are set to 1 so that they will be done in the default size (which is now 12 point). The last thing that page_setup does is reduce the frame back to the usual fraction of the bbox to allow room for title and labels outside of the figure. This means that the figure box is of course less than 3 by 3. The preview default is to scale the figure to fill the page. This is changed by setting tex_preview_fullpage to false, changing tex_preview_tiogafigure_command to tiogafiguresized, and setting tex_preview_figure_width and tex_preview_figure_height to 3 inches. Perhaps we can debug this until it does what you want! Please take a look a let me know how it goes. Thanks, Bill From ifinvers at ucalgary.ca Thu Sep 7 12:35:30 2006 From: ifinvers at ucalgary.ca (Ivars Finvers) Date: Thu, 7 Sep 2006 10:35:30 -0600 Subject: [Tioga-users] font size change using tex_preview_fontsize results in incorrect label positioning In-Reply-To: References: <0453B1A0-F016-4F59-B04E-79DEE11071AE@ucalgary.ca> Message-ID: <596C2AEE-9164-44CB-8F97-9D1F58CC54DE@ucalgary.ca> Bill, Thanks for the code examples. It basically does what I want once I change the set_size routine to: def set_size(width,height) # in inches units_per_inch = 720 t.set_device_pagesize(width*units_per_inch, height*units_per_inch) t.tex_preview_figure_width = width.to_s + 'in' t.tex_preview_figure_height = height.to_s + 'in' t.tex_preview_paper_width = width.to_s + 'in' t.tex_preview_paper_height = height.to_s + 'in' t.tex_preview_hoffset = "-1in" t.tex_preview_voffset = "-1in" end where I have added the paper width/height and hoffset/voffset setting so that the final pdf page size is of the desired size (since this is what LaTeX will use when sizing and placing the figure). Looking through the rest of the code, it contains most of the things that I had tried except for 3 bits: t.set_device_pagesize(width*units_per_inch, height*units_per_inch) This had a huge impact. I'm still not clear how it interacts with the rest of the system, but if I leave it out, the font sizes are all wrong even if the rest of the commands remain the same. t.tex_preview_tiogafigure_command = 'tiogafiguresized' This makes sense. set_bbox_to_fill_page I'm still confused about how the bounds affects the bounding box (and the relationship and impact of the various coordinate systems, frames, bounds, etc.) and exactly what the update_bbox routine does. I'll have to dig into the code. So in the end, the positioning instruction in the \makebox command of the .txt file don't need to be changed as I suggested previously. The difference between your approach and my original attempt was that I changed the font size using tex_preview_fontsize, whereas you used set_default_font_size. Being the author of the code obviously helps in knowing what commands exist! (Perhaps the \makebox positioning commands should be altered so that the tex_preview_fontsize command is more usable). Thanks so much for the help. Ivars On 6-Sep-06, at 6:12 PM, Bill Paxton wrote: > Hi Ivars, > > Thanks for the email. I'm glad you're willing to help dig into > this one to get a good solution. Attached is a first rough effort > to make a figure with a 3 inch square bbox and using 12pt Times. > Once we getting a scheme that works, we'll need to provide a nicer > packaging to make things pretty. > > > > > The figure is 'splines' taken from samples/plots -- with the > addition of an initial call to setup the page. > > def page_setup > t.tex_preview_tiogafigure_command = 'tiogafiguresized' > t.tex_preview_fullpage = false > set_size(3,3) > set_bbox_to_fill_page > t.tex_preview_preamble = t.tex_preview_preamble + "\n\t\ > \usepackage{times}\n" > t.set_default_font_size(12) > t.title_scale = 1 > t.xlabel_scale = 1 > t.ylabel_scale = 1 > t.set_frame_sides(0.2,0.8,0.8,0.2) # left, right, top, > bottom in page coords > end > > > The set_size routine adjusts the device pagesize and the preview > figure size. > > def set_size(width,height) # in inches > units_per_inch = 720 > t.set_device_pagesize(width*units_per_inch, > height*units_per_inch) > t.tex_preview_figure_width = width.to_s + 'in' > t.tex_preview_figure_height = height.to_s + 'in' > end > > > The set_bbox_to_fill_page routine sets the frame to cover the > entire page and then adds points at the four corners to set the bbox. > > def set_bbox_to_fill_page > t.set_frame_sides(0,1,1,0) # left, right, top, bottom in > page coords > t.set_bounds( > 'left_boundary' => 0, 'right_boundary' => 1, > 'top_boundary' => 1, 'bottom_boundary' => 0) > t.update_bbox(0,0) > t.update_bbox(0,1) > t.update_bbox(1,0) > t.update_bbox(1,1) > end > > > In page_setup, I've added a \usepackage{times} -- this might be > better done by changing the tex_preview_fontfamily, but I haven't > tried that. The default font size is changed to 12 and the scales > for title and labels are set to 1 so that they will be done in the > default size (which is now 12 point). > > The last thing that page_setup does is reduce the frame back to the > usual fraction of the bbox to allow room for title and labels > outside of the figure. This means that the figure box is of > course less than 3 by 3. > > The preview default is to scale the figure to fill the page. This > is changed by setting tex_preview_fullpage to false, changing > tex_preview_tiogafigure_command to tiogafiguresized, and setting > tex_preview_figure_width and tex_preview_figure_height to 3 inches. > > > Perhaps we can debug this until it does what you want! > > Please take a look a let me know how it goes. > > Thanks, > Bill > > >