Questions tagged [macros]

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

29
votes
0answers
2k views

Copy to clipboard feature in PDF output

I want a clickable copy to clipboard feature in my PDF document. Ideally the macro also allows for graphical elements to be embedded inside them (say, a button that will automatically copy paste ...
14
votes
0answers
475 views

Alternatives to the physics package

The physics package is useful A lot of my LaTeX documents make heavy use of the physics package. Aside from it overloading several standard commands (e.g. \sin, \abs, etc.), it also makes a few ...
7
votes
0answers
96 views

Beamer: Reference Overlay Numbers with Names

I am trying to reference my beamer overlays by an identifier, much like in this question: reference overlay numbers with names. Since I am using \visible<+->{} (where the beamerpauses counter ...
6
votes
0answers
660 views

Typesetting graphs of Turing machines

I have to typeset a lot of graphs of automatons looking like this. Therefore, I spent a lot of effort on introducing a simplied syntax based on TikZ. I got much help from here working out one or the ...
5
votes
0answers
176 views

regular expression to match floating point number or decimal number

To become somewhat familiar with the latex3 syntax, I've written a small macro to convert lengths (known in LaTeX). I found the following on page 206 (229) in the last source3.pdf: [+ - \ ] * ((? i) ...
4
votes
0answers
117 views

Better arrows in math to match tikz-cd diagrams

The underlying problem I find the arrow tip in the Lucida Bright \rightarrow, hence in \to and \mapsto, to be too small, especially at smaller font sizes. Likewise, I find the Lucida Bright \relbar,...
3
votes
0answers
209 views

Is there a BNF grammar of the LaTeX format?

I know it seems like there is no BNF for TeX language. But I am interested in BNF, PEG or any other kind of formal grammar for the LaTeX format. Is it possible to create such a grammar for pure LaTeX ...
3
votes
0answers
52 views

Duplicating a new line in a new command

I'm trying to write a new command which will duplicate the last line. I don't want the content duplicated. I just want the template for the last line line duplicated so I can enter new data to the new ...
3
votes
0answers
51 views

How to create template longtable/datatool code?

Consider the MWE below (TexLive '15, pdflatex). I have multiple datafiles which need to be displayed in different tables. Currently I have copied table code like MWE multiple times. Q1: But, what is ...
3
votes
0answers
108 views

LyX functions: Nest label from clipboard into inset insert

In writing my thesis in LyX I make frequent use of the label-copy-as-reference function - mainly from equations but also with other labels. The labels are however not pasted as formatted reference ...
3
votes
0answers
181 views

mouse over (highlight) acronyms using acronym package. is that possible?

Is it possible to highlight acronyms (mouse over shows the acronym definition) by using the acronym package \ac ....? In this post, there is a macro that was working somehow but by using the acro ...
3
votes
0answers
198 views

\ifbeamer@anotherslide and \ifbeamer@localanotherslide in beamerbasedecode.sty

At the beginning of the source file beamerbasedecode.sty of beamer class, two switches are defined: \newif\ifbeamer@anotherslide \newif\ifbeamer@localanotherslide By reading beamerbasedecode.sty and ...
3
votes
0answers
360 views

looking for selective latex command replacement methods

I have a perl script for generating wordpress (or physicsforums or wikipedia) style latex markup from standalone latex files, but it has grown into a bit of a monstrosity and has also recently met it'...
3
votes
0answers
1k views

Insert code snippet via keyboard shortcut in TeXworks

I know there already are questions (1, 2) on creating keyboard shortcuts in TeXworks. The discussion (also in the Google thread referred to), however, seems a little outdated. By now, there is the ...
2
votes
0answers
47 views

How do use {<setup>} in \tl_set_rescan:Nnn to replace \scantokens?

This question is related to (Changing escape character in \tl_set_rescan:Nnn) and (https://tex.stackexchange.com/a/496258/7832) but is not the same. I've tried to change this: \exp_args:NNx \...
2
votes
0answers
34 views

Help Understanding/Adapting the Definition of Beamer's 'lecture' Command

Beamer's 'lecture' command has been a great way for me to have all my lecture notes in one document, but typeset only the segments that I need for any given day/week of class. Ultimately I would like ...
2
votes
0answers
128 views

Create an adapted \color macro for RTL mode (pdflatex and xelatex)

This is a complement to these questions: Colors bizarre results with right to left text Change color method used with beamer My aim is to create a macro like \color which can be used in RTL mode (...
2
votes
0answers
49 views

Custom command for multiple boxplots

I have to include a lot of boxplots in my document and would like to automate this with a custom command. I'd like to be able to write something like this: \boxplots[ range={1,2,3,4,5}, questions=...
2
votes
0answers
47 views

How to make up a macros to have a effect on all following text without specified?

Some macros from TeX or LaTex have global effect, "\bfseries", "\color{red}", for example. This kind of macros need not to specify the contents, because all the text followed them are affected. I ...
2
votes
0answers
50 views

Changing between symbolic and textual format of writing currency

I'm looking for a way to switch between symbolic and textual formatting of currency - e.g. $5 vs 5 dollars. Additionally, I want to choose which currency to display and change between currencies as ...
2
votes
0answers
98 views

Latex is really just a bunch of Tex macros?

A question of no practical importance, just curious: One reads that Latex is just a collection of Tex macros. Is this literally true? A more precisely specified version of the same question: Does ...
2
votes
0answers
35 views

How to pass in nested expression using pfgkeys

I have a setup with 2 simple macros: \documentclass[a4paper]{article} \usepackage[english]{babel} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{pgfkeys} \begin{document} \...
2
votes
0answers
397 views

OSX Sierra - Pygmentize sometimes not recognized

I've recently decided to switch to minted due to way better Python highlighting. I am having weird issues with minted sometimes not being able to find pygmentize on my Mac - never had the same issues ...
2
votes
0answers
123 views

Adding a variable with backslash as argument

i would like to make a command to create tables. In a minimal idea the function "autotabell" should be like: \documentclass{article} \usepackage{tikz} \usepackage{csvsimple} \usepackage[latin1]{...
2
votes
0answers
150 views

TikZ/Pgfplots - restrict expr to domain does not accept pgf macro

First question here, so thank you all for welcoming it. When I try the option restrict expr to domain in \addplot, there seems to be no way for TikZ/PGF to understand a prior macro produced by \...
2
votes
0answers
99 views

Create daily workbook

I would like to use LaTeX for my daily events : (like a longtable, etc.) For the left column I have the date, and the second column contains pre-stored newcommand/newenvironment setups to call them ...
2
votes
0answers
174 views

Adding dynamic tikzpicture with newcommand inside new command

I have a side block command that lets me add content on the side of the page very easily but now I want to have the choice to add some kind of chart or dynamic graphic content in it too. Lets say I ...
2
votes
0answers
189 views

Using \subimport inside \newcommand

I am using the command \subimport and I am very happy with it. However, it doesn't seem to work when I use it inside a \newcommand environment. My file structure is as follows: ./main.tex ./Macros/...
2
votes
0answers
109 views

Texmaker personal macro # symbol

If I save a macro in texmaker I need to use more often and it contains a # the # gets deleted after I click save and the next time I want to use it I get the whole macro but without the # and it's ...
2
votes
0answers
68 views

Context-dependent macro expansion

The prelude to this question is my previous question regarding expanding macros inside renewcommand. The accepted answer works beautifully, and now I want to define a macro which expands differently ...
2
votes
0answers
115 views

Difference between tableofcontents and listoffigures internal codes

In standard classes book.cls and report.cls we find \newcommand\tableofcontents{% \if@twocolumn \@restonecoltrue\onecolumn \else \@restonecolfalse \fi \chapter*{\...
2
votes
0answers
56 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
0answers
323 views

Unwanted vertical space at top of page before subsection heading

I have been using LaTeX for a while now, but I am very new to defining my own commands in the preamble. I am working on my thesis, and I'm using a custom .cls file which has been passed down by other ...
2
votes
0answers
213 views

Autocomplete in TeXstudio for macro with optional argument

I have a macro, such as \newcommand*{\example}[2][]{#1.#2} defined. TeXstudio adds this to its autocomplete list, which is great, but when I actually autocomplete it shows up as \example{arg1}{arg2}...
2
votes
0answers
39 views

Can I force a pre-process action on all commands or environments without having to redefine them all manually?

I am trying to preserve a history of the latex commands and environment initializations I use in a typeset html or pdf file. Is there a way where I can force a pre-process action on all commands ...
2
votes
0answers
436 views

soul for text highlighting, microtype for letterspacing, and xspace: incompatibility

I am trying to use soul for highlighting text and microtype for letter spacing (and other things). But I cannot get the two to work together nicely when I include xspace (I use this mainly for ...
2
votes
0answers
191 views

Correct way to make command defined in tikzpicture environment (in an example) available in all documents?

The wonderful answer to the question Easy curves in TikZ shares some code that is defined inside a tikzpicture environment. I share the relevant portion of the answer here: Here is a slightly ...
2
votes
0answers
197 views

Generating LaTeX reports from XML *without* external scripts

First of all, I apologize if this is pretty similiar in nature to my previous question: Reading and (custom) formatting a CSV (not \csvautotabular) I thought it would be better to separate the two ...
2
votes
0answers
155 views

Different colours for each argument and value in listings

This recent question (Print blue brackets in one language and black in another) made me come up with (up to) two more questions regarding the listings package: Is there an option similar to opstyle ...
2
votes
0answers
435 views

Duplicate Line command in TeXShop for Mac

I'm a quite new user of LaTeX and one thing I miss in TeXShop on mac is a "Duplicate Line"-command, espacially when writing mathematical derivations. It's my impression that it is possible to create a ...
2
votes
0answers
125 views

\ref to \label in other document?

I have a repository with one document, but I think of splitting it into two documents, whereas I want to cross-reference from one to eachother. Is there a way, to "rewrite" \ref to automatically ...
2
votes
0answers
1k views

Using the correct amount of space around unit symbols

This is from an old package I developed back in 2003. The idea was to cover international system units (SI) and other type of units, roughly following guidelines from that document. Units should ...
2
votes
0answers
145 views

A problem with using the \ganttbar macros inside another one

I'm trying to write a macros for converting day time to a format, which the pgfgrantt package can understand. Here it is: \newcommand{\htime}[2][0]{ \StrBefore{#2}{:}[\hours] \StrBehind{#2}{:}[\...
1
vote
0answers
33 views

font size definition problem in math mode

I am defining some abbreviations to use in a very large book in order to get consistency over chapter. I have the following definition that works in regular text: \newcommand{\pr}{\fontsize{9}{11}\...
1
vote
0answers
28 views

Using pgfkeys to make a custom tikzpicture command with multiple use of addplot

Consider this MWE: \documentclass{article} \usepackage{tikz,pgfplots} \usepackage{pgfkeys} \usepackage{xparse} \usepackage{filecontents} % DATA 1 \begin{filecontents*}{data1.txt} 1 1 2 4 3 9 4 16 5 ...
1
vote
0answers
31 views

How to check if attempts at totally expanding the tokens of an arbitrary sequence of tokens would yield an error?

How to check if attempts at totally expanding the tokens of an arbitrary sequence of tokens would yield an error? How to check if attempts at totally expanding the tokens of an arbitrary sequence of ...
1
vote
0answers
39 views

Is there a way to create a “function” that generates LaTeX code based on the parameters?

Context: I work as a statistican for a high school. One of my responsibilities is to generate performance reports for every teacher in the school, based on how well students evaluate them. I use ...
1
vote
0answers
29 views

`\show` for macro arguments

For debugging purposes, I want to write to the log what is actually passed to a macro as argument. A naive \newcommand\test[1]{\show#1} obviously doesn't do the job. So how can I printout a list of ...
1
vote
0answers
18 views

Merging lyx files involving different (perhaps intersecting) macros

I want to merge two files written in LyX by my colleague and me. The problem is both of us use self-written macros for writing things shortly. We want to merge our files, and use a chapter my ...
1
vote
0answers
33 views

Prevent selection of some pdf sections

In order to avoid the selection of a part of a pdf, I use this command: \usepackage{accsupp} \DeclareRobustCommand\squelch[1]{% \BeginAccSupp{method=plain,ActualText={}}#1\EndAccSupp{}} For ...