Discussion:
How to detect current font size, shape, series and the like?
Steve Litt
2007-05-04 15:28:44 UTC
Permalink
Hi all,

Turns out I'll be using my Ex character style in body text and in several
headings, which means I can't hardcode a size like \LARGE, but instead must
find a way to *increase* the font size, which means I need to detect and
store the current font size so I can increase it, probably with a bunch of
if/then/else type stuff.

How do I detect and store the current font size?

Thanks

SteveT

Steve Litt
Author: Universal Troubleshooting Process books and courseware
http://www.troubleshooters.com/
Paul A. Rubin
2007-05-11 19:09:18 UTC
Permalink
Post by Steve Litt
Turns out I'll be using my Ex character style in body text and in several
headings, which means I can't hardcode a size like \LARGE, but instead must
find a way to *increase* the font size, which means I need to detect and
store the current font size so I can increase it, probably with a bunch of
if/then/else type stuff.
How do I detect and store the current font size?
\***@size will give the current font size (in points); \***@series,
\***@family, \***@shape do similar sorts of things. The catch is that they
can't be used directly within a document. What you can do is put
something like

\newcommand{\mysize}{\***@size}

in the preamble. There are also \***@size and \***@size which might be
intended for math mode (not sure).

/Paul
Steve Litt
2007-05-14 23:16:10 UTC
Permalink
Post by Paul A. Rubin
Post by Steve Litt
Turns out I'll be using my Ex character style in body text and in several
headings, which means I can't hardcode a size like \LARGE, but instead
must find a way to *increase* the font size, which means I need to detect
and store the current font size so I can increase it, probably with a
bunch of if/then/else type stuff.
How do I detect and store the current font size?
can't be used directly within a document. What you can do is put
something like
intended for math mode (not sure).
/Paul
Thanks Paul,

This didn't work for me. Here's a tiny LaTeX file incorporating it:

%====================================
\documentclass[12pt]{book}
\newcommand{\mysize}{\***@size}

\begin{document}
mysize is \mysize
\end{document}
%====================================

When I try to compile it, here's what happens:

[***@mydesk vimfacts]$ latex junk2.tex
This is pdfeTeX, Version 3.141592-1.30.6-2.2 (Web2C 7.5.5)
entering extended mode
(./junk2.tex
LaTeX2e <2005/12/01>
Babel <v3.8h> and hyphenation patterns for american, french, german, ngerman,
b
ahasa, basque, bulgarian, catalan, croatian, czech, danish, dutch, esperanto,
e
stonian, finnish, greek, icelandic, irish, italian, latin, magyar, norsk,
polis
h, portuges, romanian, russian, serbian, slovak, slovene, spanish, swedish,
tur
kish, ukrainian, nohyphenation, loaded.
(/usr/share/texmf/tex/latex/base/book.cls
Document Class: book 2005/09/16 v1.4f Standard LaTeX document class
(/usr/share/texmf/tex/latex/base/bk12.clo)) (./junk2.aux)
! Undefined control sequence.
\mysize ->\f
@size
l.7 mysize is \mysize

?

Any ideas what I should do?

Thanks

SteveT

Steve Litt
Author: Universal Troubleshooting Process books and courseware
http://www.troubleshooters.com/
Richard Heck
2007-05-15 16:13:30 UTC
Permalink
Post by Steve Litt
%====================================
\documentclass[12pt]{book}
\begin{document}
mysize is \mysize
\end{document}
%====================================
[snip]
! Undefined control sequence.
\mysize ->\f
@size
l.7 mysize is \mysize
?
Any ideas what I should do?
\makeatletter
\newcommand{\mysize}{\***@size}
\makeatother

Otherwise, LaTeX parses this:
\newcommand{\mysize}{\***@size}
as if it were:
\newcommand{\mysize}{\f @size} %note the space after '\f'
since '@' isn't ordinarily a `letter', that is, something that can occur
as part of a command name. You always have to use
\makeatletter--\makeatother in the preamble when using @-commands. You
do NOT have to do this in .cls and .sty files. Note that this means that
you also need the \makeatletter--\makeatother pair in Preamble sections
of LyX layouts.

rh
--
==================================================================
Richard G Heck, Jr
Professor of Philosophy
Brown University
http://frege.brown.edu/heck/
==================================================================
Get my public key from http://sks.keyserver.penguin.de
Hash: 0x1DE91F1E66FFBDEC
Learn how to sign your email using Thunderbird and GnuPG at:
http://dudu.dyn.2-h.org/nist/gpg-enigmail-howto
Jean-Pierre Chretien
2007-05-15 08:40:49 UTC
Permalink
Subject: Re: How to detect current font size, shape, series and the like?
Date: Mon, 14 May 2007 19:16:10 -0400
[...]
%====================================
\documentclass[12pt]{book}
\begin{document}
mysize is \mysize
\end{document}
%====================================
[...]
Any ideas what I should do?
@ is not legal in latex documents, you must say that it is a plain letter:
\makeatletter
\newcommand{\mysize}{\***@size}
\makeatother

LyX does it for you, for the whole preamble, so without adding these commands,
tex2lyx yourdoc.tex; lyx -e dvi yourdoc.lyx; xdvi yourdoc
works...
--
Jean-Pierre
Continue reading on narkive:
Loading...