Questions tagged [macros]

{macros} is for questions specifically concerning TeX's macro processor. Note that, because TeX uses macros ubiquitously, most questions about code that uses macros are not looking for information about how macros work, and so are not appropriate for this tag.

Filter by
Sorted by
Tagged with
0
votes
0answers
25 views

Passing a macro as a string in luatex

In lua I have a function that takes a string and an number called "simpFracs" (It's supposed to take a fraction and a number, multiply them, return a number) I have a pretty disgusting macro ...
0
votes
1answer
17 views

How to read the newcommand syntax for the \cventry item using awesome-cv?

I am trying to compile my CV using awesome-cv with overleaf. There is one position in my CV where I would like to go directly to the description leaving out both (i) position and (ii) period. ...
2
votes
2answers
41 views

“case” situation to avoid double periods when using newcommand with a period

Shown is a MWE (from M. Scharrer's package actually) that highlights my question. Sometimes I invoke a newcommand in the middle of a sentence, and sometimes at the end. The newcommand outputs a '...
4
votes
2answers
41 views

A symbol table with protection issues

I wanted to create a table of symbols that is easy to read in LaTeX, so something like: \begin{tabular}{*4M} < & \le & \ll & \lll \\ > & \ge & \...
0
votes
1answer
28 views

Have both \limits and normal superscript

I'd like to define an operator that has both a normal-style superscript and a \limits style subscript. The obvious solution doesn't work. \max\limits_{a}\nolimits^{b}
4
votes
2answers
54 views

Problem with newcommand and the optional argument

I want to have a command that does the following: \documentclass[a4paper]{letter} \newcommand{\stuffing}[2][]{\ensuremath{W_{\mathtt{#2}}^{^{\left[#1\right]}}}} \begin{document} what I want: $W_\...
1
vote
1answer
22 views

Expand part of \g@addto@macro in scrlttr2 AtEndLetter

I am trying to write a package that generates envelopes for scrlttr2. The idea is to collect a list of recipient addresses and write all the envelopes at the end. Here is what I have so far, distilled ...
1
vote
2answers
39 views

Simple replace dot by comma after fpeval

I want to simply replace the dot of the fpeval result with comma. Very simple, no additional features, so siunitx and numprint etc. is not working because they are modifying and adding to much stuff. ...
0
votes
1answer
18 views

Assign a separate colour to each author in the todonotes package

The todonotes package has options for specifying the author name and also an option for specifying the colour of the individual note. However my question is that, is there a provision to set a colour ...
1
vote
1answer
56 views

Check for empty tex file to decide ifthenelse branch

Objective: I am trying to key on on the presence of file content (comments are acceptable, I am trying to key in on content that would be displayed in the built PDF) to determine what path to take. If ...
5
votes
4answers
154 views

Double hashes inside macro definition?

Assume a macro which is not defined in terms of \long and which is not defined in terms of \outer and which is not defined in terms of \protected and which does not process arguments and whose ...
1
vote
1answer
46 views

Addressing package collusion when building a library

I wish to create a "library" of commands that I often use, say lib.tex, so that every time I wish to use them, I write \input{lib} and get on with life. The problem, however, arises when my ...
1
vote
3answers
46 views

How do I store the current value of a macro as an permanent string?

Long story short, I have been using \patchcommand within a \whiledo loop to try to construct a string piece-meal from an old string, inserting certain characters along the way. I cut off a bit of the ...
1
vote
1answer
29 views

How add new argument to command to control scaling?

The following code, slightly modified from https://tex.stackexchange.com/a/552769/13492, allows creating new symbols \bigplus, \bigtimes, and \bigbox. However, it hard-codes the scaling factor \...
0
votes
1answer
40 views

How to set style file for Urdu paper

I wonder, if it's not difficult for you, I am uploading a LaTeX code which returns Urdu text in XeLaTeX, however, can you arrange its preamble into a separate style file and LaTeX body file? Like, the ...
0
votes
0answers
18 views

The tikz variable resets before the loop finishes [duplicate]

In tikz, I define a variable outside \foreach loop, and use \pgfmathtruncatemacro command to increase it inside the loop. Below is my MWE. \documentclass{article} \usepackage{pgfplots,tikz,tikz-3dplot}...
0
votes
0answers
11 views

Adding custom command into autocomple

Can we set autocomplete for custom command in miktex as it auto complete and suggest the environment when we start typing \begin{} command. Corrected one- Can i set autocomplete for custom command in ...
2
votes
1answer
51 views

How to create comma separated list as the argument of a macro or command?

In the following MWE, I tried to create a command (but I also tried with a macro) that receives #1 argument. In this case, I am trying to create a comma separated list. However, as shown in the figure ...
3
votes
1answer
48 views

Define command with optional characters

I have the following command definition (in the MWE) \documentclass{article} \usepackage{amsmath} \def\hE_#1^#2#3{\hat {\textrm{E}}_{#1}^{#2}\,[#3]} \begin{document} \[ \hE_{1}^{2}{3},\qquad % \...
0
votes
0answers
41 views

What are the Main LaTeX Commands?

On Texmaker editor in order to overwrite existing default font type to modify it to my custom font I use the commands below, which work fine: \renewcommand{\familydefault}{\sfdefault} \usepackage{...
5
votes
2answers
120 views

Fourth argument in \RequirePackage internals?

I was reading the code of miniltx to understand the way LaTeX loads package files. I know it is simplified, but there's an aspect which is puzzling to me. According to source2e, \RequirePackage has ...
1
vote
1answer
20 views

New command with alias counter

I'm trying to make a command which will create a new theorem environment and link the counter for it to a specified other counter. For example, I'd like to be able to do something where my theorem, ...
4
votes
2answers
178 views

Define commands without the need for brackets

Not sure whether the standard actually allows this, but at least in my LaTeX installation (TeX Live 2019/Debian), I can write for instance $\sqrt\frac12$ instead of $\sqrt{\frac{1}{2}}$. However, this ...
4
votes
1answer
26 views

Pass a parameter from preamble to command

I want to pass a parameter to a command that I use in several places in my document. I want to set the parameter in the preamble so that I don't have to use edit the command further down in my ...
1
vote
1answer
48 views

pgfkeys: Different output depending on a keyword

I need an output like \cmd --> "S0" (output) \cmd[] --> "S0" (output) \cmd[map] ----> "S1 S2 S3" (output) \cmd[map=true] ----> "S1 S2 S3" (output) \...
0
votes
0answers
29 views

Define a new macro for tabu environment

I recently found this github repo which has a package called yFlatTable. It is beautiful and I want to use it for my German note (making vocab list and their usage, or lecture note, etc). But when I ...
1
vote
1answer
57 views

Keyvalue-command: Add option for boolean key

I have a boolean key map that produces TikZ-stuff (right column) like I would like to have an additional key-option like map=red with which I can access the TikZ options, in the sense of \node[text=...
1
vote
1answer
34 views

keyvalue-command: A Key changes Another

I have a keyvalue-command \cmd[map] that produces Now I need another key stepstrokes=true, that produces That means: Text of 'map' is gray now and the 'stepstrokes' overlay (and 'startpoints' or '...
0
votes
1answer
96 views

How to add vertical spaces automatically?

I am preparing a questionnaire. I want two questions to appear on each page. I adjust the gap between the first question and the second question with \vspace {6cm}, and after the second question, I ...
2
votes
2answers
56 views

How to call a \newcommand in a FOR loop - automated document preparation

I'm working on a technical report which I need to simplify in order to get rid of ridiculous manual copy-paste work. My ideas: My simulation results can be presented in the same way (same variables, ...
1
vote
0answers
44 views

Define an incremental counter with Lua

I would like to receive a suggestion for this example. Really, it is more a question related to Lua scripting. Minimal working example \documentclass{beamer} \directlua{dofile("timer.lua")} ...
1
vote
1answer
48 views

Drawing string diagrams using macros

I am writing a paper which contains a lot of string diagrams from the type below. The problem is that many of them are complicated and it takes very much time to draw them from scratch. Is there a ...
3
votes
2answers
71 views

How can I define a colour from a macro?

I am trying to define a colour (using the xcolor package) where the colour is provided by a macro in hex HTML format. I have a macro \colorGet{#1}{#2} which takes two arguments and returns the colour ...
0
votes
0answers
52 views

Enregistrer dans un fichier annexe dans une classe perso, à l'aide de \AtBeginDocument et \AtEndDocument

Bonjour, Je cherche à mettre en place une classe me permettant de taper un document à la fois prof (complet) et élèves (avec des trous) qui se différencie à l'aide d'un booléen ifprof. Mes macro et ...
3
votes
2answers
156 views

Define a command that prints the first letter of its input argument

Is there a way to define a command or macro that outputs only the first letter of its argument? Example: my name is Joaquim Brasil. I could define a macro \def\WhatIsYourName#1{\@WhatIsYourName{#1}} ...
1
vote
1answer
36 views

Nested macros using FPeval

I am trying to create an easy to use template, with a part that would look like this: The original code I used to do this is the following: \begin{tabularx}{\linewidth}{|X|X|X|X|X|} \hline \rowcolor{...
1
vote
1answer
27 views

Command works as “\csname cmd \endcsname” but not as “\cmd”

I'm trying to create a command (\dummy) for dynamic macro definition. It is supposed to return a macro that is named dynamically (#3) with the content of #2 concatenated after #1 iterations. \...
1
vote
1answer
53 views

\noexpand, \unexpanded and \expandafter

Recently I discovered a piece of code (from ucharclasses) using three expansion-related macros \noexpand, \unexpanded and \expandafter: \def\do#1{\noexpand\setTransitionsFor{#1}{####1}{####2}} \def\...
3
votes
1answer
42 views

A macro has a pesky global effect when used in several environments

I was using a cool macro to write some nice matrices inside a particular math environment, from this question: Ugly matrices to fix But then I wanted to use the same macro to fix some other matrices ...
2
votes
1answer
19 views

Using @namedef to store equations

This is a modification of the question here: @namedef and math mode. I am trying to define a macro called myLabel that 1) defines a standard label for an equation, and 2) saves the equation so that it ...
3
votes
3answers
70 views

Undefined color with the \colorlet command

I have the following code working just fine: \documentclass[letterpaper,10pt]{article} \usepackage[english,german]{babel} \usepackage{xcolor} \usepackage{boolexpr,pdftexcmds,trace} \definecolor{...
0
votes
0answers
28 views

How to get a macro behave differently at the top of a page/column

In a macro I would like to detect if it is the first item put right after a pagebreak/columnbreak on the top of the next page/column. In that case it would like it to behave differently (e.g. change ...
1
vote
1answer
56 views

Adding a macro to the -jobname section of the PDFLaTeX compiler (i.e., how to add dates to the PDF filename)

I would like to add a macro, and/or a user-defined command, to the "jobname" section of my compilation command. My ultimate goal is to add the current date (e.g., YYYY_MM_DD) to the PDF ...
0
votes
0answers
29 views

Macro to change the extension of filename

I would like to have a macro to change the extension of a file name. For example, my macro needs to take an argument like Figures/Fig.xxx and return me Figures/Fig0.yyy. I found a solution in Extract ...
-1
votes
1answer
28 views

page number jumps in log file

I compiled a document back in 2016 (with TeXLive 2016) and noticed the following strange situation. The page number jumps 76 to 89, when including the next file with a new chapter. (the file starts ...
1
vote
0answers
28 views

Why my Header text is not appearing in the even pages

I am using a document class "thesis" . After compiling I have seen that header text is not appearing in the even pages. Anyone have any idea? % Thesis framework file. %\PassOptionsToPackage{...
24
votes
1answer
985 views

What are some typical LuaTeX gotchas?

The interaction of TeX and Lua can be quite delicate at times. While the former has category codes and tokens, the latter has escape sequences and datatypes. Mixing the disparate concepts of these ...
2
votes
1answer
35 views

How to deal with empty values in command arguments

In this MWE, a command argument is directly passed to an environment. That works fine with empty values: \documentclass{article} \newcommand{\minipag}[1]{% \begin{minipage}[b][#1][b]{6em} One ...
0
votes
0answers
25 views

\global \newcommand in align environment

I want to use \newcommand within an align environment. Furthermore, I need the newly defined command outside of the align environment. While this is easy for the case of \def as I can simply prefix it ...
2
votes
2answers
39 views

A problem with a simple command definition [duplicate]

I am trying to define a command that writes the word "FACTORING" in sans serif. I did define the command as follows: \newcommand{\FACTORING}{\textsf{FACTORING}} But the when I use the ...

1
2 3 4 5
130