LaTeX Books
LaTeX users online
In total there are 18 users online :: 2 registered, 0 hidden and 16 guests (based on users active over the past 5 minutes)Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm
Users browsing this forum: Bing [Bot], Google [Bot] and 16 guests
How to print out the value of \textwidth?LaTeX Forum: GeneralAdd tags
9 posts
• Page 1 of 1
Dear all,
I want to print out the value of \textwidth in the =? placeholder as follows
Please help me. Thank you in advance. regards, Hayashi
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Mr. Juanjo, Thanks for replying. Is it possible to convert the unit from pt to cm? Thanks in advance.
Hi,
as I don't know a more direct way I've made a calculation and manipulated it's output, here's a demonstration example:
Output is 13.998, so there may be a small rounding error, I just used 72.27pt=1in and 1in=2.54cm for the calculation. But there are packages that are capable of floating point operations. Stefan LaTeX Community Administrator
With the help of the \catcode trick given by Stephan_K and the fp package, it is possible to define macros to convert from one unit to another:
The optional argument of TOpt, TOcm and like fixes the number of decimal digits shown (2 by default). These macros first convert their mandatory argument to pt (done automatically by TeX) and then the conversion to the corresponding unit. From the above code, it is easy to add macros for conversion to pc, ex, bp and so on. The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
To Stefen and Juanjo,
thanks for replying. I am trying to diggest the codes Hayashi
Well, not so good, since I've reinvented the wheel! I've found that the layouts package defines the commands \printinunitsof and \prntlen. The latter prints the value of a length in the units specified by the former. So, for example, after loading layouts, the code
prints the value of \textwidth and \textheight expressed in cm. Reading layouts.sty, one sees that conversion is internally done by multiplication by a suitable factor (without the help of fp). The code there uses the internal LaTeX macro \strip@pt, similar to (but much more elaborated than) \TOnum in my code. In fact, with the help of this macro, my code can be simplified: \TOnum is unnecessary and \TOop can be given by
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Dear all,
By accident, I found a package about this topic: http://www.ctan.org/tex-archive/help/Catalogue/entries/printlen.html regards, Hayashi
9 posts
• Page 1 of 1
LaTeX users onlineUsers browsing this forum: Bing [Bot], Google [Bot] and 16 guests |