# Tag Info

32

Requires xelatex: \documentclass{article} \usepackage{color} \XeTeXinterchartokenstate = 1 \newXeTeXintercharclass \vowelsclass \XeTeXcharclass \a \vowelsclass \XeTeXcharclass \e \vowelsclass \XeTeXcharclass \i \vowelsclass \XeTeXcharclass \o \vowelsclass \XeTeXcharclass \u \vowelsclass \XeTeXcharclass \A \vowelsclass \XeTeXcharclass \E ...

30

This is just for practicing with LaTeX3 code. \documentclass{article} \usepackage{xparse,xcolor} \ExplSyntaxOn \NewDocumentCommand{\colorize}{mm} { \cs_set:cpn { maryjane_color_#1: } { \textcolor{#2}{#1} } } \tl_new:N \l_maryjane_text_tl \NewDocumentCommand{\changecolors}{ O{aeiou} m } { \tl_set:Nn \l_maryjane_text_tl { #2 } \tl_map_inline:nn { #1 ...

30

Edit: To give some indications for this question (What's the maximum number of pages a PDF produced by pdfTeX can have?), I tried my second version with a limit of 2.500.000 pages. The PDF produced (in approximatively 30 minutes) contains 1112672090 bytes. Here is a variation of your first solution (this document can't be terminated!): ...

19

My first LaTeX3 answer! Yay! :) The l3clist package has a lot of built-in commands to deal with comma-separated lists. Here's an attempt: \documentclass{article} \usepackage{expl3} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand \countItems { m } { \clist_count:N #1 } \NewDocumentCommand \countInlineItems { m } { \clist_count:n {#1} } ...

18

A loop and a counter: Code \documentclass{article} \makeatletter \newcommand*{\length}[1]{% \@tempcnta\z@ \@for\@tempa:=#1\do{\advance\@tempcnta\@ne}% The length of the list #1 is \the\@tempcnta.% } \makeatother \begin{document} \length{0,1,54,1,3} \def\mylist{0,1,54,1,3} \length\mylist \end{document} Output The length of the list ...

15

The following code will do what is asked, using the plain TeX construction \loop ... \if ... \repeat: \documentclass{article} \title{The Song That Never Ends} \author{by Norman Martin} \begin{document} \maketitle % \noindent This is the song that never ends. \newline \loop \iftrue Yes, it goes on and on my friends. \newline Some people started ...

12

The syntax for \@for is \@for\cs:=<list>\do{<code>} Here <list> is either a comma separated list of tokens or a macro expanding to such a list. Thus, the calls \@for\next:=abc, def, gh ,ij\do{<code>} and \def\mylist{abc, def, gh ,ij} \@for\next:=\mylist\do{<code>} are equivalent. Notice that LaTeX doesn't really ...

12

The difficulty is not in producing it, but rather in printing it. Here's a way; for printing ten terms we need two lines and I decided to let TeX bother with the splitting. The \telescope command is generic, by redefining \Term you can print other similar series. \documentclass{article} \usepackage{xparse,amsmath} \ExplSyntaxOn ...

12


11

The main error is in the line \ifnum\select@i=#1\@@select@item\@endfortrue\fi% When \@@select@item the lookup for the number is not finished and TeX keeps expanding until finding something that's not a digit; when \@@select@item is 1, it's easy to predict chaos. A better style is \ifnum#1=\select@i\@@select@item\@endfortrue\fi because \select@i is a ...

10

The tricky part is to get the maximum number of pages in a PDF file. If a file is included in pdfTeX, then it sets a primitive \pdflastximagepages with the number of pages in the included PDF file. Thus the following example defines the macro \getpdfpages. It includes the first page in a temporary box. Then it sets the LaTeX counter pdfpages to the value of ...

10

Here is a never ending counting of the primes... (except that it will end-up in some arithmetic overflow error after a while). For less overhead, I use plain PDFTeX. Launching the run in a Terminal, the page numbers correspond to how many primes have been computed so far. update: the algorithm was a bit faulty, although it computed correctly the ...

9

A solution without any extra packages \documentclass{article} \usepackage{graphicx} % introduce a dummy counter, initially 0 \newcount\tmp \newcommand{\pdfappendix}[2]{% need this to prevent extra vertical space % #1: image path and core part of name % #2: maximum number \tmp=0 \loop % increment dummy counter ...

9

Here another approach using l3int: \documentclass{article} \usepackage{amsmath} \usepackage{xparse} %dt. Silbentrennung \ExplSyntaxOn \cs_generate_variant:Nn \int_set:Nn { Nx } \NewDocumentCommand \Formula { O{1} O{1} m } { \int_step_inline:nnnn { #1 }%initial value { #2 }%step { #3 - #2 }%final value { \formula_func_aux:n { ##1 } \\ ...

8

A combination of forloop and calc: \documentclass[10pt,a4paper]{article} \usepackage{amsmath} \usepackage{calc} \usepackage{forloop} \begin{document} \hsize=8cm \newcounter{k}\newcounter{j}% \begin{align} %forloop[ step ]{ counter }{ initial value }{ condition }{ code } \nonumber \forloop{k}{1}{\value{k} < 11}{ \setcounter{j}{2*\value{k}-1} \\ ...

8

This also uses no counters but is perhaps a bit simpler than jfbu's but is the same idea. \documentclass{article} \usepackage{amsmath} \newcommand\y[1]{% y_{\the#1}&=A_{\the#1\,\the\numexpr2*#1-1\relax} +A_{\the#1\,\the\numexpr2*#1\relax} x_{\the\numexpr2*#1\relax}} ...

8

Without any package, you can do with \loop; the trick is to add something invisible to the empty pages, for instance \null (more efficient than \mbox{}): \documentclass{article} \newcommand{\filluptopage}[1]{% \clearpage \loop\ifnum\value{page}<#1\relax \null\clearpage \repeat } \begin{document} Page 1 has text. \filluptopage{5} This will ...

8


7

Package xstring, counting empty elements A solution using package xstring. It also counts elements that are empty: \documentclass{article} \usepackage{xstring} \newcommand*{\commalength}[1]{% \StrCount{#1,}{,}% } \begin{document} \verb|{0,1,54,1,3}| has length \commalength{0,1,54,1,3}. \verb|{,,}| has length \commalength{,,}. \end{document} ...

7

You can avoid the error by just delaying switching the mathcode, so change \mathcode#1="8000 to \AtBeginDocument{\mathcode`#1="8000 } But a more serious problem is that you are making every definition {\color{abc}\olddefn} which makes every character a mathord and destroys the spacing (just of = in this example as letters get mathord spacing ...

7

To say it short: the only solution for this is: rephrase the sentence or use \ref or \pageref. A little bit longer: This error message informs you that the created reference goes over the current page and variorefdoes not know whether it should count it on page x or x+1. Is the reference on page x the text of the reference is calculated to "this page" or ...

Only top voted, non community-wiki answers of a minimum length are eligible