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

7
votes
3answers
186 views

Draw circle in TikZ by specifying endpoint and distances instead of angles and radius

In the classical arc command in TikZ, we specify an endpoint of the arc, followed by the initial and final angles, and finally the radius. I would like to create a macro (if it doesn't already exist) ...
11
votes
1answer
290 views

Solution to 'Multiple PDF generation with one tex file' does not work anymore with TeXLive 2016

The solution in Multiple PDF generation with one tex file worked with TeXLive 2015 and is now broken in TeXLive 2016, at least on OS X El Capitan. Minimal Example: \documentclass{article} \ifx\...
1
vote
2answers
90 views

Automatically generate new commands and keyval definitions

I would like to automatically define new commands and keyval definitions anytime that a command beginning with the prefix \fn is used within a string. Part I below is the stub that needs to be ...
0
votes
0answers
13 views

Variable name space problem [duplicate]

I have a problem with defining a variable in latex. Here is the deal: I create a variable containing a string like this: \newcommand{\company}{{Company Name}} It works, but the problem is when I ...
5
votes
4answers
196 views

Macros that define other macros, which also define other macros

I would like to define a TeX 'macro-building' command (let us call it \buildmacro) that takes as argument a string of 'normal' characters (e.g., Title) and which satisfies the followings: the ...
7
votes
1answer
79 views

Macro overloading, catcode redefining… or how can I parse XML with TeX?

Given this code that barely parse XML and print it as SXML (s-exp XML, aka lisp-style XML, aka XML-with-parenthesis): \catcode`@=11 \let\@xp\expandafter \def\@makeletter#1#2\@nil{\catcode`#1 \ifx\...
6
votes
2answers
69 views

Latex3 equivalent csname endcsname

I would like to know how to create dynamic named macros (in a loop) in Latex3. Everythings ok in LaTeX2e. I look to something equivalent to that code with expl3 \stepcounter{N} \expandafter\def\...
3
votes
1answer
70 views

Don't break item (without disappearing footnotes)

I am trying to keep items (used within a command) from breaking internally, but the solutions I've found end up causing the footnotes to disappear. Any advice on how to keep the footnotes alive but ...
1
vote
2answers
57 views

How does one detect if the next char is ^? [closed]

How do I do this? Using \@ifnextchar^{command1}{command2} fails to work. What should I do instead to detect ^? UPDATE. There turned out to be no problem with the command, just a conflict of names ...
1
vote
1answer
44 views

newcommand defined on multiple lines creates extra white space

When I define a \newcommand over multiple lines, I get unwanted white space in my output. How do I make it so I can write a long command, but still make it readable, without getting the extra white ...
1
vote
1answer
46 views

Create an automatically command for: $\Rightarrow$

Is it possible to create a quick command for $\Rightarrow$, because when I write a math paper I use often this: $\Rightarrow$. I know that the simple command \Rightarrow it can be shortcuted, but $\...
7
votes
2answers
345 views

How does LaTeX renders a \div?

This is a follow-up question to this one: How can I get a "divide by" symbol with \usepackage{physics}? In the referenced question the OP asked how to \undef a redefined \div. I want to ...
1
vote
1answer
50 views

How to repeat text without duplicating it?

I have defined a command for writing down 'requirements' in my document. It automatically styles and numbers it and creates a label to which I can refer to get the number - really nice. However, ...
10
votes
1answer
530 views

What do the commands inside the \LaTeX logo do?

I am trying to typeset a word in a similar fashion as the \LaTeX logo. I have found the code for the logo (given below in the MWE), but it uses many commands that I have never seen before, such as \z@ ...
4
votes
2answers
83 views

How to create a table with fixed-width cells and use cellcolor and multicolumn to create time bars? Or: How to substitute ganttbar with tabular?

Failing to combine a gantt chart with a table I now try to avoid the gantt chart by just using a tabular environment. However I like to keep some neat features of the pgfgantt-package and I'm facing ...
2
votes
1answer
33 views

\newcommand trailing space with tocloft

I have had to add a 'List of Supplementary Materials' to my current document using the tocloft package. I currently have the following code in my preamble: \usepackage[titles]{tocloft} % Create Table ...
4
votes
2answers
149 views

Adding accents, sub- and superscripts to defined variables

I often use \newcommand to define variables, notations or operations on variables. Sometimes I have to add accents, sub- and/or superscripts to a defined variable, like in the following test example: ...
0
votes
1answer
48 views

LaTeX DeclareUnicodeCharacter as a second argument for a macro

I want to enable the unicode modifiers for an emoji library: apple_emoji.sty: \usepackage{graphicx,amsmath,xparse} \usepackage[utf8x]{inputenc} \usepackage[export]{adjustbox} \ProvidesPackage{...
1
vote
0answers
36 views

TeX choking on a newcommand in a section heading [closed]

I'm writing a file in LaTeX2e with TeXshop in which I'd like to use a newcommand in a section heading. First I'll show you a minimal example that compiles and then an edit to it that does not compile. ...
0
votes
0answers
34 views

Add Logo to each slide with option to remove on some slides [duplicate]

I am using an elegant solution to place a logo on each slide, however for some slides (e.g. a full-screen image slide) I want to remove it. I have searched across stack for a solution to this. Whilst ...
2
votes
2answers
85 views

Avoid linebreak in abbreviation

I use the macros for i.e. and e.g. from the tufte-book example. They look great, but sometimes a linebreak occurs in between like in the following example: \documentclass[nobib]{tufte-book} \...
3
votes
1answer
56 views

“Something's wrong--perhaps a missing \item” error in \newenvironment using a \vtop box

In attempting an answer to "How to label a list / make a line before list stick with the list?" I answered using a \vtop box to contain the entire list including the label. I then, trying to improve ...
0
votes
1answer
94 views

How to include any .sty file in circuit_macros?

My circuit_macros M4 code .PS #\usepackage{steinmetz} #include(steinmetz) #s_init(steinmetz) scale=25.4 source(up_,AC);llabel(,120\angle 50{^{\circ}},) .PE output And that I want image, That ...
2
votes
0answers
26 views

Collecting and analyzing data presented in tables

I have data presented in tabular environments and I want to process it, in LaTeX, in ways that require for multiple cells to be analyzed together. That's in addition to typesetting the cells ...
2
votes
2answers
77 views

How can I remove trailing \par when reading a file and writing the output to the log?

I put together a macro to write the contents of an external file to the log output. Unfortunately, I always read out the trailing \par that LaTeX adds when reading files. How do I test for this and ...
2
votes
1answer
39 views

Convert count into length

I want to decrease a length by a number (count). I tried some variations with \newlength{\temp} and \addtolength but I got problems there with the minus. I also tried variants with \dimexpr. The ...
3
votes
1answer
40 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 \...
3
votes
1answer
27 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
63 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
57 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
38 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
44 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
39 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
87 views

How to force edef to execute def [closed]

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 commands....
1
vote
1answer
32 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} \newcommand{\test}[2]{\[log_{#1}#2\]}...
0
votes
2answers
40 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
49 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 looks ...
5
votes
3answers
140 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
126 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
51 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
110 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
48 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
74 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
390 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
25 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
69 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 I'...
5
votes
1answer
71 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
69 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
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 \...