# Tag Info

## New answers tagged macros

3

you can use \scrollmode or \batchmode so that TeX does not stop on errors but it would be a really bad idea to do so. The class should simply predefine constructs like \author if you have \def\author{your name goes here} in the class then you get that text unless the user sets author, or you could instead have \def\author{\ClassWarning{MG}{author name ...

1

Put the mouse on the PDF that is open by texstudio, then RIGHT-CLICK the mouse. This open a window like this: Which is on top of the PDF, like this click on the "Go to Source" To go from Source to PDF, put the mouse on the source file open, and RIGHT-CLICK, this will open a menu like this: Click on the Go to PDF to go the PDF file location of the ...

0

It's not clear what is the intended usage of \ns; however, here's an implementation. I fixed the most obvious weaknesses in your code. \documentclass[12pt,a4paper]{article} \usepackage{xparse} \newlength{\tempi} % define active & to be normal & \begingroup\lccode~=& \lowercase{\endgroup\let~}& % make & active \catcode&=\active ...

1

Macros and keysettings are part of the profile. There is currently no way to handle them separately.

2


2

I think you want something like this: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \keys_define:nn { maag/variables } { unknown .code:n = \maag_defvar:Vn \l_keys_key_tl { #1 } } \NewDocumentCommand{\newfamily}{mm} { \prop_clear:N \l_maag_family_prop \keys_set:nn { maag/variables } { #2 } \prop_new:c { g_maag_family_#1_prop } ...

2

You need to remove the $and$ in the macro definition. Otherwise when the macro \test expands, it'll introduce a display math environment $...$ within an in-line math environment $...$, which throws an error. Code \documentclass{article} \newcommand{\test}[2]{\log_{#1}#2} \begin{document} Expected result:$\log_{(\log_{a}{b})}{c}$ ...

2

there are several problems with your code. first, you need \makeatletter and \makeatother at the outer level so that the @ is properly recognized in the command names. and then, these are not needed inside the definition of \generateFixBox. second, in the definition of \generateFixBox, a closing brace is missing to complete {\fbox{B}. the result gives a ...

3

The problem is the catcode of @: \newcommand{\generateFixBox}{ \makeatletter \def\@oddhead{% \setlength\unitlength{1mm}% \begin{picture}(0,0)% \put(120,-250){\fbox{B}}% \end{picture}\hfill} \makeatother } At definition time, \makeatletter is not executed, but the definition text is already tokenized. Therefore the input text ...

1

You can't make this work; the settings such as \setAuthor must be evaluated before \BODY is expanded for being stored in the lied macro. You can add a third argument where making the settings. But you're probably using a wrong approach: a key-value one would be better. \documentclass[12pt,a4paper]{article} \usepackage[utf8]{inputenc} ...

3

If you add \global\cslet{lied;#1;#2}\test \show\test you will see that \test and so lied;..;.. is defined as > \test=\long macro: ->{\Author \temp }. but \Author and \temp are only locally defined so not defined outside the group, where you try to use this. I couldn't work out the intended behaviour, but this is error free. ...

0

Annotation 1 -- about "variables" that get initialized somewhere within the document-environment's body but are used from the beginning of the document-environment's body: Use the LaTeX2e-kernel's infrastructure for defining the \label..\ref- mechanism and define your own -- references will be resolved after the second LaTeX-run: ...

4

Keep the tests out of your document body: \documentclass[12pt]{book}% \usepackage{amsmath} \ifdefined\HCode \newenvironment{myequation} {$$}{$$\ignorespacesafterend} \else \usepackage{breqn} \newenvironment{myequation} {\begin{dmath*}$$}{$$\end{dmath*}\ignorespacesafterend} \fi \begin{document} \begin{myequation} ...

2

Not exactly as you suggested, but \newif is a simple solution. Your A and B environments replaced by exemplary theorem-like ones. Edit: enlarged, according to suggestion from comment. The old picture left. \documentclass{article} \usepackage{amsmath} \begin{document} \def\myVariable{ whatever I want goes here } %tell Latex not to look at it Now I ...

6

You're wrong in thinking that \def is shorter. Maybe it looks shorter by number of characters, but it can save you from pulling your hair when some weird error shows up. Suppose you load a package you use only some features of, but that this package uses a macro named \setpage as part of its working when the feature you exploit is called. Can you see what ...

9


2

If I've understood what you want correctly, then you would like the following input \section{X} \myplotFF{file={example-image-a},Re=50,DOF=4M, statsName=Drag} to produce the following output The code as you currently have it is a mess. You seem to have multiple modules for one package/class/ and multiple sub-modules for handling the same options/data. ...

1

You're forgetting outer sep. Don't be obsessed by end-of-lines! ;-) \documentclass[12pt,oneside,a4paper]{book} \usepackage{tikz} \usepackage[font+=footnotesize, subrefformat=parens]{subcaption} \newcommand{\customcaption}[2]{{% \begin{tikzpicture} \node[ anchor=south west, inner sep=0, outer sep=-0.2pt, fill=black, ...

1

You can use \usepackage{numdef}: http://web.archive.org/web/20130727172127/http://www.elec.ryukoku.ac.jp/~fujii/pub/ftp/incoming/styles/kth.se/numdef.sty You can define \num\def\x1{x one} and use it as \x1. Hope this helps! VIKI

-1

You can use \usepackage{numdef}: http://web.archive.org/web/20130727172127/http://www.elec.ryukoku.ac.jp/~fujii/pub/ftp/incoming/styles/kth.se/numdef.sty You can define \num\def\x1{x one} and use it as \x1. Hope this helps! VIKI

4

\ifnum can only be used for integer numbers in the range -231-1 to 231-1. Dimensions can be used for numbers with decimal point, also with limited range (\maxdimen = 16383.99999 pt) and precision (the smallest unit is 1 sp = 2-16 pt). Example: \documentclass[a5paper]{article} \def\marks#1{{% \hskip20pt plus 1 fil (#1 ...

5

Classic ways to do this would be to use \ifdim \ifdim#1pt=1pt \else s\fi or \ifx \def\tempa{#1}\tempb{1}\ifx\tempa\tempb\else s\fi

4

\ifnum can't be used with floating point numbers, i.e. it is meant for integer values only. There are some ways: Using a \ifdim by-pass (like in the answers by David Carlisle and Heiko Oberdiek) or the expl3 style with \fp_compare:nNnF which checks for the floating point 'entity' This is easily achieved and can be extended, if needed, for more complicate ...

1

The optional argument of \fun is to hold a comma-separated list of elements that are to be "exploded". With your code, there is always trailing empty element. That trailing element is also processed by the \@for-loop. Therefore the output is always 1:a-2:b, 1:c-2:d, 1:e-2:f, 1:g-2:, 1:-2:, ìnstead of: 1:a-2:b, 1:c-2:d, 1:e-2:f, 1:g-2:, Below is a ...

2

This is a suggestion on implementing checking both for letter@ and other-@. \documentclass{minimal} \makeatletter %%---------------------------------------------------------------------- %% Check whether argument is empty: %%...................................................................... %% \CheckWhetherNull{<Argument which is to be checked>}% ...

3

As already explained, the problem is that @ has category code 11 at definition time, but category code 12 at usage time. Here's an implementation with xparse; the \SplitArgument processor pushes -NoValue- when the argument hasn't the indicated number of tokens to split at, so it's necessary to use \IfValueT in order to print the second part when existing. ...

4

It is a category code problem of @. The definition used category code "letter", whereas the category code of @ is usually "other" in the main document, example: \documentclass{article} % \FunLetter using @ with category code "letter" \makeatletter \def\@explode@letter#1@#2@#3\@nil{\edef\@pOne{#1}\edef\@pTwo{#2}} ...

2

I suppose @ is of catcode 11 (letter) due to \makeatletter at the time of defining \@explode, \explode and \fun. Thus within argument-delimiters at definition-time and within the default-value of the optional argument at definition-time, @ was tokenized as acharacter-token of catcode 11 (letter). Therefore those of your macros processing delimited arguments ...

5

You can use another separator different than @ that doesn't change catcodes, or use \begingroup\lccode;=@ \lowercase{\endgroup \def\@explode#1;#2;#3\@nil}{\edef\@pOne{#1}\edef\@pTwo{#2}} instead of \def\@explode#1@#2@#3\@nil{\edef\@pOne{#1}\edef\@pTwo{#2}} but note that you won't be able to use it in a \makeatletter part of the code. And the ...

3

LyX does support Mathematica. Make a math box in LyX (Ctrl+M), put in the math box solve(...), then right-click and go to Use Computer Algebra System and then Mathematica.

1

Here is two idea. If the file to be inputed does not change the whole strecture of document (if no command like \section or \global\textheight...) one can do \setbox0=\hbox{\let\def\gdef\input{file}} In cases like the Example here \begin{ENV}...\end{ENV} the best is to use comment or verbatim packages For example \let\ENV=\comment ...

5

With breqn all characters are math active, so the solution is not going to work; but we can exploit the features of breqn: \documentclass{article} \usepackage{breqn} \newcommand{\splitatcommas}[1]{% \begingroup \begingroup\lccode~=`, \lowercase{\endgroup \expandafter\def\expandafter~\expandafter{~\penalty0 \hspace{0pt plus 1em}}% }#1% ...

8

Here's the savesym way of getting rid off this problem: \savesymbol{foo} should work, after that say \origfoo to access the old version. The classical conflict appears for example with bbding and marvosym packages: \documentclass{article} \usepackage{savesym} \usepackage{bbding} \savesymbol{Cross} \usepackage{marvosym} \begin{document} Original ...

5

Starting with version 3.4 of biblatex there is the concept of delimcontexts that are used to find out in what context (\parencite, \textcite, bibliography, text is printed), we can use that to determine of we are in a \textcite \makeatletter \newcommand\ifintextcite{\ifdefstring{\blx@delimcontext}{textcite}} \makeatother There is no need for patching the ...

6

In the standard authoryear biblatex style, both \parencite and \textcite internally is use the name:others bibmacro. What we can do is to create a toggle that is switched on and off try \textcite, and we use the toggle for a conditional to be used inside the macro that prints the "and others" or "et al" strings. \newtoggle{myintextcite} The simplest way ...

2

Like this? \begin{filecontents}{\jobname.bib} @book{blabla, title = {An introduction to {LaTeX}}} \end{filecontents} \documentclass{article} \usepackage[backend=biber, bibstyle=standard]{biblatex} \addbibresource{\jobname.bib} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}} ...

5

Here's a xkeyval version, with automatic definition of keys and it's keyval macro and a corresponding \if... whether the option is used. The precise implementation depends on the internal options to be specified what they should do if specified. I assumed, that the class options are to be stored to a macro, say \classoption@myclass@#2 where #2 has the ...

5

Examples for kvoptions among my packages: accsupp, attachfile2, bookmark, enparen, epstopdf-base, grffile, pagegrid, pmboxdraw, rerunfilecheck, resizegather, selinput, zref-xr, ... A grep -r kvoptions TDS:tex/latex will reveal much more packages. Example rerunfilecheck: % Package start [...] \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{rerunfilecheck}% ...

1

You have to call differently if the optional argument is missing, so the handier way is with xparse: \usepackage{xparse} [...] \NewDocumentCommand{\nom}{ o m m }{% #2% the text to print \IfNoValueTF{#1} {\nomenclature{#2}{#3}}% no optional argument {\nomenclature[#1]{#2}{#3}}% with optional argument } The legacy definition (without xparse) ...

1

Perhaps something like this? \NewDocumentCommand{\nom}{somm}{% \IfBooleanF{#1}{% (#3)% }% \IfValueTF{#2}{% \nomenclature[#2]{#3}{#4}% }{% \nomenclature{#3}{#4}% }% } This defines \nom with the optional argument #2 (for the prefix) and the two mandatory arguments #3 and #4. If \nom* is used, the expliciting printing of (#3) is ...

1

Try \newcommand*{\nom}[3][]{#2\nomenclature[#1]{#2}{#3}}

4

It may or may not be to your taste...for example, the slanted + is not the same slant as the \mathcal{H} legs; but it works in all math styles. \documentclass{article} \usepackage{graphicx,trimclip,scalerel} \def\dblHtextstyle{\clipbox{0pt 0pt 4pt 0pt}{$\mathcal{H}$}\smash{ \kern-1pt\scalebox{.75}[1.06]{\raisebox{.450pt}{\textsl{\sffamily +}}}\kern-5.15pt ...

1

The standard way is to write style files, as described in the manual: https://gnu.org/software/auctex/manual/auctex.html#Style-Files Usually I start from the one created with TeX-auto-generate and tweak it.

5

It's a global temporary macro a (followed by b, c etc as distinct from \@tempa which is a macro for local definitions. The naming convention comes from LaTeX2.09 which used these all over the place however by 1993 when we did latex2e far too many packages (style files) were using \@tempa so we renamed all the internal uses in the format to \reserved@a etc ...

4

\@gtempa is a temporary scratch command, meant for global purposes (often used in conjunction with \xdef), but can be overwritten easily. It's just used for temporary storage globally and throw away after that. The prefix g indicates that it is designed for global purposes. However \@gtempa can mean a global temporary dim register as well. It's quite ...

3

You can get more exact values by storing the actuall positions in the aux-file. This need two compilations (the x are only there to show the locations): \documentclass[a4paper,12pt]{article} \usepackage[top=2cm,bottom=2cm,hmargin=2cm]{geometry} \usepackage{lipsum} \usepackage{zref-savepos} \begin{document} \section*{Firstpage} \lipsum[1-4] ...

1

A rather flexible implementation with xparse and expl3: \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\agename}{m} { \str_case:nnF { #1 } { {A}{Adult} {B}{Adolescent} {C}{Child} } {You~fool!} } \NewDocumentCommand{\xforeach}{m +m} { \clist_map_inline:nn { #1 } { #2 } } \ExplSyntaxOff ...

7


3

Note first that node options is rarely needed. label={[label distance=7pt,font=\scriptsize]-90:0} is equivalent. You would only need node options here if you wanted multiple labels. A macro is not, I think, the best way to do this. In particular, a macro with a standard optional argument of the kind you have in mind is definitely not going to work ...

7

For more details What is the difference between \def and \newcommand? What is the difference between \let and \edef? A solution is to use \edef method \edef\measurepage{\the\dimexpr\pagegoal-\pagetotal-\baselineskip\relax} MWE \documentclass[a4paper,12pt]{article} \usepackage[top=2cm,bottom=2cm,hmargin=2cm]{geometry} \usepackage{lipsum} ...

Top 50 recent answers are included