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.

351 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
51
votes
0answers
5k 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 ...
8
votes
0answers
2k 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 ...
7
votes
0answers
201 views

Redefining Commands: Safety and Best Practices

There's plenty of questions on this site about redefining specific commands, but I couldn't find a more general, comprehensive question about the safety and best practices of redefining commands in ...
7
votes
0answers
237 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,...
5
votes
0answers
69 views

What variant float lists exist?

I saw question wrapfig and wraptable not obeying \FloatBarrier and resolved to put \wrapfill\WFclear into placeins.sty. But I also wonder if there are more alternative float types or alternative ...
4
votes
0answers
184 views

When is \ensuremath really needed?

A rather popular question is When not to use \ensuremath for math macro?. Some good answers there explain why \ensuremath is often overused. egreg has an "\ensuremath-only-when-really-needed campaign"....
4
votes
0answers
390 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'...
4
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 ...
3
votes
0answers
131 views

xparse - \NewExpandableDocumentCommand - what is the rule for calculating the amount of expansion-steps it takes to obtain the replacement text?

According to the documentation of the package xparse the syntax of \NewExpandableDocumentCommand is: \NewExpandableDocumentCommand ⟨function⟩ {⟨arg spec⟩} {⟨code&...
3
votes
0answers
73 views

Generate table from code

My name is Patrick and I am quite new to TeX. I want to have a command which will leave a colorbox with text at the location used and also store some information not shown at first. And in addition I ...
3
votes
0answers
34 views

Using answers environments inside commands

I use package answers for putting answers or hints to problems at the end of a document. I wonder if it is possible to use the environment for solutions inside a command. But the straightforward way: \...
3
votes
0answers
73 views

ConTeXt: Protrusion does not work with the \quotation macro

For some reason, protrusion is not applied when using the \quotation macro. See the following example: \setuppapersize[S3] \showframe \definefontfeature [default] [default] [protrusion=quality] \...
3
votes
0answers
223 views

latexindent and trailing comments

In macros it makes sense to put percent signs at the end of line in order to avoid any line break characters in the macro definition. For example, a macro with a multi-line definition could look like ...
3
votes
0answers
528 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
108 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
60 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
144 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
561 views

Automatic lettrine in chapters

I'm trying to get lettrine dropcaps applied automatically on the first word of each chapter. I found some code here: http://dererumnatura.us/archives/2009/02/automatic-usage.html which I've tried ...
3
votes
0answers
291 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
272 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 ...
2
votes
0answers
57 views

History - LaTeX2e - \newcommand - Why does the mechanism for detecting an optional argument not crank out the case of an implicit [?

[Please take this question for a moot point/an "academical" issue.] The LaTeX-kernel-command \newcommand was invented decades before expl3, xparse and \NewDocumentCommand were available. \...
2
votes
1answer
96 views

Check if a command was used at least once?

I use LuaLaTeX, so Lua-based answers are welcome. I would like to know, for an arbitrary command sequence, can I make some function/command \wasused{csname} to tell me if a cs was used in my document? ...
2
votes
1answer
47 views

Wide and short ytableau

I'd like to draw a Youngtableau with entries given by a formula. The formula is not super long, but in order to fit it, I have to increase the boxsize to 6em. Then it is quite tall and has lots of ...
2
votes
0answers
24 views

Author query macro placing query wrongly on the page

I created a macro to place Query on the margin and the query list on the seperate page at the end of chapter I have two problem In the two column layout, when text continued from one column to next ...
2
votes
1answer
99 views

how to create "aux" directory to store auxilary files with pdflatex?

Currently I use TexStudio, with the command pdflatex -synctex=1 -interaction=nonstopmode -output-directory=./aux/ "paper".tex which works fine to compile and put all auxilary files in the ...
2
votes
0answers
51 views

Is it possible to concatenate itemized lists?

I am currently keeping track of my research / tasks to do in a LaTeX lab journal. The organization of each day in the Latex code is essentially like the following toy example: \chapter{Saturday, 2nd ...
2
votes
0answers
72 views

Running LaTeXiT as a command-line instruction

I wonder if it is possible to run LaTeXiT as a command-line instruction that takes options. Specifically, I want to run something like LaTeXiT -if abc.tex -of abc.png or LaTeXiT < abc.tex > abc....
2
votes
0answers
44 views

How to generate a list containing the values of a table

I have a table containing two columns with x and y values respectively and I want to generate a list \coordinates containing (x,y) for each row of the column. I tried defining a command that creates a ...
2
votes
0answers
57 views

grade table with question/parts/subparts

I am trying to modify the code I have obtained from sykora so that, I can add \question and subparts points to the grade table. So far I have modified the code as. My MWE \documentclass[addpoints]{...
2
votes
0answers
31 views

Defining a macro for nodes in a qtree

I'm using the qtree package to make linguistic c-structure trees. Consider the following simple tree: generated by the following code: \documentclass{article} \usepackage{qtree} % shorthands for ...
2
votes
0answers
73 views

What're the best references for TEX macros?

I need to learn about the famous TEX macros. if there are good references. but for beginners -step by step- Not limited to. :: \foo \par \@@par And commands to create the macros:: \def, \newcommand, \...
2
votes
0answers
111 views

How to redefine \str_if_eq_x:nnTF for backward compatibility

In TeXLive 2012 \str_if_eq:xxTF was deprecated and replaced with \str_if_eq_x:nnTF (see References below). Now it appears that with TeXLive 2020, \str_if_eq_x:nnTF has been deprecated. The MWE below ...
2
votes
0answers
174 views

Why is \DeclareRobustCommand[*] still used by LaTeX?

As LaTeX requires eTeX now it would be much easier to replace all the definitions of robust commands with \DeclareRobustCommand[*]... by \protected[\long]\def..., wouldn't it? Which advatages come ...
2
votes
2answers
75 views

Construct math super/sub-script from reference (`\ref`) with hyperref and cleveref being loaded

First, I would like to apologize for the insanely long MWE below. However, I wanted to keep it complete. At the bottom line I want to achieve a construction like $H^{\ref*{my-label}}_{\ref*{another-...
2
votes
0answers
44 views

ConTeXt fails to find SVGs on macOS when space is in directory path

I'm trying to make a PDF of a tex document that references some external SVGs and JPGs. This is the command I am using: context --nonstopmode --batchmode --path=styles main.tex This command creates ...
2
votes
0answers
144 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
177 views

Create an adapted \color macro for RTL mode (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
58 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
130 views

counters, newcount and pgfcalendar, macros

I am trying to use the pdfcalendar library, but I think I'm confused by the definitions. My Question: What kind of LaTeX counter/macro/variable can I use with pgfcalendar functions? Do I have to ...
2
votes
0answers
52 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
84 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
109 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
49 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
225 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
226 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
160 views

newcommand and index

I want to have an index entry referencing to another entry withought adding a comma. I currently do this with: \newcommand{\gobblecomma}[1]{} And then in the text itself when an entry occurs: \...
2
votes
0answers
120 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
234 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
168 views

How to use lilypond macros in different blocks

Code: \documentclass[12pt]{article} \usepackage[utf8]{inputenc} \begin{document} First variant \begin{lilypond} \version "2.17.27" \language "english" D = \relative d {d4 <f a d>} A = \...
2
votes
0answers
286 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/...

1
2 3 4 5
8