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

2
votes
1answer
34 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
30 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
108 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
97 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
57 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
174 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
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}% \setcounter{b@counter}...
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]{% \ifnum\theauthor@counter>0\author@toks=\...
2
votes
1answer
96 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
187 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
30 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
41 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
75 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
39 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
173 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
106 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
35 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
46 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
20 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
98 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
25 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
48 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
54 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
180 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
889 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
125 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
56 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
31 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
36 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
100 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
104 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 ...
19
votes
0answers
172 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\...
1
vote
1answer
19 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
28 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
38 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} \begin{...
7
votes
2answers
63 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
20 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
106 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
188 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. \sigblock{0}{2}{...
1
vote
0answers
41 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
126 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
58 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 simple)...