New answers tagged loops
2
I propose one more answer, which uses expandable macros from the xint package, version 1.06a or later. Here, the case of an empty set of indices is treated less well than in my other answer (an empty align environment is typeset, which makes an increase in the equation counter), this could be fixed of course. Also, contrarily to my other answer, here the ...
4
A fairly general method, with a "simple macro" and a complex one that's completely customizable.
\documentclass{article}
\usepackage{xparse,amsmath}
\ExplSyntaxOn
% #1 = number of x's
% #2 = number of equations
\NewDocumentCommand{\makeequations}{O{2}m}
{
\egreg_makeequations:nnnnnn { x } { y } { A } { 1 } { #1 } { #2 }
}
\tl_new:N ...
6
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}}
...
5
You see? three answers already, almost immediately. Mine is comparatively tremendously complicated. I started in a certain direction, and wanted to get it done that way.
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand\CreateEquations[2]{%
\expandafter\@createequations@a\expandafter
{\the\numexpr #1\expandafter ...
6
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}
\\ ...
7
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 } \\ ...
4
Here's a way to do it, by using a regular array for alignment:
\documentclass{article}
\usepackage{multido}% http://ctan.org/pkg/multido
\begin{document}
\def\yeqns{}
\[\begin{array}{r@{}l}
\begingroup
\let\\\relax
\multido{\iKa=1+1,\iKb=2+2,\iKc=1+2}{10}{%
\xdef\yeqns{\yeqns% Gather equations for y
y_{\iKa} &{}= ...
3
In addition to my comments, there is also the /pgf/number format/int detect option for \pgfmathprintnumber.
Code
\documentclass[tikz]{standalone}
\usepackage{etoolbox}
\usetikzlibrary{matrix}
\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={
rectangle,
...
2
You can do everything you want with overlay specifications and the \againframe command. First of all, format the list like this:
\begin{enumerate}[<+-| alert@+>]
\item collect underpants
\item ...
\item profit!
\end{enumerate}
The +- specification says that each item should automatically increment the pause counter by one, and display that item ...
5
It also possible a bit less hacky. (pgf-manual p. 496) Look at this modified code:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\foreach \i in {1,2,...,6}
{
\draw[name path global/.expanded=line\i] (-3,\i) -- (3,-\i);
}
\draw[name intersections={of=line1 and line2}] ...
4
Besides percusse’s answer, using a \pgfmathtruncatemacro, here are a few other solutions:
uses eTeX’s \numexpr.
uses TikZ’ \foreach’s evaluate
uses the TikZ library chains with start chain=going below.
Code
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning,chains}
\begin{document}
\begin{tikzpicture}[node distance = 0.5cm]
\foreach \x in ...
9
You can use math :)
\foreach \x in {0,...,2}{
\ifnum\x=0\relax
\node (\x) {Block \x};
\else
\pgfmathparse{int(\x-1)}
\node (\x) [below= of \pgfmathresult.south] {Block \x};
\fi
}
Top 50 recent answers are included