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
1answer
29 views

Sorting newcommands according to one variable

Two reviewers made several comments on my paper, and I am writing a response letter. I defined a newcommand as follows: \newcommand{\response}[3]{Comment by Reviewer #1 \\ Comment: #2 \\ Response: #3}...
0
votes
1answer
16 views

How to format text based on a logical statement that reads in a value from a csv?

Background Hello, and thanks in advance for any insights you all can offer! Sorry for the very long post, but I noticed most new users are chastised for not sharing enough context. The TLDR version ...
2
votes
1answer
31 views

Create filename with a counter in a command

the code below is not efficient as I would like : \documentclass{article} \usepackage{graphicx} \newcounter{nomfigcpt} % compteur pour compter les figures insérées dans le document \newcommand{\...
3
votes
1answer
84 views

Replace backtick ` with power ^ in math mode

I'd like to declare the backtick symbol ` to be the math operation power ^, so that by writing \documentclass{article} \usepackage{amsmath} % \DeclareMathSymbol{`}{\mathbin}{symbols}{^} \begin{...
0
votes
1answer
37 views

define command to insert a small picture into text

I'd like to define a command that inserts a small sign saved as pdf. It should be fit into a floating text. I've not found a good solution for this yet, so I try to ask you... Why? I have a graphic ...
0
votes
0answers
18 views

Define a newcommand of dictionary word entry with variable sub-entryes

I want to creat a dictionary, each word should have variable like 2 or 3 sub-entrys, see in the figure Can anyone helps in defining such a newcommand? It should be something as \newcommand \...
6
votes
2answers
200 views

Nicely-spaced multiple choice options

I am maxing an exam using LaTeX and use this command for making multiple-choice options: \newcommand{\mc}[5]{(\textbf{A}) #1 \qquad \qquad (\textbf{B}) #2 \qquad \qquad (\textbf{C}) #3 \qquad \qquad (...
0
votes
0answers
28 views

How to make macro as “\qty” on equation? [on hold]

I am a TeX user and I have a question about macro. I usually handle math equations and I uses "physics package" a lot. Using equation on TeX with Physics package, \qty( "Something" ) is the same as \...
2
votes
1answer
21 views

Error Inserting Custom Symbols (Graphics) into the Section

I am making a cookbook, and want to use a single macro \recipe (in the minimal example below) to insert the name of the recipe, the tags for the food (custom symbols denoting dietary restrictions), ...
0
votes
0answers
28 views

Macro to put stuff in the appendix

I am trying to write a macro to put proofs of theorem in and out of the appendix by setting a variable. I know how to do the following: In the following example, when I set the variable ...
3
votes
2answers
77 views
+50

How to put a vertical rule between Beamer columns created with the \column command?

Note: This question is different from https://tex.stackexchange.com/a/95188/18588 because that question works with the column environment but this one is about the \column command. My code: \...
0
votes
2answers
27 views

Definition of an alternative to \footnote to adjust the layout

This is a follow up question of Distance of footnote number from theorem title I've problems defining my \thfootnote. The problem concern the optional argument of the \footnote command as you see in ...
0
votes
0answers
34 views

Way to automate how many weeks are in a given month and year

I am writing a short piece of code that, among other things, generates a customized calendar with some specialized formatting and content. I have everything working fine, except there is one ...
3
votes
2answers
43 views

Ignore # (hashtag) within \newcommand

I am using the lyluatex package to integrate LilyPond to LaTeX. I created the following command for conveniently outputting correct-size Figured Bass within a text: \newcommand{\fig}[1]{% \...
1
vote
1answer
66 views

Macros to make [ ] and ( ) automatically have \mleft and \mright

Since I'm writing a document with thousands of brackets of all kinds, manually sizing all the brackets or manually add \mleft and \mright every time will be need a lot of time in the end. Moreover, I ...
0
votes
0answers
21 views

How can i use a Macro as input for <choices> in ChoiceMenu from hyperref

I am a little bit puzzeled. I want to use a macro as input for the hyperref ChoiceMenu. But i got no clue how to do. What i do: \newcommand{\namea}{name1, name2} \ChoiceMenu[combo, name=...
0
votes
1answer
41 views

Expandable contact information

Introduction I am sorry for the long MWE, but I was not able to make it shorter and still illustrate my problem. Again I am working on streamlining the creation of exams for my university. In the ...
2
votes
1answer
48 views

Contact list as dictionary

Introduction I am trying to create a template to make it easier to type problemsets and exams for the university I am working for. In that regard it is often neccecary to write down the contact ...
1
vote
2answers
31 views

Access nth argument after use of \SplitArgument in \NewDocumentCommand?

It is a bit artificial, but assume the following as context: First, I want to add labels for tables as tab:label, for figures as fig:label and so on. Second, I want to create some commands to include ...
2
votes
1answer
27 views

Defining command with asterisk

I have a command which takes multiple arguments, one of which is a star: \NewDocumentCommand{\foo}{ s m m }{ \IfBooleanTF{#1}{Asterisk is here.}{Asterisk is not here.} #2 #3. } I would like to ...
2
votes
1answer
52 views

Labeled input parameters

I am creating a frontpage for various exams and I am looking to automate it a bit further. At the moment I write in (or rather copy paste), a ton of commands in the preabmle as follows: \newcommand{\...
1
vote
1answer
25 views

Missing \endcsname inserted., “relax” when inserting figures in minipage in newcommand

I am trying to insert figures in minipages in newcommands to get two images on a a5 paper. MWE: \documentclass{article} \usepackage{mwe} \usepackage[a5paper, margin=5mm]{geometry} \newcommand{\...
1
vote
1answer
26 views

How I show the counter with the part number?

Here is a MWE: \documentclass{scrartcl} \newcounter{main}[part] \newenvironment{Remark}[1][]{\refstepcounter{main}\par\medskip \noindent {\underline{\textit\Large{MAIN~:\arabic{part}.\themain}}\\...
0
votes
0answers
24 views

Latex get counter value at beginning of section [duplicate]

I am trying to access the final value of a counter in each section at the beginning of the section. The reason for knowing the value ahead of time is to use it in a bar plot that summarizes ...
0
votes
0answers
22 views

Suppress reference undefined warning for specific chapters

I have got a large document with over 400 pages and over 20 different chapters. Every chapter is separately included via an\input{} command. While editing a specific chapter, I exclude the most other ...
0
votes
4answers
77 views

How to define a macro that takes the definition of a macro as an argument

We would like to define a macro \ellipsis that takes four argument and has the following behaviour: \ellipsis{x^{#DUMMY#}}{0}{5}{+} and outputs: the pattern string #DUMMY# (which doesn't have to be ...
1
vote
1answer
31 views

when compiling, miktex-dvipdfmx.exe occupied a huge memory(10GB+) and never finish [closed]

\documentclass[10pt,a4paper]{article} \usepackage{fontspec}%setmainfont的依赖 \usepackage[hidelinks]{hyperref}%hidelinks属性隐藏了link的颜色 \usepackage{etoolbox} \usepackage{ctex} \usepackage{CJK} \usepackage{...
1
vote
1answer
35 views

why my newcommand reports error?

1 \newcommand{\Qf}[3]{\paragraph{\[#1\]}#2\\#3\\} ... \Qf[AA][AA][AA] it says There's no line here to end. \Qf[AA. 2 \usepackage{etoolbox} ... \csdef{Q1}{ 1.1.2-1992-2,3-1 } \csdef{Q1=}{ ...
1
vote
1answer
61 views

Easy way to make a new “List of…” that copies the typesetting of LoT or LoF without tocloft

I am trying to make a template for people I work with, and they want a "List of Objects" in addition to List of Tables and List of Figures. But they want the "List of Objects" to have the exact same ...
0
votes
1answer
34 views

How to add a custom TOC (automated “Section Break-down”) after each \chapter command?

Let's say we have a document broken into chapters and we want at the beginning of each chapter to add between two horizontal lines a "Section Break-Down" that shows all the sections and subsections of ...
2
votes
0answers
22 views

ConTeXt fails to find SVGs on macOS when space is in directory path

I'm trying to make a PDF of a tex document that references some external SVGs and JPGs. This is the command I am using: context --nonstopmode --batchmode --path=styles main.tex This command creates ...
1
vote
1answer
45 views

Using booktabs with newcommand

I'm relatively new to defining commands and environments. I'm trying to make several tables (all of which follow a template), and thought that defining myself a new command would simplify the code. ...
5
votes
3answers
77 views

How to change value of an argument (e.g. #1) such that any reference to it (the argument, #1) would expand to the new value?

I was wondering how to change #1, based on its value, to something else such that any #1 that follows the change would contain the modified value, not the original value (passed to the macro from ...
1
vote
1answer
43 views

Itemize command with variable number of items

I'm looking to create a command that I can give a variable number of inputs, and it will place them into an itemized list. Something like \myitemize{First item}{Second item}{Third item} would ...
0
votes
1answer
42 views

How can I pass an argument to a command defined and called in a .cls file using another command called in a .tex and defined in the previous .cls?

I am building a résumé on which I would like to list the languages I speak and my level in each one of them. To present the levels, I wish to use skill dots. I want to obtain a structure similar to ...
0
votes
1answer
29 views

BibLatex - Help with APA/Harvard

Im using APA style in Biblatex and I want to know how I could remove the parantheses around year. I found code for this with authoryear, but nothing for APA. This is my code: \usepackage[backend=...
0
votes
0answers
22 views

How use \DeclarePairedDelimiterX after \providecommand* for same command?

The package mismath includes the definition: \providecommand*{\abs}[1]{\left\vert#1\right\vert} After loading mathtools, I want to redefine \abs by: \DeclarePairedDelimiterX{\abs}[1]\lvert\rvert{#1}...
2
votes
1answer
28 views

Define macro that scans ahead for super- and/or subscript, “absorbs” them and moves their argument

I have a lot of mathematical macros that already have a super- and/or subscript by definition, i.e. something like \newcommand*{\mymathsym}{x^{\text{foo}}_{\text{bar}}} In the text body, these ...
3
votes
1answer
32 views

inserting an additional notes between two words and above the sentence

Please suppose there is enough space between lines of a paragraph in a text. I wish to insert an additional note between two words of a certain sentence and above that (between two lines of the ...
0
votes
1answer
42 views

Conditional kerning with custom characters

I have been reading answers to latex questions for the past while in order to address an issue I am having. I am using a font that contains symbols and mapping the symbols to a latex command. For this ...
1
vote
1answer
36 views

How can i short the commands in tabular environment?

Table is list as follows. \begin{tabular}{|>{\centering\arraybackslash}m{2cm}|>{\centering\arraybackslash}m{7cm}|>{\centering\arraybackslash}m{1cm}|} \hline \textbf{Keys} &...
1
vote
2answers
43 views

How can I avoid to copy and paste this code (similar newcommand definitions using different functions) :

I've been improving my code thanks to you guys, but this still looks improvable as it looks like an ugly copy/paste : \newcommand*{\LegendFlecheInf}[5]{ \coordinate (C2) at (axis cs:#2, { \...
0
votes
0answers
57 views

How to read a picture with name # in it?

Probably avoiding to use # would be best at the first place but for musical chords I would like to name my image something like F#m.png . The problem is that latex does not allow to write \...
2
votes
1answer
34 views

pgfmathprovidefunction functionality

I am looking for a \pgfmathprovidefunction which executes a \pgfmathdeclarefunction if the given function is not already declared and does not report an error if it was already defined (but does not ...
0
votes
1answer
46 views

How to define a macro with digits in its name using \def and a counter value?

I need a \def whose name involves a number, with that number being value of a counter. \documentclass[varwidth,border=5mm]{standalone} \begin{document} % COUNTER \newcounter{myC} \addtocounter{myC}{...
2
votes
1answer
31 views

Change footer within the document in fancyhdr

I am producing LaTeX reports via Rmarkdown. The LaTeX code should therefore be generic. I would like to add arbitrary text to the existing footer within the document, defined in a certain pagestyle. I ...
6
votes
2answers
299 views

Issue with Expansions of Nested Macros

I am trying to incorporate membership checking macros by marmot and Phelype Oleinik (thanks to both of them for their neat solutions) into an argument of another macro: \singleBox{\...
6
votes
2answers
275 views

Checking if an integer is a member of an integer list

Is there any way to check whether an integer is a member of a list of integer numbers and return a boolean? I found this neat solution, here that does a great job. It checks whether a string exists ...
1
vote
0answers
30 views

Membership checking inside fpeval [duplicate]

I would like to check whether a number is in a list and make a decision in the calculation of a macro. I found a neat solution to check the membership of a number, here and it works as long as I don't ...
2
votes
1answer
32 views

Calling a Macro as Argument of Another Macro

How can I call a macro in an argument of another macro? I am having difficulty running the following LaTeX code. I used \fpeval to be able to process floating-point numbers. \documentclass[tikz, ...