# Tag Info

2

I on purpose left other answers first, for mine to be be listed on top ;-) \documentclass{article} \usepackage{biocon} %\usepackage{ifthen}% already loaded by biocon \newcommand*\OnlyFirstPlantFamily [1]{% \expandafter\ifx\csname OnlyFirst@\csname P#1@family\endcsname\endcsname \relax \space(\plant[Family]{#1})% ...

1

We can also simplify the syntax, by providing a command \plantF that automatically adds the family name, provided it's not the same as the last family that has been typeset. The idea is the same as yours, but we need to delve into the internals; in particular, the family name for araca is stored in \Paraca@family. \documentclass{article} ...

1

This will not work. \plant[Family]{acafrao} is very complicated command and absolutly not expandable and you can't use it in ifthenelse. You can try something like this, but I don't know the package and so I'm only guessing that it will work: \documentclass{article} \usepackage{biocon} \usepackage{ifthen} \begin{document} \newtaxon{family} ...

4

You can do it also without any package. The trick is that the argument to \section is passed as a braced group to the final part of the code, so if that part ends with a macro taking an argument, it will see the section title; but you first need to remove the braces. Note that defining the inner macro with three arguments we can easily add the final period. ...

5

You have to capture the argument before passing it to \bl. Below we capture it using \@bl before passing it to \bl: \documentclass{article} \usepackage{titlesec} \makeatletter \def\@bl#1{\bl#1} \def\bl#1 #2 {#1\textsuperscript{#2}\,} \titleformat{\section}[runin]{}{}{0pt}{\@bl}[. ] \makeatother \begin{document} \section{3 a 21} main text. \end{document} ...

2

This might qualify as "dirty": \documentclass{article} \usepackage{titlesec} \def\bl#1 #2 {#1\textsuperscript{#2}\,} \titleformat{\section}[runin]{}{}{0pt}{}[. ] \let\oldsect=\section \def\section#1{\oldsect{\bl#1}} \begin{document} \section{3 a 21} main text. \end{document}

1

Here's a LuaLaTeX-based solution. It defines two fully-expandable "wrapper" macros named \mycmd and \mkfirstuc, which pass their arguments to Lua functions named mycmd and mkfirstuc. The Lua functions perform the actual work of prefixing "an " or "a " to a string and of upper-casing the first character in the string, respectively. % !TEX TS-program = ...

5

Here's an approach with expl3 \documentclass{article} \usepackage{xparse,glossaries} \ExplSyntaxOn \DeclareExpandableDocumentCommand{\indef}{m} { \str_case_x:nnF { \tl_head:f { \tl_lower_case:n { #1 } } } { {a}{an} {e}{an} {i}{an} {o}{an} {u}{an} } {a}~#1 } \ExplSyntaxOff \begin{document} \indef{abc} --- \indef{cde} --- ...

5

This is easy enough using expl3 (there are several possible approaches): \documentclass{article} \usepackage{expl3,xparse} \ExplSyntaxOn \DeclareExpandableDocumentCommand \mycmd { m } { \__mycmd_loop:nN {#1} aeiouAEIOU \q_recursion_tail \q_recursion_stop } \cs_new:Npn \__mycmd_loop:nN #1#2 { \quark_if_recursion_tail_stop_do:nn {#2} { a } ...

1

Is this what is meant? It is not the most effective usage of expl3, I know ;-) \documentclass{article} \usepackage{xparse} % used in example below \usepackage{pgffor} % used in example below \usepackage{xstring} % used in example below \ExplSyntaxOn \clist_set:Nn \l_tinytot_lowercaseletters_clist {a,e,i,o,u} \clist_set:Nn \l_tinytot_letters_clist ...

5

You're not passing a set of options but something that contains a set of options. The error message is a bit misleading, because the expansion takes place when issuing the error, so it appears you have passed the right options. No key-value based package performs expansion when absorbing key-value pairs, because it could be disastrous. So the solution is to ...

4

Is this what you have in mind? The \definesizecommand macro is able to define a command that behaves differently in the various sizes. This command can also have arguments, as shown by \baz. \documentclass{article} \usepackage{relsize} \usepackage{xparse} \ExplSyntaxOn % relsize builds a list \rs@fontsizes of the form % ...

5

I'd just query \@currsize. \documentclass{article} \makeatletter \newcommand\queryfont[3]{% \ifx\@currsize#1 #2% \else #3% \fi } \makeatother \begin{document} \queryfont\small{This is small}{This is not small} \small \queryfont\small{This is small}{This is not small} \end{document}

4

{\small \f@size} is not a number. You should better store the f@size-value first: \documentclass{article} \usepackage{ifthen} \begin{document} \makeatletter \ifthenelse{\f@size=9}{the size is 9}{the size is not 9} \makeatother \makeatletter \small \ifthenelse{\f@size=9}{the size is 9}{the size is not 9} \makeatother \makeatletter {\small ...

3

I've stored the font size \f@size of \small first (before \begin{document} and use \ifthenelse{...} to compare this with the current size. \documentclass{article} \usepackage{xifthen} \makeatletter {\small\xdef\smallfontsize{\f@size}} \makeatother \begin{document} \makeatletter \large \ifthenelse{\f@size = \smallfontsize }{the size is small}{the size ...

1

The LaTeX kernel has some non publicized programming tools, such as while loops. The more well-know \loop is not appropriate here inside the tabular for a number of reasons, one being that it makes a local definition which will get lost, the other one is that \cline also uses \loop and this would clash. Here is a one-liner to get user access to one LaTeX ...

4

It is imho not a good idea to redefine such accent commands. But in your case you can make \turc robust: \documentclass{scrartcl} \usepackage{natbib} \let\turc\c \usepackage{etoolbox} \robustify\turc \renewcommand{\c}{\ensuremath{c^\pi}} \begin{document} \citep{ABC} \bibliographystyle{plainnat} \bibliography{lit} \end{document}

2

When you do \let\turc\c you are essentially defining \def\turc{\OT1-cmd \c \OT1\c} Note that \OT1-cmd is a single control sequence, as well as \OT1\c; they can't ordinarily be written or used without special tricks. Simplifying a bit, the purpose of \OT1-cmd is twofold: during normal typesetting, it ignores the following \c token and uses \OT1\c, which ...

5

Your code doesn't work because you're issuing \makeatletter at the wrong time; category codes are not changed when tokens have already been absorbed. You need \makeatletter \section{\textbackslash section\f@size pt} \makeatother but it's better to use a specific macro. \documentclass{article} \newcommand{\cs}[1]{\textbackslash #1} \makeatletter ...

1

Please refer to the MEW instructions to have a consistent one. This is an expl3 based solution. To switch the rowcolor, the compiler should be informed if the new insertion is (or not) a weapon subtype. In such case, it have to hold on the previous rowcolor. Otherwise, it switches it. The compiler is informed about subtypes via \weapon*. ...

5

\in@ doesn't expand its arguments; you can easily define a new macro \ein@ that expands (once) its argument: \documentclass{article} \def\myvar{foobar} \makeatletter \def\ein@#1#2{% \expandafter\ein@@\expandafter{#2}{#1}% } \def\ein@@#1#2{\in@{#2}{#1}} \makeatother \begin{document} \makeatletter \in@{foo}{foobar}\ifin@ Yes\else No\fi, ...

5

Several ways, one way to do it with two \expandafter is \documentclass{standalone} \def\myvar{foobar} \begin{document} \makeatletter \in@{foo}{foobar}\ifin@ Yes\else No\fi, \def\zz{\in@{foo}} \expandafter\zz\expandafter{\myvar}\ifin@ Yes\else No\fi \makeatother \end{document}

Top 50 recent answers are included