11

Inside of a group, a command like \tiny has effect only until the group ends. One would like to be able to say \global\tiny to have it last after the group ends, but that does not work.

The best that I was able to come up with (described here) is the following.

\newif\ifhelper
\makeatletter
\def\unithelper#1\@nnil{\global\helpertrue\helper}
\def\helper{\ifhelper\afterassignment\helper\global\fi}
\newcommand*\globalfontsize[1]{%
\begingroup
       #1%
       \def\@defaultunits{\helperfalse\afterassignment\unithelper\global}%
       \let\realvrule\vrule
       \def\vrule{\helperfalse\global\helpertrue\afterassignment\helper\realvrule}%
       \global\helpertrue
       \helper#1%
       \helperfalse
\endgroup}
\makeatother

Then you can say \globalfontsize\tiny or \globalfontsize\normalsize to achieve the desired effect. What is the right way to do that?

Edit: Several people have suggested some variant of \documentclass[10pt]{article}. That is not related to my question. I'm using "global" in analogy to the TeX primitive \global.

1
  • Without looking into too much detail into the NFSS code, I think this is about the best you're going to be able to do. Aug 22, 2010 at 23:55

2 Answers 2

10
\newcommand{\doglobally}[1]{{\globaldefs=1#1}}

Now you can write \doglobally\tiny

1
  • Excellent! I had completely forgotten about \globaldefs. According to the TeXbook's index, \globaldefs appears on exactly 3 pages (not counting the index itself). Good catch.
    – TH.
    Aug 23, 2010 at 1:20
0

For at least some font sizes, you can use something like \documentclass[12pt]{article}. However, I'm entirely sure which font sizes this works for---I do know it works for 10pt (the default) and 12pt.

3
  • I could have sworn there was a similar answer that I already commented on. My question is not about setting the fontsize for the document. It's about how to change the size in a manner that is analogous to TeX's \global.
    – TH.
    Aug 22, 2010 at 22:07
  • @TH. The previous answer has been deleted by its owner.
    – Caramdir
    Aug 22, 2010 at 23:35
  • But this is what I was looking for when I googled, so I'm upvoting.
    – fotanus
    Nov 28, 2013 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .