{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
3answers
65 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 ...
3
votes
2answers
69 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
vote
1answer
22 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 ...
5
votes
2answers
36 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}% ...
4
votes
1answer
99 views
+50

Get a command to ignore stuff in braces?

I'm using biblatex and I did this: \DeclareFieldFormat{uppercase}{\MakeUppercase{#1}} So when I want to print a field in uppercase I can use \printfield[uppercase]{title}. The problem is this ...
4
votes
2answers
50 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
4answers
158 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} ...
2
votes
1answer
46 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 ...
9
votes
2answers
162 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
1answer
71 views

Trick for listing authors

I wrote the following code: \makeatletter \newtoks\author@toks\newcounter{author@counter}% \setcounter{author@counter}{0}% \newcommand{\authorAdd}[1]{% ...
10
votes
3answers
527 views

Repeat characters n times

I wanted to create a new command, which allows me to repeat any characters I want for n times. After some searching and trying, I came up with this: \usepackage{multido} \newcommand{\myrepeat}[2]{% ...
4
votes
2answers
246 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}% ...
2
votes
1answer
43 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
141 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 ...
2
votes
1answer
26 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} ...
9
votes
2answers
676 views

How to use \csname, \expandafter, \csuse, \@namedef …?

I have the following package \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{mypkg} \providecommand*\@mycmd{No {\MakeUppercase Mycmd} defined} \newcommand*\Mycmd[1]{\renewcommand*\@mycmd{#1}} ...
4
votes
2answers
292 views

Adding symbols to glossary entry and limit to description field?

I used an answer provided by Geoffrey Jones regarding how to create a Lexicon of sorts (unmodified code): \documentclass{article} \newcommand*{\glossaryname}{Dictionary} ...
5
votes
2answers
37 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 ...
1
vote
1answer
65 views

Left Content Bar/Area

I am working on a template for papers and documentation. Sometimes, the authors have "key facts" or other items they wish to callout in a left content bar (xxxx is left bar, ccc is main content): ...
6
votes
2answers
68 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, ...
2
votes
1answer
33 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 ...
5
votes
6answers
159 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
1answer
107 views

HZ typesetting system in plain TeX

How can I use the hz typesetting engine with plain TeX and pdfTeX? I read about it in TUG Vol 36 no.2, Peter Karow.
4
votes
1answer
53 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 ...
121
votes
3answers
23k views

What is the difference between \let and \def?

What is the difference between the \let and \def commands in TeX/LaTeX? Ideally please provide a simple example that will illustrate the difference between them.
5
votes
2answers
48 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 ...
191
votes
5answers
46k views

What is the difference between \def and \newcommand?

Inspired by a question about \let and \def, I have some that essentially all boil down to asking What are the differences between \def and \newcommand? In particular, I wonder Is it possible to ...
1
vote
1answer
29 views

Making csv2latex work with OSX El Capitan and TexMaker

I have encountered several difficulties making csv2latex work after excel2latex mysteriously failed after having worked fine for 2 years (no upgrades of office or anything)... I am using TexMaker as ...
3
votes
1answer
26 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 ...
59
votes
7answers
35k views

Isn't there any other way of doing double quotes in LaTeX besides `` + ''?

The standard way of writing quotes and double quotes in LaTeX is with `` and '', but I find them quite ugly. Isn't there something similar to \emph{}, but for quotes? I mean something like ...
1
vote
0answers
41 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. ...
2
votes
1answer
178 views

How to remove LaTeX control sequences from a .tex document using plasTeX?

I need to get just the text and math expressions (ignoring tables, pictures and styling) from a set of LaTeX documents and represent them in html. Looks like plasTeX and MathJaX are enough for this ...
2
votes
1answer
43 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 ...
3
votes
0answers
67 views

Aliasing a variable argument command into tabular environment [closed]

I am making a multi-language document. With the big help of Mr. Steven B. Segletes, I am able to deal with several languages mixed document, which can only output in wanted one or several laguages. ...
0
votes
0answers
43 views

How define a command auto insert some command and environment

I have a file like \tag{3.1.1}{ 3 section_name 3.1 subsection_name 3.1.1 subsubsection_name line1 afasf sht sa.fm th saf th adf. line2 afasf th asdfa lg..ag ;ag gasg line3 wfasdfasfsaf. ...
3
votes
1answer
94 views

Items from file in itemize environment

Is it possible to import items from a file into an itemize environment? For example, consider a file with just words and no formatting: Elem1 Elem2 Elem3 Elem4 ... Elem120933 I like to read in this ...
3
votes
1answer
19 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
85 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 ...
11
votes
3answers
870 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 ...
5
votes
0answers
20 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 ...
1
vote
0answers
64 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
48 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 ...
28
votes
2answers
897 views

How do I debug pgfkeys?

I'm sure if you're reading this question you are already familiar with my love for pgfkeys. However, it is absolutely impossible to debug: \tracingmacros is a total mess, with every key expanding to ...
9
votes
2answers
174 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 ...
3
votes
2answers
77 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
1answer
89 views

Bulk letter, “loop” doesn't work, “read to” doesn't work

Original Text below Edit: I solved it with endless googleing and help from here. Here is my theory: the typos caused expandafter to fail, which caused a dismatch between the chopline command and the ...
3
votes
2answers
122 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
48 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 ...
4
votes
1answer
93 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
60 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 ...