# Tag Info

13

In general, there is no starred version of a command. What really happens is that the unstarred command checks to see if there is a star as the first argument and passes control to different auxiliary macros accordingly, or simply executes two different sets of commands. So, to take a random example, we look at \endlargethispage and find that it is defined ...

11

This is not basically possible, and I'll try to explain why, on an example. Let's \show\section: \section=\long macro: -> \@startsection {section}{1}{\z@ }{-3.5ex \@plus -1ex \@minus -.2ex}{2.3ex \@plus .2ex}{\normalfont \Large \bfseries } Ok, not much to see, other than that \section takes no arguments at all! So let's \show\@startsection: ...

11

You were almost there... If you want to compare real numbers you have to compare dimensions, so use \ifdimless instead of \ifnumless like in the following example: \documentclass{article} \usepackage{etoolbox} \newcommand{\checknum}[1]{% \ifdimless{#1pt}{.01pt}{$p < 0.01$}{$p = #1$}% } \begin{document} \checknum{0.45} \checknum{0.01} ...

10

You might like \ifcase ...\or...\fi for this situation- here's a complete example to play with % arara: pdflatex % !arara: indent: {overwrite: yes} \documentclass{article} \newcommand{\mycommand}[1]{% \ifcase#1 Some text, because it's zero \or Some other text, because it's one \or Some other text, because it's two % keep going ...

7

You can do much better: a \newcasecommand that can deal with arbitrary labels, not only numbers. \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\newcasecommand}{ m m O{No~default~value} } { \cs_new_protected:Npn #1 ##1 { \str_case:nnF { ##1 } { #2 } { #3 } } } \ExplSyntaxOff \newcasecommand{\mycommand}{% ...

6

In your \else branch you have \else \RequirePackage{iftex} \ifLuaTeX\RequirePackage{fontspec}\fi \ifXeTeX \RequirePackage{fontspec}\fi Now \ifXeTeX is an undefined command which is OK as this is being skipped but the \fi is \fi so terminates the outer \ifodt and things go wrong. Never define conditionals within a TeX primitive \if.. as this always ...

5

You have to delay the conditionals when (and if) the iftex package has been loaded. \NeedsTeXFormat{LaTeX2e}[1996/06/01] \ProvidesClass{myclass}[2013/12/15 v0.1 My Class] \newif\ifodt \DeclareOption{odt}{\odttrue} \ProcessOptions\relax \LoadClass{article} \ifodt \RequirePackage[utf8]{inputenc} \RequirePackage[T1] {fontenc} \expandafter\@gobble ...

5

It's easier if you say what suffix to add when you define the macro for the name; if the name ends with a letter requiring an apostrophe, use \newname* for defining the macro, otherwise use \newname. \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[ngerman]{babel} \makeatletter \newif\if@apostrophe ...

5

You can use the l3fp module of LaTeX3: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\fpcompare}{mmm} { \fp_compare:nTF { #1 } { #2 } { #3 } } \ExplSyntaxOff \begin{document} \newcommand{\checknum}[1]{% \fpcompare{#1 < .01}{$p < 0.01$}{$p = #1$}% } \checknum{0.45} \checknum{0.01} \checknum{0.005} ...

4

This can be a solution. I've used the command \IfSubStr* from the xstring package to see if inside the 5th argument we have the words "delimN" or "delimR" (in the number list, \delimN is a command that expands to , and \delimR expands to --) which, with the help of a new \if, determines where to print pp and where to print p. If "delimN" or "delimR" are ...

3

The following MWE uses environ to define the exercise environment and then condition on whether or not to set its contents (\BODY). The condition is set to true at the start of bank, and set to false after setting the first \BODY. \documentclass{article} \usepackage{environ}% http://ctan.org/pkg/environ \newif\iffirstexercise% Condition for first exercise ...

3

Here is an implementation using environ and expl3. With environ we absorb the whole environment's contents and with l3regex we check whether the environment contains the tokens \label{table_ via the regular expression \c{label}\cB.table_ Where \c{<string>} matches the control sequence with name <string> and \cB. matches one open brace. ...

2

I don’t know about the clipped path or the rectangle at the bottom. But you can easily draw a randomized line on one path. I am using the coordinate c-0 and c-1 as a reference for the rand factor instead of using the pt units this calculation will be based on the Coordinate System by PGF/TikZ. Code \documentclass[tikz]{standalone} \usetikzlibrary{calc} ...

2

Just collect all the else statements together to save on typing and errors, as shown below. Then simply you only need to change one line of the code for the false, i.e., PIECESfalse. \documentclass{article} \usepackage{lipsum} \begin{document} \newif\ifPIECES \PIECEStrue \section{Lorem ipsum dolor} \lipsum[1] \ifPIECES This is small piece. I want this ...

1

Because your exercise is unspecified, the code is changed a little. \documentclass{article} \usepackage{exercise} \begin{document} \long\def\bbank#1 STOP #2\ebank{#1} %\begin{bank} \bbank %\begin{exercise} $2+2$ %\end{exercise} % No new paragraph STOP %\begin{exercise} $4+3$ %\end{exercise} %\end{bank} $4+3$ \ebank \end{document} ...

1

The per-item testing should be performed when setting the item, rather than in the header, since the filter are set globally. From the csvsimple documentation: \csvfilterreject All following data lines will be ignored. This command overwrites all previous filter settings. \documentclass{article} \usepackage{csvsimple,filecontents}% ...

1

The csvrow counter is used for accepted input lines (after filtering). If you want to count line numbers of the input file to build a filter on it, you should use the counter csvinputline: \documentclass{article} \usepackage{csvsimple,filecontents} \begin{document} \begin{filecontents*}{chunk.csv} AAAA,aaaaa BBBB,bbbbb CCCC,ccccc DDDD,ddddd EEEE,eeeee ...

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