4

Since I want to display several fonts I my document showing an example of the alphabet of each font I wanted to define a new command to easily get the alphabet; the code for this is the following:

\newcommand{\alphabetExample}{{\fontfamily{#1}\selectfont Aa\-Bb\-Cc\-Dd\-Ee\-Ff\-Gg\-Hh\-Ii\-Jj\-Kk\-Ll\-Mm\-Nn\-Oo\-Pp\-Qq\-Rr\-Ss\-Tt\-Uu\-Vv\-Ww\-Xx\-Yy\-Zz\-0123456789}}

However, the #1 isn't accepted - the command works if I write a specific font family instead of the argument. Thanks for any help, it would really save me a lot of copy-paste-work.

PS: Sorry if the tag isn't right, it's my first question here and I didn't know which one to use.

  • 1
    \newcommand{\alphabetExample}[1] you need to tell LaTeX that the number of arguments of the command. – Manuel Jan 31 '15 at 17:01
  • Oh! Thank you very much ^_^. I've started LaTeX only one week ago so I haven't got familiar with it so far. – Oliver Borchert Jan 31 '15 at 17:03
  • @Manuel. Provided that it was the solution, put it as an answer, so that others may profit – Ludenticus Jan 31 '15 at 18:16
7

You need to tell LaTeX hoy many arguments the command has with [n], in this case just one [1].

\newcommand*\alphabetExample[1]
  {{\fontfamily{#1}\selectfont Aa\-Bb\-Cc\-Dd\-Ee\-Ff\-Gg\-Hh\-Ii\-Jj\-Kk\-Ll%
    \-Mm\-Nn\-Oo\-Pp\-Qq\-Rr\-Ss\-Tt\-Uu\-Vv\-Ww\-Xx\-Yy\-Zz\-0123456789}}
3

You need to tell TeX how many parameters (and maybe their separators) is provided by the defined macro.

\def\alphabetExample#1{%
   {\fontfamily{#1}\selectfont Aa\-Bb\-Cc\-Dd\-Ee\-Ff\-Gg\-Hh\-Ii\-Jj\-Kk\-Ll%
    \-Mm\-Nn\-Oo\-Pp\-Qq\-Rr\-Ss\-Tt\-Uu\-Vv\-Ww\-Xx\-Yy\-Zz\-0123456789}}
  • 1
    But in LaTeX it is better to use \newcommand or \newcommand* when possible. [Naturally that's not so with alternative formats, and I know you eschew LaTeX.] – cfr Feb 1 '15 at 4:09

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.