How to print out the value of \textwidth?Add tags
9 posts
• Page 1 of 1
How to print out the value of \textwidth?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
Re: How to print out the value of \textwidth?
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Re: How to print out the value of \textwidth?
Mr. Juanjo, Thanks for replying. Is it possible to convert the unit from pt to cm? Thanks in advance.
Re: How to print out the value of \textwidth?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
Re: How to print out the value of \textwidth?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.
Re: How to print out the value of \textwidth?Hi Juanjo,
you've given a very good demonstration! Btw. I've read the catcode trick in the TeXbook Appendix D: Dirty Tricks. Stefan LaTeX Community Administrator
Re: How to print out the value of \textwidth?To Stefen and Juanjo,
thanks for replying. I am trying to diggest the codes Hayashi
Re: How to print out the value of \textwidth?
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.
Re: How to print out the value of \textwidth?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
Who is onlineUsers browsing this forum: No registered users and 23 guests |





