# Tag Info

14

There is more than one problem with such a definition. The \def instruction has the following syntax: \def<cs><parameter text><left brace><balanced text><right brace> where <cs> is the control sequence or active character to define; <left brace> and <right brace> stand for explicit braces (character tokens ...

13

Here is a preliminary example (depending on what you are looking for) using a for loop, \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \def\repeatno{40} \node[inner sep=0.5cm,circle] (base) at (0,0) {}; \foreach \x in {1,2,...,\repeatno}{ \draw[rotate=(\x*360/\repeatno)-90] (base.\x*360/\repeatno) to [in=-70,out=70] ++(0,2) ...

13

This will most likely break everything, \jobname is used for all kinds of things like aux files and having commas and spaces in file names is tricky. Just use pdflatex \def\mycommand{a,b,c}\input myfile possibly needing to quote the \ or {} depending on your commandline processor.

12


12

The problem here is that the character must be already active when used for \def. The #1 argument however holds the same character in its previous catcode and this won't be affected by \catcode. There is a trick using \lowercase but I'm not sure if it works well with non-ASCII characters with normal LaTeX. You can use \scantokens (an eTeX extension ...

12

You could use the xstring package \documentclass{article} \usepackage{xstring} \newcommand{\mymacro}[1]{% \StrLeft{#1}{1}[\firstletter]% \StrRight{#1}{1}[\lastletter]% First letter: \firstletter Last letter: \lastletter } \begin{document} \mymacro{ABCDEF} \end{document} I’m a little busy so please excuse that I didn’t build it in ...

11

Here are 3 solutions using expl3, depending on your requirements. To perform the tests, I'd use \prg_case_int:nnn rather than an ad-hoc bunch of \ifthenelse statements: those are slower. (1) The simplest is to use \tl_head:n{#1} to access the first digit of the number, and \int_mod:nn {#1}{10} for the last one. This works for numbers less than 2^{31}, and ...

10

I'm not sure to really understand the question. First I draw a closed curve and then I rotated this curve but there are no difficulty to do this, perhaps I'm on a wrong way! First curves : the closed curve is named \myclosedcurve \documentclass[11pt]{scrartcl} \usepackage{tikz} \begin{document} \def\spirographlike#1{% \def\repeatno{#1} \foreach \i in ...

10

The following example uses the syntax that the arguments are given inside the argument for the command: \images{{...}{...}{...}{...}{...}{...}...}. The macro \images then parses its argument and catches three arguments at a time: \documentclass{article} \newif\ifimagesSep \newcommand*{\images}[1]{% \par\noindent[begin images]\\\relax \imagesSepfalse ...

10

You can have a variable number of items by rethinking your usage of a tabular and using an inline list. \documentclass{article} \makeatletter \newcounter{inline} \def\inlinelist#1{% \setcounter{inline}{0}% \@for\next:=#1\do{% \stepcounter{inline}% \alph{inline})\thinspace\next\space} } \makeatother \begin{document} ...

10

Or in classic TeX; the following defines \fst and \lst to be the first and last characters (or be empty for short input) \def\fl#1{\flx#1\empty\empty\empty} \def\flx#1#2#3\empty{% \edef\fst{#1}% \edef\cdar{#2}% \edef\cddr{#3}% \ifx\cddr\empty \let\lst\cdar \else \expandafter\flxx \fi #3} \def\flxx#1#2\empty{% \edef\car{#1}% ...

8

To scan a character at a time you need to use \futurelet (or its LaTeX wrapper \@ifnextchar) not a macro argument #1 then it is safe for {}. But for numbers I would just do this: \documentclass{article} \begin{document} \makeatletter \def\num{\afterassignment\xnum\count@} \def\xnum{the number was [\the\count@]} \num44 \emph{\num99} \end{document} ...

8

You have to define \dollarcom with a "stringified #": \documentclass{article} \usepackage{minted} \edef\dollarcom{\noexpand\mint{bash}/$\string#/} \begin{document} \dollarcom \mint{bash}|$#| \end{document}

7

As you correctly state, if all you need to do is store the user input, then a token list variable is the usual approach unless there is some 'structure' to think about. I would therefore define \NewDocumentCommand \myAssessments { O { I } O { cc } +m } { \tl_gset:Nn \g_myA_tl {#1} \tl_gset:Nn \g_myB_tl {#2} \tl_gset:Nn \g_myC_tl {#3} } ...

7

Here is a key-value interface. I use skeyval package instead of pgfkeys only because I wanted to preset keys. \documentclass{article} \usepackage{skeyval} \usepackage{tikz} \usetikzlibrary{shapes.geometric} \makeatletter % Spurious spaces will appear in the following methods in horizontal % mode, but TikZ doesn't mind them. The star (*) form of \directkeys ...

6

The etextools package provides an expandable \ifempty{<text>}{<true>}{<false>} macro which works with newlines. If you don't need the test to be expandable you can also use the following code: \newcommand{\mymacro}[1]{% \begingroup \def\temp{#1}% \ifx\temp\empty \endgroup % empty \else \endgroup % ...

6

I have a solution, though it's not quite what I had envisioned. From the answers (and lack of answers) I have come to believe that continuous rotations are not a built-in feature of tikz, so I took the suggestions of Jake and Altermundus to just program in all the math calculations myself using polar coordinates. Below is my solution and its output. % ...

6

Try \StrRight in the xstring package: \documentclass{article} \usepackage{xstring} \def\getYear#1{\StrRight{#1}{4}} \begin{document} \noindent\getYear{12.12.2012}\\ \getYear{2012} \end{document} with result:

6

I do not know the purpose and format of the "number". There are many variants what can be considered a number: Explicit number consisting of digits 0 up to 9. TeX number, that includes count registers, internal numbers given by primitives (\inputlineno, \value{page}, \numexpr), even dimensions (\textwidth) can be interpreted as numbers. This solution ...

6

This depends on the font size selected for the document class or within the text and whether you're in \twocolumn or not (at least, for the default document classes). For the exact lengths, you need to view size10.clo, size11.clo, size12.clo in conjunction with the document class you're using. The following minimal example lists these totals for the various ...

5

You could define a starred and unstarred macro so that \mytabs uses \tabfour and \mytabs* uses \tabfive. A good reference for this is Defining starred versions of commands. However, I would recommend you use the inline list feature from the enumitem package: \documentclass{article} \usepackage[inline]{enumitem} \begin{document} ...

5

What about this (plain-TeX) code? (Note: I did it in 5 minutes without thorough testing, there might be some bug, but it seems to work. Also, I used exactly your idea of a tail-recursive structure.) \documentclass{article} \newcount\takeargscount \def\takeargs#1{% \takeargscount=#1 \ifnum\takeargscount>0 \expandafter\dotakeargs \fi } ...

5

user1189687 already proposed a solution that I think is better, but since I already begun to write this, here is if you want a plain tex solution : The point here is to recognize that you are in the first case or in the other. As @Kurt pointed out, it is trivial to do if you know the format of your input. But here, apparently you don't. So what I would ...

5

You can avoid this error by modifying your class definition as follows: \ProvidesClass{UGentCourse}[2011/07/28 v1.0 UGentCourse] \DeclareOption{english}{\AtEndOfClass{\main@language{english}}} \DeclareOption{dutch}{\AtEndOfClass{\main@language{dutch}}} \DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}} \ProcessOptions\relax ...

5

You can use the etoolbox to set up a boolean which is either true or false \newbool{hidetrafficlight} \setbool{hidetrafficlight}{false} and then depending on what value it takes, use \AtBeginEnvironment from the etoolbox to comment out the environment using comment from the verbatim package % set conditional behaviour of environment ...

5

You seem to want to centre a v between two (decorated) boxes. The usual way is \fbox{one}\hfill v\hfill\fbox{two} Not sure what other hints one could give without some more context. If you do want to experiment with lengths then stick the whole page layout in a macro so \def\test#1{% \clearpage \noindent\fbox{one}\rlap{\hspace{#1}v}\hfill\fbox{two}% ...

4

The \isempty test expands its argument; you may try \ifthenelse{\isempty{\unexpanded{#1}}}{<true>}{<false>} or resort to a different test like \ifx\relax\detokenize{#1}\relax <true>% \else <false>% \fi In both cases #1 stands for the argument you want to test.

4


4

\newcommand{\iitthesis@thesisdatafield}[2]{% \@namedef{iitthesis@#1}{#2}} With \iitthesis@thesisdatafield{authorEnglish}{Name of Author} you'd define \iitthesis@authorEnglish to expand to "Name of Author", that is, you'd have issued the equivalent of \def\iitthesis@authorEnglish{Name of Author} This wouldn't check for the defined command to be ...

4

use multiples of \baselineskip and in tabulars/arrays \normalbaselineskip \documentclass{scrartcl} \usepackage{mathtools} \begin{document} \begin{spreadlines}{2\baselineskip} \begin{align*} \pi(\mu \mid x) &= \frac{\pi(\mu)\,\mathcal{L}(x \mid \mu)}{p(x)} \\[\normalbaselineskip] &= \begin{dcases*} ...

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