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

5
votes
0answers
23 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
49 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
45 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
70 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
50 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
177 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
881 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
85 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
123 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
54 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
27 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
30 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
95 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
62 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 ...
2
votes
3answers
94 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 ...
17
votes
0answers
143 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} ...
1
vote
1answer
18 views

defining new functions such that their names have a normal font [duplicate]

There are predefined functions somewhere such that when you use them in default theorem environments, their names appear in a normal (non-italicized) font. I want to be able to define my own functions ...
0
votes
0answers
27 views

Keep Latex packages and templates on USB

I was able to install TExshop on my university's mac computer lab, but the IT people were only willing to install Basic Tex. The root of the problem is that the computers are refreshed every 15 ...
1
vote
1answer
36 views

Is there a simple way to create a local length

I want to redefine \textheight and \textwidth inside a \parbox. \textwidth works pretty well so far. But the textheight-part works only with the help of a \newlength. Unfortunately the \newlength will ...
1
vote
2answers
52 views

automatic word in color

I would like some text to display in red color. For Example paragraph text need to display in red color. My MWE is: \documentclass{article} \usepackage{times} \usepackage{amsmath,amssymb} ...
7
votes
2answers
62 views

How to handle syntax errors in a macro?

I would to indicate in the log file that if I use () instead of {} in the line \macro[red,circle]{2/3/a,4/4/b,5/0/c}, an error occurs . What is the best way to do this ? \documentclass{article} ...
1
vote
0answers
18 views

Process a latex command if the current date is between two specified absolute dates [duplicate]

I need to process a latex command if and only if the current date is between certain months, say between april 15 and june 15 of any given year. I imagine it's possible with datetime.sty but all the ...
1
vote
1answer
104 views

Is biber Turing complete?

I am wondering whether biber inherits Turing completeness from TeX. To show Turing completeness (without the requirement that the memory is infinite), we would need to emulate a Turing-complete ...
6
votes
6answers
180 views

How to write macro with variable amount of text variables

I am trying to make a signature block macro that accepts a variable number of text variables so that I can add or subtract the text without using empty fields "{}" as arguments. ...
1
vote
0answers
35 views

Package that fills pages to total number of pages devideable by 4, 8, 16

I'm doing a package right now, which is capable of filling in empty or custom pages to get a total number of pages which is devideable by a defined number. I just want to make sure, that a package ...
4
votes
2answers
125 views

Automatically colourize all occurrences of certain strings (different colouring for different sets of words)

This question is a follow-up of Macro: Replace all occurrences of a word, but I would like the same for different colours, that is to have different pre-defined sets of text strings which will be ...
1
vote
0answers
52 views

Macro: Replace all occurrences of words which are identical to content of \label{…} into \nameref{…} (unless of course the \label itself)

This question is a follow-up of Macro: Replace all occurrences of a word, but would like to ask for a possibility to do the same with words (e.g. foo) that are identical to the contents of certain or ...
2
votes
3answers
55 views

Ignore parenthesis contained in a macro parameter

I want that the macro ignore the parenthesis which are parts of the parameter and only conside the last parenthesis as the delimiter, I found a solution with \text{}. Are there any better (and ...
4
votes
2answers
34 views

ifboolexpr with a list of toggles - true if any toggle is true

I'd like to write a single file with a collection of e.g. questions, but I want to produce various outputs with a different subsets of all questions each. So at the beginning of my file I want to ...
4
votes
2answers
83 views

Conflict when using \newcommand

I've just realized that I made a big mistake sometime ago when in my preamble I defined the new command \renewcommand{\v}{\mathbf{v}} Now, I'd like to type the czech s using \v{s}, but I can't. ...
1
vote
1answer
25 views

How can I keep everything within a variable/macro on the same line?

I know there are various techniques to keep things on the same line. I have a two-word variable input. For example, Settings App. Let's say there are a group of apps, and I would like them always ...
1
vote
1answer
38 views

TikZ: cannot extract coordinate from intersection point

I am applying the solution proposed in this answer in order to automatically draw a vertical line at the point where to functions intersect. That solution implies creating a new commands that receives ...
2
votes
1answer
46 views

Macro to auto-convert english quotes (“”) to french («»)

French quotes can easily be obtained using \og and \fg commands. Although this is perfectly fine, it's not very intuitive to use them when typing. Is there a way to make latex automatically ...
4
votes
2answers
137 views

\bold in math environment

Having forgotten the command to make text bold in math mode I naively tried $\bold{bold var goes here} these maths symbols are not bold$ and it worked! I became immediately suspicious as I know ...
7
votes
2answers
70 views

read and write commands to auxfile

I have a problem with the aux-file. According to some posts here on Tex-Exchange, the aux-file is read at the beginning of the document (is this at \begin{document} or \documentclass? I wanted to ...
2
votes
1answer
28 views

Modifying command globally from within command

I've seen a couple of somewhat similar questions, but none with similar construct or -- I'll be honest -- none with answers I've been able to understand well enough to adapt to my situation. The ...
4
votes
1answer
54 views

Why does having an empty definition, {}, when defining a new command execute whatever is between the brackets when the command is called?

Here is an MWE: \documentclass{article} \newcommand{\new}{} \begin{document} \new{Why is this printed?} \end{document} Which outputs a document that says "Why is this printed?". My main question ...
4
votes
1answer
58 views

How to call a command in a loop?

there is a code \documentclass{beamer} \usepackage[utf8]{inputenc} \usepackage[english,russian]{babel} \makeatletter \newcommand*{\dothis}[1]{% \stringcases {#1}% {% {a}{so you typed a}% {b}{now ...
2
votes
1answer
49 views

Command suggestions in winedt

How do I get command suggestions in Winedt like in texmaker? I have tried exploring the options but couldn't find anything.
15
votes
1answer
595 views

What is the programming term for the command invoking '\' in latex?

I don't think it would be called a delimiter. Is there a specific term for this character? Just to clarify, I'm talking the slash here: \frac{1}{2}
5
votes
2answers
122 views

How do I nest a command with an optional argument?

I'm having problems making a normalizer command that can nest. Here is my code so far: \documentclass{article} \newcommand{\nrml}[2][]{N_{#1}(#2)} \begin{document} $\nrml[\nrml{H}]{J}$ ...
5
votes
2answers
109 views

compare a value from \newcounter to value from \newcount

I searched for this topic, but I didn't find anything, so I hope this isn't a duplicate. I've got the following code: \documentclass[12pt,a4paper]{article} \usepackage[utf8]{inputenc} ...
1
vote
1answer
56 views

Declaring again the same command

I defined a certain command, but now I want to change its definition. I tried to simply change it, but it doesn't compile. What should I do? Thank you very much. EDIT The former command was ...
14
votes
2answers
365 views

Is there any reason not to use \let to redefine a deprecated control sequence to the currently recommended one?

I understand that \bf and \it are both deprecated in the current version of LaTeX. To the best of my knowledge, the correct control sequences replacing them are \bfseries and \itshape. Is there any ...
4
votes
3answers
72 views

Change counter in \edef

When I try to change a counter in an \edef using \stepcounter, I get a whole lot of error messages ("Missing \endcsname inserted"). When I try to do the same with \addtocoutner I get no error, but the ...
6
votes
2answers
91 views

Trouble with patchcmd and double #

I need to patch the following macro from gloss-greek.ldf (polyglossia): \def\greek@numbers{% \let\latin@alph\@alph% \let\latin@Alph\@Alph% \if@greek@numerals ...
1
vote
1answer
90 views

macro: call parameter of level above - double pound ##1 doesn't work

Once again, I have a macro problem. It works almost. I spend a lot of time googling about \expandafter, \noexpand, \unexpanded and others. I used some of them, but nothing lead to the desired result. ...
5
votes
7answers
280 views

newcommand with comma separated argument, and optional arguments

I want to define a command (not with \def) the simplest possible way that it takes arguments separated by a comma, supports an optional argument (the first one). maybe another solution with extra ...
0
votes
1answer
32 views

Kile: How can I insert repeated code snippet and make keyboard shortcut in kile for LaTeX?

To insert figures in LaTeX document I use this code repeatedly: %%%%%%%%%%%%%%%%%%%%%%%%%%% figure environment start %%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{figure}[hb!] \centering \includegraphics ...
7
votes
2answers
1k views

Why is the \bye command not used by LaTeX?

Is there a technical reason why the \bye TeX command was replaced in LaTeX by \begin{document} and \end{document}? I suspect there must be a good technical reason behind this, as otherwise it would ...