summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex')
-rw-r--r--Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex58
1 files changed, 36 insertions, 22 deletions
diff --git a/Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex b/Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex
index b91150cbe73..5bf2b098691 100644
--- a/Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex
+++ b/Master/texmf-dist/doc/generic/FAQ-en/faq-mac-prog.tex
@@ -187,12 +187,14 @@ which rather spoils the intent of the joke implicit in the example
\Question[Q-repeat-num]{Repeating a command \emph{n} times}
-\tex{} \emph{isn't} a programming language, but there are occasions
-when you want to repeat some part of your document, just as parts of
-programs need to run several times. An obvious
+\tex{} was \emph{not} designed as a programming language, but there
+are occasions when you want to repeat some part of your document, just
+as parts of programs need to run several times. An obvious
example is \tex{}-based drawing: \latex{}'s \environment{picture}
environment and \Package{pgf} (at least) provide repeat facilities~---
-they are useful for drawing repeating patterns.
+they are useful for drawing repeating patterns. As a result,
+``common'' programming techniques often have to be emulated using
+obscure macro \tex{}niques.
This answer deals with repeating an operation a given number of times;
repeating operations once for each of a set of objects is dealt with
@@ -372,12 +374,16 @@ clear.
\item[pgffor.sty]Distributed as part of \CTANref{pgf}
%\item[repeat.tex]\CTANref{repeat}
\end{ctanrefs}
+\LastEdit{2013-03-01}
\Question[Q-repeat-set]{Repeating something for each `thing' in a set}
-A common alternative requirement is to repeatedly apply a command to a
-set of ``objects''; this can arise, for example, when you have input
-that specifies a list.
+As another question % line break!
+(\Qref*{repeating something a given number of times}{Q-repeat-num})
+explains, \tex{} is not explicitly designed for `regular' programming
+operations. As a result, we must resort to arcane tricks to do the
+seemingly simple task of repeating an operation. This answer deals
+with repeating an operation for each of a given set of objects.
The \Package{etoolbox} package provides iteration over a
comma-separated list of items, in its \csx{docsvlist} and
@@ -2613,26 +2619,32 @@ This does the trick, for sufficiently simple commands, but it has
various tiresome failure modes, and it requires \csx{mycommandnostar}
to take an argument.
-Of course, the \LaTeX{} kernel has something slicker than this:
+The \LaTeX{} kernel does a lot of this, and has its own command,
+\csx{@ifstar} (which needs `internal command protection', cf.
\begin{quote}
\begin{wideversion}
\begin{verbatim}
-\newcommand{\mycommand}{\@ifstar
- \mycommandStar%
- \mycommandNoStar%
+\newcommand{\mycommand}{%
+ \makeatletter
+ \@ifstar
+ \mycommandStar%
+ \mycommandNoStar%
+\makeatother
}
-\newcommand{\mycommandStar}[2]{starred version}
-\newcommand{\mycommandNoStar}[1]{normal version}
+\newcommand{\mycommandStar}{starred version}
+\newcommand{\mycommandNoStar}{normal version}
\end{verbatim}
\end{wideversion}
\begin{narrowversion}
\begin{verbatim}
+\makeatletter
\newcommand{\mycommand}{\@ifstar
\mycommandStar%
\mycommandNoStar%
}
-\newcommand{\mycommandStar}[2]{starred version}
-\newcommand{\mycommandNoStar}[1]{normal version}
+\makeatother
+\newcommand{\mycommandStar}{starred version}
+\newcommand{\mycommandNoStar}{normal version}
\end{verbatim}
\end{narrowversion}
\end{quote}
@@ -2640,7 +2652,7 @@ Of course, the \LaTeX{} kernel has something slicker than this:
are independent~--- either can have their own arguments, unconstrained
by the technique we're using, unlike the trick described above.)
The \csx{@ifstar} trick is all very well, is fast and efficient, but
-it requires the definition to be % ! line break
+it requires that the definition be % ! line break
\Qref*{\csx{makeatletter} protected}{Q-atsigns}.
A pleasing alternative is the \Package{suffix} package. This elegant
@@ -2708,7 +2720,7 @@ via the \Package{expl3} package.
\item[xparse.sty]Distributed as part of \CTANref{l3packages}[xparse]
\item[expl3.sty]Distributed as part of \CTANref{l3kernel}[expl3]
\end{ctanrefs}
-\LastEdit{2012-11-01}
+\LastEdit{2013-02-28}
\nothtml{\hrule height 0pt \nobreak\vskip0pt plus2.5in\vskip 0pt\relax}
\Question[Q-ltxabbrv]{\LaTeX{} internal ``abbreviations'', etc.}
@@ -3585,11 +3597,12 @@ December 2003 edition of \LaTeX{}; if you have an older distribution,
the packages \Package{type1cm} (for \acro{CM} fonts) and
\Package{type1ec} (for \acro{EC} fonts) are available.
-If \Package{fix-cm} doesn't do the job for you, try one of the other
-two; \Package{fix-cm} has one or two omissions~--- fonts the \latex{}
+\Package{Fix-cm} doesn't has one or two omissions~--- fonts the \latex{}
team did not consider useful, or something; the CM dunhill fonts (as
-CM, but with stretched ascenders) and the CM fibonacci (which is only
-available in 8-point design size) are certainly missing.
+CM, but with stretched ascenders) and the CM fibonacci font (which is only
+available in 8-point design size) are certainly missing. If
+\Package{fix-cm} doesn't do the job, try the \Package{type1xx}
+packages, or the \Package{anyfontsize} package.
A further alternative might be to switch to the
\Qref*{\FontName{Latin} \FontName{Modern} fonts}{Q-uselmfonts} (which
@@ -3597,6 +3610,7 @@ provide a close simulacrum of the \FontName{Computer}
\FontName{Modern} set); these fonts were scaleable from their first
distribution, and don't therefore need any such trick as the above.
\begin{ctanrefs}
+\item[anyfontsize.sty]\CTANref{anyfontsize}
\item[fix-cm.sty]Distributed as part of \CTANref{latex}[fix-cm] (an unpacked
version is available at \CTANref{fix-cm})
\item[\nothtml{\rmfamily}\FontName{Latin} \FontName{Modern} fonts]\CTANref{lm}
@@ -3605,7 +3619,7 @@ distribution, and don't therefore need any such trick as the above.
the \CTANref{cm-super} distribution, but it works happily in
the absence of the scaled fonts)
\end{ctanrefs}
-\LastEdit{2011-06-02}
+\LastEdit{2013-06-04}
\Question[Q-latexqual]{The quality of your \LaTeX{}}