# Tag Info

18

There are several ways to accomplish your need. Here's one with expl3: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\skillAdj}{m} { \int_case:nnn { #1 } { {8}{Legendary} {7}{Epic} {6}{Fantastic} {5}{Superb} {4}{Great} {3}{Good} {2}{Fair} {1}{Average} {0}{Mediocre} ...

10

One more TeX \ifcase version, without extra ifnum: \def\skillAdj#1{% \count255=8\advance\count255by-#1 % \ifcase\the\count255 % Legendary% \or Epic% \or Fantastic% \or Superb% \or Great% \or Good% \or Fair% \or Average% \or Mediocre% \or Poor% \or Terrible% \or Awful% \or Abysmal% \else Error% \fi% } \def\test#1{#1 \skillAdj{#1}} \obeylines\tt \test{+8} ...

9

You could also use TeX's in-built \ifcase construct as follows- no packages necessary! % arara: pdflatex \documentclass{article} \newcommand{\skillAdj}[1]{% \ifcase\numexpr#1+4\relax Abysmal % -4 \or Awful % -3 \or Terrible % -2 \or Poor % -1 \or Mediocre % 0 \or ...

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 } \\ ...

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} \\ ...

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}} ...

6

Other answers have exploited the numeric character of one of the member of the correspondance. Here is a method which establishes a bidirectional correspondance. It does use the numeric character of the levels to allow some flexibility in the input, like using a count register, or having arithmetic operations on them (uses the e-TeX \numexpr) The code uses ...

5

The following is a mild modification to PGF/TikZ: How to store strings in array? The adjustment accommodates for negative values (excluding a count of the elements since it may not be required): \documentclass{article} \usepackage{etoolbox}% http://ctan.org/pkg/etoolbox \newcounter{listtotal}\newcounter{listcntr}% \newcommand{\skilladj}[1]{% ...

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 ...

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} &{}= ...

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 ...

3

Looking at the source exam class would need quite a few changes to use repeated numbers as it uses the number counter internally in several places. However to help anyone else answering and to address other problems in the posted document here is a start at a solution. You shouldn't use star form for numbered sections, and \numberwith should only be used ...

3

\documentclass{report} \usepackage{thmtools} \declaretheorem[ style=mydefinitionstyle, name=Definition, numberwithin=chapter ]{definition} \declaretheorem[ style=mydefinitionstyle, name=Definition, numberwithin=definition, ]{definitionAlt} \renewcommand\thedefinitionAlt{\thedefinition\alph{definitionAlt}} \begin{document} ...

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 ...

2

This solution uses a different approach and was written as answer for question "Listings: total line number count" that was closed too fast. This solution uses a different approach than my other answer: Also a label is used to remember the number of code lines. This variant uses package zref for this purpose. The number of code lines is made available by ...

1

This is an example that I have generated based on the answer by Steven B. Segletes, all credit goes to him. You can pass the label of the lemma as the argument in the following while issuing \deferlemma and then use the same label to recall using \recalllemma \documentclass[12pt]{article} \usepackage{amsmath} \newcounter{lema}\setcounter{lema}{0} ...

1

I don't use lemmas, but if they use a numbering scheme like equations, then you should be able to adapt this. I show here how to defer the presentation of equations, while preserving the numbering when they were "conceived." I create a \defereqn command to "conceive" an equation (give it a number and remember it) without printing it. I also have the ...

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