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

1
vote
1answer
19 views

\expandafter to expand macro before macro call

I am trying to include an image: \documentclass{article} \usepackage{graphicx} \begin{document} \newcommand{\ext}{.pdf} \def\incPIC#1{ \expandafter\includegraphics{#1}} { \tracingmacros=1 ...
1
vote
0answers
10 views

Using/Forcing upright text within theorem environment

I would like to write an equation within a theorem that involves an integrand and the upright symbol $ \textrm{d} $ which I have abbreviated in my preamble with \newcommand{\dmath}{\textrm{d}} ...
0
votes
1answer
60 views

Change temporary or locally error behaviour suppress undefined errors

I googled about this problem with no result yet. You might discourage this, but is there a way to suppress errors? This is an example how it should work. \documentclass[12pt,a4paper]{article} ...
0
votes
1answer
42 views

How to “Go to source” from PDF file to Latex file with Texstudio?

I'm using Win 8 + Texstudio and follow the instructions of the previous answers, but do not succeed. It my commands
0
votes
1answer
33 views

redefine ampersand & for environment

I want to redefine the ampersand-charakter to expand to a macro, I defined. Basically it is/should be something like &={\hspace*{30pt}Ampersand has been redefined\hfill} The final use is ...
2
votes
1answer
31 views

TeXstudio: Is there a way to keep my custom macros and shortcuts in a separate file?

I've created some macros and corresponding shortcuts; found them in my texstudio.ini file (Macros and keysetting keys), buried deep among lots of predefined stuff. Is there a way to 'modularize' it a ...
2
votes
1answer
29 views

Macro or \def to create lines in a table

I have a certain table to which I would like to add lines by a command. One way I can get to this looks like this: \newcommand\arow[3]{ #1 & #2 & #3 \tabularnewline } and the table ...
2
votes
0answers
85 views

How to force edef to execute def [on hold]

Since I haven't given up on my problem from yesterday, I've been messing around with \edef, \def, \unexpanded, \expandafter and some other stuff. I also read about fragile commands and robust ...
1
vote
1answer
31 views

Command inscribed in command

May I know if there's a way to use a defined command in other commands without producing an error? Code(the line with error is commented) \documentclass{article} ...
0
votes
2answers
36 views

Newcommand for fixed content not working

I tried to generate a macro for fixed content, but it's not working and I was wondering why. This is my code: \documentclass{article} \begin{document} % this is working and puts A at the bottom of ...
1
vote
2answers
45 views

Environment behaves different inside \cslet{}

Please scroll down for the EDIT and most recent version This is not a good title, but I didn't come up with a better one. I've got an environment which should be used like this (The way this ...
5
votes
3answers
123 views

How to assign arbitrary LaTeX text to a variable for use in different places in a document?

I have lots of LaTeX text duplication in my files, since the file has to compile with pdflatex and tex4ht and text4ht does not support all packages, So my files are littered with things like this all ...
8
votes
2answers
123 views

Make \par work inside command arguments

I have a problem, which I think can not be solved, except for workarounds. I want to pre-define pages and insert them later into the document. The problem is, that \par (if used in the pre-defined ...
2
votes
1answer
49 views

Macro for pictures with generated labels

Good day, I would like to write a macro (using Latex3/expl3) that posts pictures and can take several key-value parameters for generated labels/captions etc. I already found code that can do this, ...
1
vote
1answer
102 views

Library with xkeyval, make my life easier?

Question is related to the topic that I opened last year regarding the Library with xkeyval, fp and newcommand where the library now grew quite big and adding new stuff in it has become tedious and ...
2
votes
1answer
40 views

White space with subfigures using a macro

EDIT The answer proposed by egreg doesn't work for me: When changing the outer sep to outer sep=-10pt, instead of shifting the images, just the labels get shifted and the white space persists. ...
0
votes
0answers
21 views

create custom badness for pagebreaking over a custom area

This is a - as I think - tricky question. I want to create and/or modify a badness for pagebreaking/newpage. It should work like this (pseudo code): \begin{areaOfBadnessValid}{badnessvalue} ...
3
votes
3answers
59 views

\ifnum and real number [duplicate]

I have an error when I take a non-integer value for may argument: \documentclass{article} \def\marks#1{{% \hskip20pt plus 1 fil (#1 mark\ifnum#1=1\else s\fi) \parfillskip=0pt\par}} \begin{document} ...
7
votes
6answers
378 views

Explode arguments in argument list

What does TeX do, when reading an argument? I wanted to write a command that has a comma separated list of arguments (\fun[a@b,c@d,e@f,g,]). Each argument should be exploded in two parts at the ...
1
vote
0answers
21 views

Texmaker user command puts filename in quotes

Following this advice: Integration of arara in Texmaker, I defined user command in Texmaker. Yet after running a command, I get a message: Error : could not start the command : arara "mgr".tex ...
2
votes
1answer
68 views

Import single macro from file

I have an automatically generated .tex file containing some content and a couple, usually just one, \newcommand calls. Usually I display the content and load the commands with \input but sometimes ...
5
votes
1answer
66 views

tex capacity exceeded when using breqn package with a separate macro

I am trying to use a nice solution for one problem I have which is to break long math sequence with commas in them as given here allowing-line-break-at-in-inline-math-mode only to to find I get tex ...
6
votes
1answer
65 views

suppress single macro from style file

I have a master style file of macros, which I use for all of my documents. Is there something I can add to the preamble of a particular file so that it ignores some specific macro from my style file? ...
4
votes
2answers
52 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
41 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
113 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
42 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
49 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 ...
0
votes
0answers
21 views

cannot get a navigation newcommand correct

Sorry, I did not read up extensively as I guess this will be easy for people experienced with newcommand. If you prefer to point to the problem and not right away solve it, thanks too. ...
8
votes
2answers
166 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
17 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
139 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
90 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
33 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 ...
0
votes
0answers
33 views

Transforming subenvironments

I need a way to access the subenvironments of an environment. So when I have code like: \begin{env} \somecommand{...} \begin{someenv} ... \end{someenv} \begin{A} ... ...
1
vote
1answer
21 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}~}% ...
3
votes
3answers
130 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
27 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
27 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 ...
4
votes
3answers
106 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
92 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. ...
5
votes
2answers
39 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
56 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
170 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} ...
4
votes
2answers
248 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}% ...
4
votes
1answer
77 views

Trick for listing authors

I wrote the following code: \makeatletter \newtoks\author@toks\newcounter{author@counter}% \setcounter{author@counter}{0}% \newcommand{\authorAdd}[1]{% ...
2
votes
1answer
75 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
146 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
186 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
29 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} ...