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?

  • 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. 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? Apr 10 '13 at 12:21
  • do you mean how can you achieve that in latex or how you can achieve it in plain? 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.
    – Lucas
    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).
    – Lucas
    Apr 10 '13 at 13:05

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}

  • 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:-)
    – Lucas
    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. 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.
    – Lucas
    Apr 10 '13 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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