LaTeX users online
In total there are 14 users online :: 3 registered, 0 hidden and 11 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], Yahoo [Bot] and 11 guests
LaTeX blog world
Index I: Anlegen und Verarbeiten (Tobi)How to Ask for LaTeX-related Help Effectively (Lian Tze)
Many variants of a Beamer presentation - part I (Marcin)
Speaker Meeting 2016 (Joseph)
LaTeX and music (Clemens)
Adding references from an external file (Tom)
Exporting from LyX to MS Word and LibreOffice (Stefan)
Booklets erzeugen (Tobi)
AltaCV, yet another LaTeX CV/Résumé class (Lian Tze)
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)
Querverweise (Tobi)
What's new in chemmacros v5.6? (Clemens)
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.
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
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], Yahoo [Bot] and 11 guests |