# Tag Info

6

In the calculation of \pgfmathsetmacro{\theta}{360*\k/\N} 360*\k easily becomes bigger than what LaTeX can handle. Reversing the multiplication order, solves this: \pgfmathsetmacro{\theta}{360/\N*\k}

0

In your original answer you said that you try to joint two long lists. But lists of 20 elements are not long. So you can use a non optimized O(N^2) method. Your first method works, even with 4 lists, because you don't need 4 nested loops, but one loop with 3 sub-loops. So it is only 3 times slower than 2 lists. ...

3

It ain't pretty, but I think it works. All the lists must be the same length. \documentclass[varwidth,border=5]{standalone} \usepackage{pgf,pgffor} \makeatletter \newif\if@il@finish \def\interleavelists#1#2{% \let\il@list=\@empty% \begingroup% \il@interleave{#2}% \endgroup% \let#1=\il@list% } \def\@stop{@stop}% \def\il@interleave#1{% ...

3

Just for fun, a python solution (updated following @percusse's comment): \documentclass[border=7mm]{standalone} \usepackage{python} \begin{document} \begin{python} a = "1,2,3" b = "one,two,three" for t in zip(a.split(','),b.split(',')): print '%s is %s\\quad' % t \end{python}% \end{document} Or to obtain the same result using pyhton to join the ...

3

Do you want something like this? \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\combinedforeach}{sm sm +m} { \IfBooleanTF{#1} { \IfBooleanTF{#3} { \sebastian_combined_foreach:VVn #2 #4 { #5 } } { \sebastian_combined_foreach:Vnn #2 { #4 } { #5 } } } { \IfBooleanTF{#3} { ...

2

Something like this? Requires lualatex: \documentclass[varwidth,border=5]{standalone} \usepackage{pgffor} \def\randomiselist#1#2{\edef#2{\directlua{% local i, j, k, n, s, t, v t = {#1} n = 0 for i, v in ipairs(t) do n = n + 1 end for i = 1,n do j = math.random(i,n) k = t[i] t[i] = t[j] t[j] = k end s = '' for i = 1,n do s = s .. t[i] if i < ...

2

Update Improved version (older version at the end) The spacings etc. can't be automated straightforwardly. Some manual adaption is needed for each slide file. \documentclass[a5paper]{article} \usepackage{pdfpages} \usepackage{pgffor} \usepackage{xparse} \usepackage{blindtext} \newlength\slidetextdistance \setlength{\slidetextdistance}{0.48\textheight} ...

2

I took something from every answer to make a simple package that meets my needs. You can draw any number staves with any number of lines each, and you can control the spacing both between and inside the staves. The package is below, followed by a sample document demonstrating different uses. Package musicstaves.sty \NeedsTeXFormat{LaTeX2e} ...

2

An expl3 customizable version: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \keys_define:nn { cashner/staff } { width .dim_set:N = \l_cashner_staff_width_dim, number .int_set:N = \l_cashner_staff_number_int, gap .dim_set:N = \l_cashner_staff_gap_dim, width .initial:n = \linewidth, number .initial:n = 1, gap .initial:n = ...

4

I'm a fan of \foreach from pgffor.sty, so... \documentclass{article} \usepackage{pgffor} \newcommand{\staff}[2][5]{%[# of lines per staff]{# of staves} \begingroup \parindent0pt \noindent \foreach \y in {1,...,#2}{% \foreach \x in {1,2,...,#1}{% \rule{\textwidth}{0.4pt}% {<staff width>}{<line thickness>} ...

6

\loop is a very simple macro and can not be nested at the same group level: \documentclass{article} \newcounter{stafflines} \newcommand{\musicstaff}{% \setcounter{stafflines}{0} ...

Top 50 recent answers are included