GNOME Bugzilla – Bug 350625
Saving as .tex: wrong scaling for lanscape-mode
Last modified: 2006-08-12 14:13:07 UTC
Using Gnumeric 1.6.3 on Ubuntu-Linux with Gnome 2.14 I found the following bug: When I save a Gnumeric spreadsheet in the .tex (latex)-format and I comment/uncomment the required line to get landscape mode using latex the file is rescaled according to the textwidth of my document instead of the textheight. Here is the code which computes the scaling of a table: \ifthenelse{\lengthtest{\gnumericTableWidthComplete > \textwidth}}% {\def\gnumericScale{\ratio{\textwidth-% \tabcolsep*\gumericNumCols*2-% \arrayrulewidth*\gumericNumCols}% {\gnumericTableWidth}}}% {\def\gnumericScale{1}} So if the TableWidth of Gnumeric is larger than the textwidth the table is rescaled to fit in the textwidth. Obviously when I use landscape the textwidth is inappropriate. Instead one should rescale to the textheight if the TableWidth is larger than the textheight. The following code worked fine for me: \ifthenelse{\lengthtest{\gnumericTableWidthComplete > \textheight}}% {\def\gnumericScale{\ratio{\textheight-% \tabcolsep*\gumericNumCols*2-% \arrayrulewidth*\gumericNumCols}% {\gnumericTableWidth}}}% {\def\gnumericScale{1}} I propose to put this line in commented form into the file when saving as .tex file. Perhaps together with a comment that it has to be uncommented (and the original code commented) in a case where lanscape-mode is used in latex. Not sure if there is a way to find out if a table is in landscape during compilation?? Something like: If currentOrientation == landscape execute the proposed code (rescaling to textheight if necessary) else execute the original code (rescaling to textwidth if necessary) end Anyway, the inclusion of the proposed code in commented form would be great. Note that anybody who has a table which is larger than the textwidth is likely to run into this problem. The first thing one does in this case is to switch the table to landscape: However instead of getting a wider table (where the numbers fit in nicely) currently the table is rescaled to the textwidth despite the fact that landscape offers more space. Thank you very much for providing great Gumeric. The ability to save tables in .tex format is a "can not live without it"-feature. Best regards Christian
Sorry - it seems that I have been to fast with the proposition of my "fix". It seems that when in landscape mode then the proposed code does not work. However the code prevents rescaling when NOT in landscape mode - does landscape in Latex use different variable-names for height and the width of the text??
It seems that the landscape uses the term: linewidth The following code provides the correct rescaling inside the landscape mode (and this time it has been tested :) ): \ifthenelse{\lengthtest{\gnumericTableWidthComplete > \linewidth}}% {\def\gnumericScale{\ratio{\linewidth-% \tabcolsep*\gumericNumCols*2-% \arrayrulewidth*\gumericNumCols}% {\gnumericTableWidth}}}% {\def\gnumericScale{1}}
Sorry. If I understand you right, then supposedly in landscape mode: linewidth in portrait mode textwidth that would be a latex bug, not a gnumeric bug! In any case, in Gnumeric 1.6.3 on debian sid this works just fine. Clearly textwidth should be the width of the document. Please file a bug report against your latex package. I will have to think about how o determine th elocation of this problem in your latex package(s).
Okay: \textwidth is the normal width of the text on a page. It should generally be changed only in the preamble. \linewidth is the width of lines in the current environment. Normally equal to \textwidth, it may be different within an environment such as list or quote environments. which means that \textwidth is supposed to be adjusted for landscape versus portrait pages. Nevertheless we should be using linewidth in both landscape and and portrait format since the available space in teh current environment matters! I will change that in cvs.
This is just to confirm that replacing \textwidth by \linewidth gives the expected results in landscape-mode and non-landscape i.e. fixes the problem for me. I just replaced it manually in the .tex document and compiled the document once in landscape once in non-landscape mode to test it and got the expected result. Thank's a lot.
fixed in cvs Note that you should figure out what is wrong with your latex installation. It should work with \textwidth in landscape mode. \textwidth will just create tables that are slightly to wide if one is inside an environment that is narrower than the regular document.
@Andreas Thanks a lot for the fix. :) I just tested different cases: Here are the results: The use of \textwidth produced nice results in landscape when landscape is used for the whole document (e.g. documentclass[landscape]{report} ) in this case \textwidth is correctly set to the (global) textwidth of the document. If the lanscape mode is used in an embedded document and the mother-document is non-landscape then things seems to be different. In this case \textwidth stores the textwidth of the mother-document. I guess that the landscape mode is just treated like a environment in this case and that the behaviour of latex is correct? I found the following info in the lscape.sty file: %%% All text within %%% \begin{landscape} \end{landscape} %%% Will be rotated through 90 degrees. The page head and foot will %%% not be rotated, but will be positioned as normal. The landscape %%% environment always starts a new page, but may span several %%% pages. This (weakly) confirms that landscape is an environment when used for having landscape tables inside a non-landscape document. Thanks a lot, again.