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

3
votes
1answer
71 views

Multiple Choice Answer Key in exam package at the end of document

I think this is a follow up question to: Print answer key to multiple choice questions I am trying to create an answer key at the end of my exam class document where all the questions are multiple ...
4
votes
1answer
57 views

Tagging latex code for subsequent aggregation

I'd like to tag portions of LaTeX markup throughout my document. At some point later, I'd like to replicate all of the tagged portions. As an example of my desired behavior: \begin{itemize} ...
5
votes
1answer
51 views

Two parenthesis and a slash all the same size and slightly bigger than the expression contained

I'd like to define a command for the red part in the following expressions: generated by the following code: f(x/y) \qquad f\big( g(x)\big/y\big) \qquad f\Big(h\big(g(x)\big)\Big/y\Big) \qquad ...
0
votes
0answers
63 views

Is there a good way to automatically generate a list of commands/environments defined in the preamble?

Background I have seen beautiful manuals with commands and descriptions of what they do. I have a shared preamble (edited by multiple people and used for multiple documents) that has a multitude of ...
6
votes
1answer
84 views

Why does the ragged2e package screw up my emphasized text and headings?

I encountered a weird behavior of the ragged2e package. \documentclass{article} \usepackage{blindtext} \usepackage{amsmath} \usepackage{ragged2e} \newcommand{\ir}[1]{_{\mathrm{#1}}} ...
3
votes
3answers
47 views

Macro not Working in Itemize-Block

I want to write an estimation of effort for one of out clients. The client wants a few changes so I am estimating the required time for every change. I could sum up the efforts manually but that ...
7
votes
1answer
40 views

How to create custom labels which can be referenced?

I would like to label the hypotheses in my thesis similar to equations (e.g., the first hypothesis in chapter 3 should be “H-3.1”). Also similar to equations, I would like to reference these ...
5
votes
3answers
260 views

Is \renewcommand{\fi} possible?

I am writing my own command and i would like to define for each letter : \newcommand{\fletter}{\mathfrak{letter}} but i can't do it for the letter i even with \renewcommand. Is it possible to ...
3
votes
1answer
62 views

Custom “list of” command for lab notebook

I'm keeping my lab notebook for my PhD in LaTeX. I have it set up such that each "project" has its own chapter. When I make a new entry into the notebook I use a custom "entry command": ...
7
votes
1answer
83 views

Suspending environments and resuming by another environment

Is it possible to interrupt a LaTeX environment, say OuterEnv, by another environment, say InnerEnv, the later closing the first in the environment startup code, doing 'whatever' and then resuming the ...
1
vote
1answer
23 views

Custom linespacing in an parbox

Is there a way to set the line spacing into a \parbox? What I am trying to do is create a new command from a \rotatebox and \parbox and assign locally, i. e. only inside of the \parbox, custom line ...
5
votes
2answers
76 views

Empty parameter in xdef definition

Considering this definition of a latex macro: \newcommand\createCMDMANUV[4]{% \expandafter\@ifdefinable\csname #3#2\endcsname{% \expandafter\xdef\csname #3#2\endcsname##1{% ...
0
votes
0answers
36 views

Tikz: Using the size of one node to set the size of another node [duplicate]

I've been working on making diagrams involving many connected components, that will look something like the following: I want to be able to make such diagrams in a reasonably modular fashion, ...
7
votes
1answer
37 views

Patching/Preventing effective code in a package

Consider a command being defined in a package (or used from another package), say \somethingstupid and being used before \endinput within the package, doing some non-typesetting setup (coloring, ...
8
votes
5answers
314 views

A more elegant version of the \ifnot macro

A TUGboat article of 15 years ago mentions an \ifnot macro by David Kastrup whose implementation is: \def\ifnot#1{#1\else \expandafter\expandafter\fi \iffalse\iftrue\fi} However, this macro ...
0
votes
0answers
15 views

Problem using \newcommand for entering code snippets [duplicate]

I'm writing a report which I need to post various code snippets in. I decided this is how I wanted to put each bit of code in: \noindent \begin{minipage}{\linewidth} \begin{lstlisting} Code goes here ...
0
votes
2answers
30 views

pderiv square macro [duplicate]

How do I update the macro for partial derivative in order to accept standard second or bigger order? I have so far \newcommand{\pderiv}[2]{\frac{\partial #1}{\partial #2}} for the first order ...
5
votes
1answer
52 views

Automatically change font size in main text and footnote

I am typesetting an article with a lot of quotes from poems, and I have defined a command that puts the poem information at the end of the line \newcommand\poemcite[1]{\hfill{\small #1}} But if I ...
14
votes
2answers
220 views

How can own commands be aware of \global?

When I define a command that defines commands \def\makefoobar{ \def\foo{foo} \def\bar{bar} } and prefix it with \global { \global\makefoobar } it is treated like { \global\def\foo{foo} ...
0
votes
1answer
41 views

Command for \part style output and little abstract

I am new in this forum and I am kind of novice in LaTeX. I would like to know how to make this presentation as macro in order to change the PART (here chapter, I am using \documentclass{article}) ...
10
votes
1answer
157 views

Why does \def@#1\space not work?

The code \documentclass{article} \begin{document} \begingroup \catcode`@\active \def@#1\par{<#1>} @some text \endgroup \end{document} works flawlessly. Why not so when I replace it by the ...
4
votes
1answer
28 views

newcommand with optional argument displays wrong text

I tried to set up a new command with optional arguments. The problem is that the command displays 'st:code'. What's wrong? Thanks in advance! \documentclass[a4paper,twoside,10pt]{report} ...
2
votes
1answer
40 views

newcommand that does not expand at all

How do I define a command that exactly inserts its contents back into the source file without any reinterpretation, expansion, etcetera? In other words, I want there never to be a difference ...
2
votes
2answers
40 views

switching between newcommand and default

I've defined the following macro: % makes tables more readable \renewcommand{\arraystretch}{1.1} \setlength{\tabcolsep}{5pt} Which add extra tabbing space in the tables. However, in one place ...
0
votes
1answer
42 views

Referencing my own command

I'm trying make my own command for a requirements document. I'm now looking for a way to reference my requirements. This should be possible by using \ref and the later on with the hyerref package. ...
2
votes
1answer
33 views

Arithmetic in tabular lengths ( p{…} )

I'm trying to do some simply arithmetic for a dynamic column type in tabularx. What I want is to be able to calculate (n-1) * X. I tried to use the calc package, but I just cant figure it out. ...
0
votes
0answers
26 views

When should one place an % at the end of a line to prevent the insertion of unwanted space [duplicate]

I understand that a % character at the end of a line prevents the insertion of a space in the text. However when creating macros I am unclear when you should place a percent sign at the end of a line, ...
1
vote
2answers
48 views

Numbered \newcommand without enumerate

How to add numbered problems within chapters and sections but not with enumerate. Problem must have variable as defined below. \documentclass[10pt,a4paper,oneside]{article} ...
4
votes
1answer
40 views

Extract the last word from a sentence stored in a variable

I want to extract the last word of a sentence stored in a variable, e.g. \thevariable. Here is the minimal example. \documentclass{article} % Function to extract the last word of a sentence ...
5
votes
3answers
158 views

Generate a table with 19 arguments using key-value interface

I'm doing my bachelor thesis, and need to make a table with lots of data. I want to make a macro for that table, since I'm going to use it a few times. Considering egreg's answer in this question, ...
7
votes
2answers
136 views

Why does twocolumn mode break usage of \AtBeginDocument{}?

I've been happily using the multicol package to layout a set of documents that are generated for multiple output formats from the same source. By necessity this moves same code from the document ...
2
votes
1answer
22 views

Nested commands with parametrized names

Inside a command I would like to define multiple new commands. Their names are parametrized by arguments, but they should also be able to call each other during definition. Here is an example: ...
4
votes
0answers
59 views

guess a number proportional to another [closed]

This is a challenging question. I am not sure how to begin coding it, or whether it is easily possible in TeX. I wish to define a command that takes in input of a simple formula such as Z = X x N + ...
1
vote
1answer
37 views

Spacing after alias [duplicate]

I'm not sure whether I am repeating an already existent question or not, but I'd like to know how to approach the following situation: I want to define a macro to be an alias to some word or fragment ...
11
votes
2answers
84 views

split off function for variable as separator

How/Possible to change this implementation of \xSplit so that the separator is a variable filled in at the time of definition (\edef somehow?) or at the actual use of the command?? %based on the ...
5
votes
2answers
81 views

How can I use \XeTeXcountglyphs\font in a pgf \foreach macro?

Problem I keep getting: You can't use `\XeTeXcountglyphs` in vertical mode. Attempt \documentclass{article} \usepackage{fontspec} \usepackage{pgf} \usepackage{pgffor} \begin{document} ...
3
votes
1answer
72 views

Where is \printtoctitle defined?

I can use \show\printtoctitle to get its definition, > \printtoctitle=macro: #1->\printchaptertitle {#1}. l.5 \show\printtoctitle but grepping for it through my latex installation I don't ...
4
votes
2answers
93 views

macro help with $\mathbb{Z}/p^{a}\mathbb{Z}$

I am using \mathbb{Z}/p^{a}\mathbb{Z} many times in my work with variable a, I was thinking can I define a macro like \Z_p^{a} which will give the above result. I tried ...
13
votes
1answer
223 views

How to show keys (ctrl, alt, …, etc.) as fancy as StackOverflow? [duplicate]

In StackOverflow, I can show keys like this: ctrl + alt. How to do the same things in LaTeX?
1
vote
0answers
43 views

TexStudio: Multiple Cursors in Macro

however looking up my questions using the usual suspects (Google, search function etc.) I could not find an answer/solution to the following task (potentially I don't know the proper name of the task ...
5
votes
2answers
90 views

Tikz: Latex macros in draw to [in=,out=] and point coordinates

I want to use latex macros in the calculation of the coordinates in a \draw command but that seems not to be possible if both the target point coordinates and [in=...,out=...] instructions involve ...
1
vote
0answers
47 views

Macro passing problem with pgfmath

As a continuation of thread 2010/2014 versions difference: I am trying to decorate program listings with highlighted lines, numbered balls, etc. In 2010, I used a macro which does not work any more ...
2
votes
1answer
28 views

How can I pass variables to \renewcommand from within another command (\DeclareRobustCommand)?

Situation I need to set a few commands and variables based on what language a document is written in. To do this, I pass an ISO 639-1 language code to a command ...
0
votes
1answer
26 views

Names on certificates [duplicate]

I have to make some certificates. The main problem is not the certificate itself but to change names between pages. Can I create a list of names, each of appears once for page?
12
votes
6answers
654 views

command for writing a sequence of numbers

While writing a document with many sequences of numbers (and various lower and upper boundaries), I would like to define a command such as \myscale{1}{6} that would produce: 1 2 3 4 5 6 What ...
1
vote
0answers
42 views

Package xthesis [closed]

\usepackage{xthesis} error messages: command\properpagestyle already defined. ...yle{myheadings}\markboth{}{}\markright{}} command\dedication already defined.{\vfill\end{center}} This errors ...
2
votes
1answer
50 views

CurVe document class: Adjust spaces between entries cross rubric or inside certain rubric without \vspace

I am using CurVe document class to create my CV. I want to know if there is anyway to adjust the spaces between the entries (\entry*[...]...) as indicated by the Figure 1. I know I can always put ...
2
votes
1answer
38 views

Textual replacement macros to wrap environment

I want to create simple textual replacement macros for an environment: \def \myEnvStart {\begin{someEnvironment}[enormous list of arguments]} \def \myEnvEnd {\end{someEnvironment}} This doesn't ...
7
votes
1answer
94 views

Macro for pgfplots/gnuplot exponential regression line

I am trying to create a series of plots with exponential regression that are automatically generated from comma/tab separated .csv files and pgfplots with help from gnuplot. When not using macros I ...
4
votes
1answer
60 views

How to control conditional statements within new commands and environments

I'm writing a pretty complicated class to typeset a book based on memoir. One of my commands draws a caption on the preceding verso page, draws content on the following recto and verso pages, and ...