TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

An specific question is as follows:

I hope that I can define a macro that can switch to different typefaces. We assume that this macro is named \myfonts, so, if I type {\myfonts throughout his life, Einstein published hundreds of books and articles.}, the typeface will be the default Minion Pro. But if I pass a parameter to that macro, for example, {\myfonts{palatino} ...}, it will become the Palatino typeface.

I have no idea to this question now.

In LaTeX, if you say \documentclass{article}, it will take a4paper and 10pt as the default, but if you type \documentclass[b5paper,11pt]{article}, it will be changed into b5paper and 11pt. I am curious about this: How can I achieve that?

share|improve this question
You have tagged this plain-tex do you want it for plain, not for latex? also does it have to be that syntax, which is problematic, as there is no way of knowing that the following { is a argument delimiter rather than a following group \myfonts {\bf zzz } xxx you probbaly want to take this as no-parameter form. A syntax such as [] or <> delimited optional argument as in latex is much less likely to have this problem. – David Carlisle Apr 10 '13 at 12:06
Also, is your intent to switch to the new font momentarily (inline font change, with a clear beginning and end), or to arbitrarily change to new font for an indefinite period? – Steven B. Segletes Apr 10 '13 at 12:21
do you mean how can you achieve that in latex or how you can achieve it in plain? – David Carlisle Apr 10 '13 at 12:55
@DavidCarlisle I mean that how can I achive the macros in this form (like \documentclass and so on, only a form, it can be any macro in this form) in plain tex. – Timothy Li Apr 10 '13 at 13:01
@DavidCarlisle I think the macro in this form is very useful when I want to give some options (of course, I can choose not to use this options, so it will use the default values). – Timothy Li Apr 10 '13 at 13:05
up vote 7 down vote accepted

enter image description here

using [] delimited argument and the fonts in plain by default:

\def\argmyfonts[#1]{\csname myfonts#1\endcsname}

{\myfonts abc de}
{\myfonts[a] abc de}
{\myfonts[b] abc de}

share|improve this answer
thanks, David. I think the \futurelet and \expandafter is what I want, but I can't achieve this construct. Now, I am learing this method from your code:-) – Timothy Li Apr 10 '13 at 12:33
@TimLi You should be able to use it as posted but just define \myfontspalatino etc as the internal command do do whatever you need to switch to that font. – David Carlisle Apr 10 '13 at 12:37
yeah. I have edited my question, the added part is the reason why I want to ask you this question. – Timothy Li Apr 10 '13 at 12:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.