Tag Info

New answers tagged

1

I'd suggest you to use a customized list defined with the help of enumitem and some \parboxes to include the information for every work: \documentclass[draft]{article} \usepackage[T1]{fontenc} \usepackage{enumitem} \usepackage{calc} \newcommand\WorkFont{\bfseries\raggedright} \newcommand\WorkNameStyle{\upshape} \newcommand\numberstyle{\scshape} ...


3

It's with a bit of plain e-TeX to make it without the extra braces. The maximal value allowed here is 1073741823000, the minimal one is 1000 (or less if you make it at least 4 digits, I hope you fit in that. In can be extended by x digits, but only in case that all your numbers have at least x digits. \documentclass{article} \newcount\OIDcounta ...


0

This is a quick-and-dirty tabularx approach, with automatic - at the first column. The widths of the columns etc. are just guesses, as well as the font commands. \documentclass{article} \usepackage{tabularx} \newcommand{\WorkFont}{\bfseries} \newcommand{\WorkNameStyle}{\upshape} \newcommand{\numberstyle}{\scshape} \newcommand{\worklistfont}{\itshape} ...


1

you can try something like this \newenvironment{work}[3]{% #1\hfill #2\\*#3 \begin{list}{-}{% \settowidth{\rightmargin}{#2}}}{% \end{list}}


1

Here is another approach which doesn't allocate the new name \etaorig: \edef\eta{\noexpand\ensuremath{\mathchar\the\eta\space}}


4

Regardless whether it's useful or not, as a shortcut without $...$ it's possible to redefine \eta, but it's necessary to store the meaning of \eta before (making a copy) using \let. My statements are of general nature, I do not really recommend to use \eta in this way. \documentclass{article} \newcommand{\pt}{\ensuremath{p_T}} \let\etaorig\eta% ...


2

Not sure of your full intent, but perhaps something like this. As egreg pointed out in the comments, enumerate was already taken; and as I pointed out, the occurrences of #1 in the definitions of \itemdef and \itemex had to be recast as ##1, since they occurred in the context of environment usages. \documentclass{article} \newcounter{usagenumber} ...


1

The macro discussed here is very curious mix of plain TeX and LaTeX approach. In pure plain TeX it can look like: \def\tableau#1{\vbox{\offinterlineskip \let\\=\cr \ialign{&\cellify{##}\cr #1\crcr}}} \def\cellify#1{\ifx^#1^\else \vbox{\kern-.2pt\hrule \hbox to18pt{\kern-.2pt\vrule height12pt depth6pt\hss#1\unskip\hss\vrule\kern-.2pt} ...


5

TeX uses macro replacement as its fundamental concept. When you say \newcommand{\foo}{<whatever>} you're instructing the program to replace every occurrence of \foo with <whatever>. In order for that \newcommand to work, the command \foo must be undefined at the moment \newcommand is performed. So with \newcommand{\mr}{\mathrm} you are ...


3

If you need to declare the macro with one or two parameters \vecbi{A} or \vecbi{B}{s}, then you have to say what is the signal of the presence of second parameter. For example the signal is the open { used immediately after the first parameter without space between them. Then you can use this: \def\vecbi#1{\def\tmp{#1}\futurelet\next\vecbiA} ...


7

The command \vecbi should be defined without arguments: \documentclass{article} \usepackage{amsmath,bm} \makeatletter \newcommand\vecbi{\@ifstar\vecbiu\vecbin} \newcommand\vecbiu[2]{\bm{#1}_{\textnormal{#2}}} \newcommand\vecbin[1]{\bm{#1}} \makeatother \begin{document} $\vecbi*{A}{s} * \vecbi{A}$ \end{document} I have replaced the obsolete \boldsymbol ...


4

You had the #1 #2 #3` in the wrong order, and an unused optional argument. Here I show two forms \nonBranchingRule with three mandatory arguments and \nonBranchingRuleB where the rule argument is optional argument given first, in []. \documentclass[11pt]{article} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} ...


2

I have managed to solve it by using \@bsphack \@esphack in command definition. The modified mulan.sty is as follows. % Multi-language support package<mulan.sty> % Copyright 2015~2015, JILONG YIN % JILONG YIN <yinjilong@gmail.com> % The Current Maintainer of this work is JILONG YIN. % % ...


2

No need to change the internals of sepfootnotes: an \aftergroup trickery is sufficient. \documentclass{article} \usepackage{environ} \usepackage{sepfootnotes} \NewEnviron{nbp}[1]{% \xdef\nbptemp{{#1}{\unexpanded\expandafter{\BODY}}}% \aftergroup\donpb } \newcommand{\donpb}{\expandafter\sepfootnotecontent\nbptemp} \begin{document} ...


3

There are two problems: the marco \sepfootnotecontent saves its contents locally which means it is forgotten after the environment ends. The second problem: the macro \BODY is saved as footnote content but what you really want is it the first expansion of \BODY and not the macro itself. With the help of the etoolbox package and its \patchcmd we can easily ...


2

To explain it more detailled as in @Andrew's comment (there a some curly braces missing at the end). I will explain it in two ways: the LyX and the LaTeX coding way. LyX macro input Insert a new blank macro by clicking on menu "View > Math > Macro". A macro field with prefilled macro name "\newmacroname" is inserted: Change "\newmacroname" to the name ...


2

I don't know why you want this, but... \documentclass{article} \newcommand\mulan[5]{% #1#4#2#5#3% }% \newcommand\mulanr[2]{% \mulan{\ignorespaces}{/}{\ignorespaces}{#1}{#2}% }% \begin{document} \section{TitleA/TitleB} \section{\mulanr{TitleA}{TitleB} } test \end{document}


6

Let's start from the main part: \ialign{&\cellify{##}\cr#1\crcr} As usual, #1 will be replaced by the argument given at call time, so it's not very relevant. The macro \ialign is defined in Plain TeX as \everycr{}\tabskip\z@skip\halign so it's an “initialized” \halign, where some parameters are cleared. The important object is the primitive ...


12

## in a macro definition puts # in the replacement text (which is why ##1 puts the required #1 in a nested definition). So if the argument of \cellify is X then when that is expanded, #1 is replaced by X and ## is replaced by # so \ialign{&\cellify{##}\cr#1\crcr} expands to \ialign{&\cellify{#}\cr X\crcr} \ialign is a command defined in ...


1

For example you can save the \ad labels into the \afflist macro and you can use these labels from \afflist when \aff is used. This means that you needn't to repeat the labels again and the \aff macro is used without parameter. \def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}} \def\ad#1{$^{\rm #1}$\global\addto\afflist{{#1}}} \def\aff{% ...


2

Whether this is intended to be accessible and will remain usable in the future I am not sure, but I have found that the glossaries package makes some fields accessible using commands formated similar to \glsentryshort{} and \glsentrylong{}. Most importantly, using these commands doesn't artificially trigger a counter that would prevent the appropriate first ...


2

The main problem here is with the line \kern\the\prevdepth % don't take into account the depth of the preceding line in the definition of \myrule. To understand the problem, look at what The TeXbook (double dangerous-bend at the bottom of page 79) says about \prevdepth: However, \prevdepth is set to the sentinel value −1000pt at the beginning of a ...


4

I propose a syntax with a *-variant rather than the \not prefix. \documentclass{article} \usepackage{amsmath,amssymb} \usepackage{xparse} \NewDocumentCommand{\newrelation}{mmo}{% % #1 is the command to define % #2 is the relation to be used % #3 (optional) is the alternative \IfNoValueTF{#3} {\NewDocumentCommand{#1}{smm}{% ...


1

Set up work is required, but it can be done. In essence, you have define various macros that perform the desired "A symbol B" for various symbols, and then you must define \negate to know how to negate each of these symbols, in turn. \documentclass{article} \usepackage{stackengine,xcolor,mathtools} \def\eqsym{=} \def\gtsymbol{>} \let\svmid\mid ...


2

You need to use the \noexpandarg mode of xstring, so it won't try expanding its arguments: \documentclass{article} \usepackage{xstring} %\noexpandarg % set \noexpandarg globally \newcommand{\TRANSFORM}[1]{% \saveexpandmode\noexpandarg % set \noexpandarg locally \StrSubstitute{#1}{\textbackslash{}}{\\}% \restoreexpandmode % restore the previous mode ...


5

You could just temporarily redefine the meaning of \textbackslash, letting it to \\: \documentclass{article} \newcommand{\TRANSFORM}[1]{{\let\textbackslash\\#1}} \setlength{\parindent}{0pt}% Just for this example \begin{document} Hello\textbackslash{}Bye \TRANSFORM{Hello\textbackslash{}Bye} \end{document}


4

Use the comment package: \documentclass[letterpaper,12pt,addpoints]{exam} \usepackage{comment} \excludecomment{choices} \title{MWE} \begin{document} \maketitle \begin{questions} \question What is your favorite color? \begin{choices} \CorrectChoice Green \choice Yellow \choice Red \end{choices} \end{questions} \end{document} You just need to comment out ...


5

My solution doesn't need any external package. The \showcat\macro is implemented. After \def\test{ger{$##m}a~n \relax \foo} \edef\curentry{\string german \relax} \showcat\test \showcat\curentry we get the result: \test -> the letter g (catcode 11) the letter e (catcode 11) the letter r (catcode 11) begin-group character { (catcode 1) ...


0

Ok, I finally got somewhere, though maybe not ideal. The below MWE behaves like this: If compiled with pdflatex test.tex, the comment stuff is ignored, and the document compiles fully; but there will be these two warnings generated in the log (don't know how to fix that): (\end occurred inside a group at level 2) ### semi simple group (level 2) entered ...


5

The experimental package l3tl-analysis does what you ask for. \documentclass{article} \usepackage{xparse,l3tl-analysis} \ExplSyntaxOn \NewDocumentCommand{\checktokenbytoken}{sm} { \IfBooleanTF{#1} { \tl_show_analysis:n { #2 } } { \tl_show_analysis:N #2 } } \ExplSyntaxOff \edef\xgerman{\string german\relax} ...


14

You can load the datetime package and declare \ddmmyyyydate MWE: \documentclass{article} \usepackage{datetime} \usepackage{advdate} \begin{document} \ddmmyyyydate \AdvYear{10} \today \end{document} Output:


1

I started with the \ifcase code from OP and added two lines in order to create expandable \euppercase macro. \def\euppercaseB#1{\ifcase`#1\relax 0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or 9\or 10\or11\or12\or13\or14\or15\or16\or17\or18\or19\or 20\or21\or22\or23\or24\or25\or26\or27\or28\or29\or ...


2

You can use the following code somewhere in the preamble after \documentclass. \def\doskipA{\begin{document}\end{document}} \ifx\doskip\relax \expandafter\doskipA\fi


0

TOTALLY REVISED ANSWER: It obviously has limitations in terms of what types of arguments it can digest, but it is expandable. \documentclass{article} \newcommand\caseupper[2]{\caseupperhelp{#1}#2\relax\relax} \def\caseupperhelp#1#2#3\relax{% \ifx a#2A\else \ifx b#2B\else \ifx c#2C\else \ifx d#2D\else \ifx e#2E\else \ifx f#2F\else \ifx g#2G\else ...


3

Here is an example how to do this at TeX primitive level. The \romantonum macro is defined here with usage \romantonum{mmcdvii}. This prints 2407. \newcount\tmpnum \def\romantonum#1{\tmpnum=0 \lowercase\expandafter{\expandafter\romantonumA#1\end{}}\the\tmpnum} \def\romantonumA#1{\ifx#1\end\else \ifx#1m\advance\tmpnum by1000 \let\next=\romantonumA ...


3

I understand that you need \def but with parameters like \newcommand. It is possible to define our own\newcommand which ignores if the defined control sequence has a meaning. For example we can use the code from this page: \def\newcommand#1{\isnextchar[{\newcommandA#1}{\newcommandA#1[0]}} \def\newcommandA#1[#2]{\edef\tmpp{\ifcase#2% ...


1

Since the classic examples have already been shown, I'll just add the xparse way, which is quite user-friendly: \documentclass{article} \usepackage{xparse} \DeclareDocumentCommand{\foo}{m} {Foo: #1} \begin{document} \foo{bar} \DeclareDocumentCommand{\foo}{om} {\IfNoValueTF{#1}% {Bar: no optional, just #2}% {Bar: optional = #1, plus #2}% }% ...


4

Yes, there is a method: \newcommand{\declarecommand}[1]{\providecommand{#1}{}\renewcommand{#1}} Why does it work? Because TeX uses macro expansion and it's irrelevant what \providecommand defines #1 to be, if #1 wasn't defined, because you redefine it immediately. Now that you know how to do it, try \declarecommand{\box}[1]{\fbox{#1}} and enjoy the ...


2

You shouldn't be using the species' name macro in the title, because it surely mustn't be considered the first appearance. Having a macro in the title is to be avoided because publishers may want to use \title for automatically producing a Web page. In my opinion you shouldn't be using \spacedallcaps in the title, too. If the paper is for personal use ...


1

May be too late but i find that we can do this with just grouping \begingroup \input{author1-customization} \input{author1-source} \endgroup % \begingroup \input{author2-customization} \input{author2-source} \endgroup % \begingroup \input{author3-customization} \input{author3-source} \endgroup


5

You can't use \bgroup for delimiting a mandatory argument. And you want leaders to fill up the page with copies of what you absorbed. \documentclass{article} \newenvironment{double} {% \par % be in vertical mode \setbox0=\vbox\bgroup % start a box \strut % ensure good height for the first line \ignorespaces % ignore the end of line } {% ...


2

The following might suit you: \documentclass{article} \usepackage{etoolbox,xparse} \ExplSyntaxOn \cs_new_eq:NN \CALC \fp_eval:n \ExplSyntaxOff \newcounter{argcnt} \makeatletter \newcommand{\newarray}[2]{% \newarray{<array>}{<csv list>} \setcounter{argcnt}{0}% Restart argument count \renewcommand{\do}[1]{% With each element do... ...


1

Is this something like what you mean? Perhaps this could get you started. \documentclass{article} \newcommand{\twothings}[2]{% \gdef\thingone{#1} \gdef\thingtwo{#2} } \newcommand{\pickone}[1]{% \ifnum#1 = 1 \thingone \else \ifnum#1 = 2 \thingtwo \else \relax \fi \fi% } ...


11

You can probably mess directly with TeX's hash table from lua but simpler is just to get lua to write out the \let statements. > \b=macro: ->s. l.10 \show\b ? > \c=macro: ->s. l.11 \show\c ? ) No pages of output Produced from: \def\a{s} \directlua{ x = {"b","c"} for n,y in pairs(x) do tex.print("\string\\let\string\\" .. y .. ...


6

My solution introduces the macro \singledef which defines control sequence (like \def) but provides two more features: it checks if the control sequence is defined. If yes, then error message is printed and the control sequence keeps its original meaning. it saves the name of defined control sequence into the \singledeflist internal macro. When the next ...


5

If you are drawing trees, I urge you to look at forest which is extremely powerful and uses a similar syntax to tikz-qtree/qtree. It also has a built in style for missing nodes: \documentclass[tikz]{standalone} \usepackage{forest} \begin{document} \begin{forest} [3 [1 ] [,phantom ] ] \end{forest} \end{document} If ...


0

Here is an unsuccessful answer. Perhaps someone can show how to fix the comparison in \TestNewSymbol so that it actually identifies duplicates. Otherwise I suppose this will demonstrate why this approach does not work! \documentclass{article} \usepackage{pdftexcmds} % Create an "array" of symbols with increasing numbers in their names. % E.g., ...


2

@egreg has shown how to compare two fully expanded strings (On testing two fully expanded character strings for equality), and you could apply his technique here. I have added an error message in case you reuse a symbol. \documentclass{article} \usepackage{pdftexcmds} \newcommand{\symbolI}{A} \newcommand{\symbolII}{\pi r^2} \newcommand{\symbolIII}{\pi ...


1

Adding the following code to the preamble fixes the problem: \makeatletter \let\old@@children\@@children \def\@@children{\futurelet\my@next\my@@children} \def\my@@children{% \ifx\my@next\edgeweight\else \expandafter\@gobble \fi \expandafter\old@@children} \makeatother This solution is due to David Carlisle and is taken from here. Congrats to the guy who ...


10

One possible implementation with a declared function using the math library of TikZ: \documentclass[tikz]{standalone} \usetikzlibrary{math} \tikzmath{function myscalefun(\a,\b,\c) { if \a>10 then { return \a; } else { if \b>10 then { return \b; } else { return \c; }; }; };} \begin{document} \begin{tikzpicture}[scale=1] \clip (0,0) ...



Top 50 recent answers are included