{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.

learn more… | top users | synonyms (4)

4
votes
2answers
71 views

Different `andothers` expressions for `\textcite` and `\parencite`

Is it possible to have two different expressions for andothers, when using either in-text or parentheses citation with biblatex classes? For instance, I would like to use "and others" in text (with \...
2
votes
1answer
48 views

Get \textsc to ignore stuff in braces

This question allowed me to create an uppercase command that would ignore stuff in braces, so that \smartuppercase{An introduction to {LaTeX}} is printed as "AN INTRODUCTION TO LaTeX". Now I want a ...
6
votes
2answers
120 views

How can I define a key-value command like \hypersetup?

I am quite familiar with switch (\if...\else...\fi) now and read many questions on key-value topic, but I cannot find an example to create the options listing command like \hypersetup, to make \...
3
votes
3answers
49 views

Creating \newcommand from existing command

So I have been using the nomencl package with the following \newcommand, to save having to type the abbreviation and then the \nomenclature command: \newcommand*{\nom}[2]{#1\nomenclature{#1}{#2}} %...
3
votes
1answer
55 views

Custom “H” symbols for double affine Hecke algebra

I'd like to create some custom symbols for double affine Hecke algebras. Specifically, I would like to "double" the usual "H" symbols, for example $\mathcal{H}$, $\mathbb{H}$ or $\mathbf{H}$. By ...
8
votes
2answers
171 views

What is `\@gtempa` used for?

\@gtempa is used in a number of intermediate definitions, but I'm having difficulty finding how it is intended to be used (at least according to convention). I first ran across in this question: ...
1
vote
1answer
21 views

AUCTeX user Macros

I know that I can add my private macros to auto-completion feature of AUCTeX by running TeX-auto-generate. However the macros that AUCTeX "knows" seem to work better i.e. it automatically ask for the ...
8
votes
2answers
143 views

Using Macros within Loop

I was wondering if there is a way to use macro within a \foreach loop. For example some of my defined locals are: \newcommand{\labA}{Adult} \newcommand{\labB}{Adolescent} \newcommand{\labC}{Child} ...
7
votes
3answers
99 views

Measure remaining space on page and use it on another page

I want to measure the remaining space and use that number on another page. I tried the following: \documentclass[a4paper,12pt]{article} \usepackage[top=2cm,bottom=2cm,hmargin=2cm]{geometry} \...
3
votes
1answer
41 views

How to define Macros in forest (e.g. labeling edges)

I want to label single edges and branching ones with some style: For example, instead of edge label={node[right,midway,font=\scriptsize]{9}} I want to have \labelA[right]{\scriptsize}{9} and ...
1
vote
1answer
30 views

\renewcommand in tabular with \input

I have generated a bunch of files (exp1.tex-exp10.tex) for different experiments that define my variables by \renewcommand{\minabserror}{\SI{0.01}{\meter}~}% \renewcommand{\minabserrorat}{\SI{1.4}{\...
3
votes
3answers
137 views

Creating a macro that conditionally turns on an \iffalse and \fi

I'd like to construct a conditional \iffalse and \fi. Specifically, I'd like to define a counter and a macro such that if the counter set to one,the macro would either set an \iffalse, if the argument ...
2
votes
1answer
44 views

how to add table from word to texstudio using macro?

i have a table of 3 pages in the word document, and it will be very time consuming to copy and paste the individual entities from word to texstudio, please guide me any short cut to manage all these ...
1
vote
1answer
37 views

declaration of \newcommand results in missing \begin{document}

I have this code: \documentclass{article} \usepackage{fontspec} \usepackage{xcolor} \definecolor{color0}{rgb}{0,0,0}% black \definecolor{color1}{rgb}{0.22,0.45,0.70}% light blue \definecolor{...
4
votes
3answers
113 views

Associate dynamic text to a label

I'm trying to associate some text (dynamically generated with counters) to a label, so that I can refer to that label and print the text associated(without re-generating it, that would cause problems ...
6
votes
2answers
108 views

Can two \vtop boxes exist side by side?

So I am trying to see if I can put two \vtop boxes side by side. The below is the closest I have gotten. This is a kind of a "plain-tex in latex" example. \documentclass[fontsize=13pt,letterpaper,]{...
5
votes
2answers
40 views

\clist and hyperref

using package xparse I stored the author of a certain paper in a \clist in the following way \NewDocumentCommand\addauthor{m}{% \clist_put_right:Nn\l_allauthors{#1}% ...
2
votes
1answer
60 views

Alternative to `foreach` loop to use an `edef`

I need to create some dynamic name macro and I want to create them from a coma separated list of parameter in #1 in one loop. foreach is not the solution because it forces the use of gdef and I want ...
5
votes
4answers
176 views

Tricky macro expansion and list

I posted these two question Tricky macro expansion Tricky list Now I would like to merge the two issues: \documentclass{article} \makeatletter \newcounter{a@c} \newcounter{b@c} \newcounter{c@c}...
4
votes
2answers
250 views

Tricky expansion in macro

I wrote the following code \documentclass{article} \makeatletter \newtoks\a@toks \newtoks\b@toks \newcounter{a@counter}% \newcounter{b@counter}% \setcounter{a@counter}{0}% \setcounter{b@counter}...
4
votes
1answer
78 views

Trick for listing authors

I wrote the following code: \makeatletter \newtoks\author@toks\newcounter{author@counter}% \setcounter{author@counter}{0}% \newcommand{\authorAdd}[1]{% \ifnum\theauthor@counter>0\author@toks=\...
2
votes
1answer
114 views

\chaptermark undefined error in classicthesis.sty when I (attempt to) redefine \spacedlowsmallcaps

My MWE does not compile and the error is: ! LaTeX Error: \chaptermark undefined. I have debugged to the extent that I know the error is the interaction between classicthesis and my \SC command ...
3
votes
2answers
151 views

Which macro actually typesets images in graphicx?

I was looking through /usr/local/texlive/2015/texmf-dist/source/latex/graphics/graphicx.dtx and trying to figure out what macro actually typesets the image file. For example, on the user level, we ...
5
votes
1answer
193 views

Get a command to ignore stuff in braces?

Update: @wipet's answer is nearly perfect, it seems like the only problem is that it doesn't work properly with safeinputenc: accented characters aren't capitalized properly and weird commands like {\'...
2
votes
1answer
32 views

\linebreak \\ causes error inside \BODY of \NewEnviron

I've got some code, which is mainly based on the solution of this: Other question I asked The code looks like this and it works so far, except for the \\-stuff: \documentclass[12pt,a4paper]{article} \...
2
votes
1answer
48 views

New environment with parameter

This is my first question on this forum, so don't hesitate to correct me. I want to create a new environment who I can pass a parameter "color". This environment call a new command named \...
6
votes
2answers
76 views

counter in TOC fails when using xparse command instead of LaTeX2e command

Here I define a custom sectioning command, \Unit, which prints a numbered subject heading and adds it to the table of contents. If I use \newcommand for the command that creates the numbered label, ...
5
votes
2answers
40 views

How can I use \apptocmd within a macro, passing the appended's macro's parameter back to itself?

Let's say I have the following \newcommand\app[1]{\textbf{#1}} % <- #1 is appended's macro's parameter \apptocmd{\app}{#1}{}{} % <- passing appended macro's parameter to appended macro again \...
9
votes
2answers
175 views

How to save and restore the nodes between tikzpictures?

My English is not good enough so I beg you to excuse me if the question is long The next code is not very interesting but it may illustrate correctly my problem. I have a lot of macros and I need ...
4
votes
3answers
107 views

What is the best way to check if an argument of a control sequence is a control sequence?

I try to find a way actually I get update : \documentclass{article} \def\IsArgaCs#1{% \ifcat\relax\noexpand#1true \else false \fi% }% \begin{document} \def\a{a}% \let\b=~% \def\c{1}% 1)\IsArgaCs{\a}...
3
votes
1answer
39 views

tikz - Multi-line text size

I am using this command: \newcommand{\orgnode}[2]{\node[shape=rectangle,draw=black,align=center] at (#2) {\Large #1};} to make basic ORG chart nodes. I want the text size Large. This works with one ...
1
vote
0answers
49 views

What is a good environment for writing problems and solutions? [closed]

I'm writing a book where I record interesting problems and their solutions. However, there does not seem to be an organized list, or other reference to these types of latex packages and tex macros. ...
3
votes
1answer
22 views

Call a command where part of the command name is given as input?

This seems obvious but I can't seem to find what I need via a search (I can't figure out a good search term I guess). So what I'm looking for is to have a command that takes in a string, and then ...
2
votes
2answers
100 views

Conditional test inside command parameter

I want to call \includegraphics with parameter width= #1\textwidth if the number i have provided thru \mycmd is >= 1 and scale= #1 otherwise. I already saw this: Can I conditionally scale an image ...
5
votes
0answers
28 views

Problem between keys, paths with two macros and pgfkeys

Sorry the code below for my minimal example is a bit long. In this code I defined two macros : the first macro \SC draws semi-circle and the second macro \ARC draws arcs. The first macro uses the ...
5
votes
2answers
55 views

Checking if a subenvironment is unique inside an enviroment

I would like to define a environment inside another environment, but I need to make sure the new environment is unique, so there can only be of them. The unique environment should also be able to be ...
2
votes
1answer
50 views

Add an iterative layer to IfFileExists to check each graphicspath

I am collaborating on a project that started off with images stored on a server. Since everyone had a different path to get to this server I took advantage of a \graphicspath declaration in the main ...
1
vote
0answers
73 views

Where to put plain TeX macros so MiKTeX finds them

I have MiKTeX 2.9 working except it can't find the files (.tex macros) when the source file (always plain TeX) refers to them as in \input mac2 I do have a TDS-compliant directory called \...
3
votes
1answer
57 views

Underscores in function arguments seem to change file names

I have been trying to pass a file name that contains underscores to a couple of nested commands. Since escaping each and every _ isn't really an option, I thought a group \catcode_=12 (had to remove ...
9
votes
2answers
184 views

Interchange variables in LaTeX (to be used with TikZ)

I want to define a couple of variables in LaTeX and then exchange their values, like this (but it doesn't work): \newcommand{\signS}{$+$} \newcommand{\signT}{$-$} \newcommand{\signU}{} \signS \...
11
votes
3answers
898 views

if test for 1 not 11

It may seem rather silly, but I can't find an answer for this question. (I've been looking for one for a while already). Suppose I want to have a macro with a single parameter. When this parameter ...
3
votes
2answers
87 views

edit the minimum length of \hfill

Once again I have a pretty special problem: I'd like to edit the minimum length of \hfill. According to de.wikibooks it is a TeX primitive. Therefore, I assume, that it can't be edited. What is it ...
3
votes
2answers
126 views

Check if two labels are undefined

I'm struggling to test if there are two labels undefined, in order to include some specific files only in that case. Until now, I only needed one condition: workshop, so I was checking like: \...
0
votes
1answer
58 views

Alkenes and newman projections

Recently, I've written a latex document about stereochemistry, but i needed a lot of strange newman projection, I found lots of problem about alkenes. First of all, I had to draw alkenes, then my ...
2
votes
1answer
43 views

New command with an Underscore

I tried creating a new command with an underscore as shown below, but doesn't work. \newcommand{\h\_world}[1]{Hello World #1} At the output I see without even initiating the command : worldHello ...
2
votes
1answer
40 views

Metapost : input file within macros

I like to have separate .mp files to organize my Metapost projects. But I'm facing this error message when I try to input file within a macro File names can't appear within macros. Even with this very ...
4
votes
1answer
102 views

Best Key-Value System For LaTeX

I want to make new macros that support key=value style. But, there are many such packages for doing this. What is the best choice, given these priorities: Highly developed, complete, or actively ...
2
votes
2answers
64 views

Macro: compatibility of 1) Auto-colorization & 2) Auto-counter-and-title-to-label

This question is about asking to have the following 2 "workflows" (if you permit me to call them as such) to be able to coexist together in 1 Tex document: Workflow Auto-colorization (≅ User Mico'...
2
votes
3answers
110 views

Loop, compare to macro value in condition and multiple macros if true

I seem to be stuck and for now am trying my luck through trial and error to find the right way to do this. Here is a general idea: % I DECLARE NEW MACROS WITH NAMES AS DEFFINITION. AND ASIGN LETTERS ...
20
votes
0answers
188 views

Is there a reliable way to get the number of arguments of a command?

While pondering over a test to distinguish two versions of a command I came up with the following example: \documentclass{article} \begin{document} \def\testA#1{\#2->blabla} \typeout{\meaning\...