LaTeX users online
In total there are 16 users online :: 1 registered, 0 hidden and 15 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] and 15 guests
LaTeX blog world
TeXdoc.net updated (Stefan)TUG 2016 reports (Norbert)
TUG 2016 in Toronto - Arriving and first excursion (Stefan)
Define new macros for logical markup (Tobi)
Finding typefaces (fonts) (Tobi)
Order of float placement parameters (Tobi)
Changes and News (Clemens)
What's new in chemmacros v5.6? (Clemens)
Lass Dich nicht von einem Hobby stressen! (Markus)
Das "Currentfile" Paket (Uwe)
TeX Live 2016 released (Stefan)
How to Deal with Wide Tables (Lian Tze Lim)
Get TeX Live 2016 now (Tobi)
LyX 2.2 released (Stefan)
Point vs. Big Point (Tobi)
Programming network switches and routers using TeX (Stefan)
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] and 15 guests |