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

1
vote
1answer
92 views

Opinions: Circuit_macros or circuitikz ? what is better? [closed]

I'd gladly read your opinions on Circuit_macros pros and cons, as well as yours on circuitikz. Gives the macro more variables to play with? Is the circuitikz language easier? Macro use seems far more ...
0
votes
0answers
55 views

Ignoring parts of text inside macro

Consider the following code: \documentclass{book} \usepackage{pgffor} \begin{document} \newcommand\containers{ \cont{aaa{\bf don't xstring me}aaa} \cont{bbb\large bbb} ...
2
votes
1answer
41 views

renewcommand the chapter in chinese problem

I move code from Miktex into Texlive. But I get errors: Run in Xelatex ! Undefined control sequence. \chaptername ->第\CJKnumber {\thechapter }章 l.33 \chapter{绪论} ...
2
votes
1answer
52 views

marginpar in a macro steal the bullet of itemized list

I have an odd (to me) problem involving an itemize environment and \marginpar{}. The problem is illustrated in the following document: \documentclass{article} ...
0
votes
1answer
31 views

Problem with \newcommand{\nal}{\end{align*}} [duplicate]

Why do these newcommands result in error when used? \newcommand{\bal}{\begin{align*}} \newcommand{\nal}{\end{align*}}
2
votes
2answers
60 views

What is the difference between a package and a template in LaTeX?

I was looking at the post How to disable automatic indentation on new paragraphs? and the given comments. It was suggested that I go to Ask Question. Which is what I am doing now. Somebody was ...
4
votes
2answers
51 views

Trouble using convertchar and thestring inside a LaTeX command or table

I'm trying to generate page references inside a command that defines a row of a table, with the name of the label being referenced generated as a result of some string maniupulation using ...
6
votes
4answers
98 views

Using MakeLowercase and StrSubstitute together

I'm using LaTeX and have a string that I want to remove underscores from, and convert to lower case (in either order). The individual steps work: \MakeLowercase{AB\_CD} \StrSubstitute{AB\_CD}{\_}{} ...
1
vote
0answers
19 views

Defining New Command with regular text inside math mode (Notation) [duplicate]

I would like to denote the volume of a lattice as vol $L$ and the determinant similarly as det $L$, so that the words "vol" and "det" are in the normal/regular text format but the L is in mathmode. ...
3
votes
3answers
113 views

How to use a macro to store the default pgfplot properties

I have some default settings for my pgfplots plots, such as xlabel, ylabel, width and so on. Since I have a large number of such plots and don't want to repeat all the properties, I want to store them ...
4
votes
2answers
126 views

Problem with defined macro and blank lines

I am using the following command to color some text: {\color{NavyBlue} Text Here! } Because I used it frequently I created this macro: \def\cl#1{{\color{NavyBlue}{#1}}} When I am using the ...
1
vote
1answer
39 views

Automatically enclose \glt line from gb4e in \enquote{}

How can I automatically enclose the \glt (\trans) line in gb4e's interlinear glosses in context-aware quotation marks with \enquote{} from csquotes? \documentclass{article} ...
4
votes
1answer
59 views

Probsoln customization of solution environment (set as marginpar)

I'm using probsoln, and I want to put the solution as a marginpar and with footnotesize. Please look at the MWE below. Writelatex won't compile, spitting out LaTeX Error: \begin{solutionnew} on ...
0
votes
1answer
50 views

Variable number of arguments for \newcommand

I use the following command to write my matrix variables \newcommand{\mymat}[3]{\ensuremath{\mathbf{#1}^{#2}_{#3}}} Thus #1 is the matrix variable, #2 is the superscript and #3 is the subscript. ...
2
votes
1answer
58 views

PGFPLOTS: How To Put \addplot boxplot prepared Inside Macro Definition

I have a need to wrap the `\addplot [boxplot prepared]' inside a macro to greatly save typing. It seems simple enough, but the devil is in the details with macro expansion issues. Is this doable given ...
6
votes
1answer
31 views

Value of \def specified via command line not being properly recognized

I am having difficulty understanding why defining a macro on the command line is being treated differently than if it is specified in the file. The MWE below allows \FormattingMode to be set to Print ...
1
vote
1answer
68 views

pgfplots: Optional graph range arguments in a macro

I defined a macro that inserts a plot that I can re-use the same graph style in multiple places. Mine actually loads data from a file, but a similar MWE looks like: \newcommand{\drawGraph}[1]{ ...
4
votes
1answer
64 views

Problem grouping environments

Below are two examples. The first one works fine, no errors no warnings, but on trying to build a doc from the latter, I get a heap of errors. Working: \documentclass[]{article} \usepackage{environ} ...
2
votes
0answers
41 views

How to divide underline with ULEM package?

In some Chinese books, proper nouns were underlined uncontinuously. How to divide underline with ULEM package, as in the first pic? I changed the ulem package, and want to seperate some words, ...
6
votes
2answers
141 views

Trying to convert Hrs:Mins to Mins

I am having a bit of trouble trying to convert a time format from Hours:Minutes for instance 12:05 into 12*60+5 = 725, ie I would like to use 725 as a number of minutes. I am already using the number ...
0
votes
0answers
31 views

Having a problem generating a command that make chapter and label in one line

I'm writing my thesis, modifying the ezthesis template. I did a new command that mix chapter and label in one line. \newcommand{\chaptercolored}[2]{\textcolor{colorchap}{\chapter{\textbf{#2}}}% ...
3
votes
1answer
38 views

Pass blank as argument to a command

How can I pass a blank to this command \newcommand{\iam}[1][happy]{I am #1.} so that I get this result I am . Note: My actual command operates in the math mode, so the space between "am" and "." ...
2
votes
1answer
54 views

newcommand with \href [duplicate]

I'm having trouble using newcommand with the \href I would like a newcommand like this: \newcommand\link[2]{\href{#1}{\underline{#2}}} This command works fine quite all, for exemple: ...
3
votes
2answers
242 views

How to redefine “\ ” (that is “<backslash> <space>”)?

In (La)TeX, is there a way to redefine the command \  (that is "<backslash> <space>")? I have lots of texts where \  is used as non-breakable space after "." characters like in ...
3
votes
1answer
111 views

How best to differentiate questions and answers in a document without compromising on typesetting and readability?

Preliminary note: I don't think this question is completely or even to a large extent subjective, as it seeks how to achieve objective utilitarian goals. Please read: I am solving my QFT assignments ...
4
votes
2answers
59 views

Put text into small parts of a picture

I have used the \multiput command to create a for example 4 by 4 table: \documentclass[a4paper,12pt]{report}‎ ‎\usepackage{graphicx} % inserting images‎‎ ‎\begin{document}‎‎‎‎ ‎‎ ...
2
votes
2answers
55 views

What macros do I have to invoke to get the day of month, month, and year?

What macros do I have to invoke to get the day of month, month, and year of the current date? I am a beginner in LaTeX.
1
vote
1answer
108 views

LyX command(s) to insert WYSIWYG horizontal line, for keyboard shortcut

Using the menu entry Insert > Formatting > Horizontal Line I can insert a WYSIWYG horizontal line into a LyX document. I want to figure out the internal command(s) used to do this so I can set up a ...
5
votes
2answers
46 views

New command adding extra space

I'm having a problem with a command with empty output adding an extra space. I have a large document that needed a number of corrections. To highlight the text added and removed for easier review, I ...
3
votes
1answer
39 views

Help for a complicated macro: breaking pages at custom places and itemize environment

In this answer, there is a macro that allows one to have a precise control of the page lengths of a document. This macro is too complicated for me and I have found a problem with it. It behaves ...
0
votes
0answers
24 views

How to use function \newcommand to turn off math mode? [duplicate]

I have a problem. I defined new commands: \newcommand\be{\begin{equation}} \newcommand\ee{\end{equation}}, which works perfectly for math mode. Then I tried with more advanced formulas: ...
5
votes
1answer
52 views

How can I write a command that defines another macro which may optionally be prefixed by \global?

In various contexts I define a macro such as \makeatletter \newcommand\aedosomething{\ae@do@something} \def\ae@do@something#1#2#3{%% %% do something with arguments #2 and #3 \def#1{<result ...
4
votes
3answers
140 views

Expansion Issues When Passing TikZ Styles to Macro Created by Macro

I'm struggling (again) with expansions. This time I have a generic function \misdirection that creates a TikZ environment subject to a few options. Then, I create a macro \freezeStyle that creates a ...
3
votes
3answers
107 views

Processing Plain Text

I'm currently trying to typeset a plain text file that has a certain structure. There's one thing that I can't get working, and that is the following. My plain text is structures as follows: "lorem ...
1
vote
1answer
43 views

I cannot run texnic centre on my miktex

When I try to run latex.exe on my document, the following shows up: C:\Program Files (x86)\MiKTeX 2.90\miktex\bin\latex.exe Cannot execute the command. Error:The system cannot find the file ...
0
votes
1answer
71 views

Bold or arrow vectors with new command

Im quite new to latex, I would like to make either bold or arrow vectors. I found many solutions to this but i cant see where i am doing it wrong, my code is \documentclass[a4paper,11pt]{report} ...
7
votes
2answers
104 views

Reuse command portion in LaTeX

I defined several new code environments (using listings' lstnewenvironment); they all share the same attributes except one (the language used). For example: \documentclass[a4paper,12pt]{book} ...
3
votes
1answer
31 views

Using \snoc as macro name inside mathpar

I'm able to define a macro called \snoc but unable to use it inside a mathpar environment: \documentclass{article} \usepackage{mathpartir} \newcommand{\snoc}{hi} \begin{document} \begin{mathpar} ...
0
votes
0answers
16 views

how to use \savesymbol for the bibliography?

My bibliography contains, among others, several words in polutonikogreek. I haven't found a better way than to use the polutoniko-macros from teubner. As some other package redefines the macro \aa ...
3
votes
1answer
51 views

Opening and closing brackets in combination with the ifthen package

Related to this question, however, I was not able to solve my problem. Let me give some background. I want to switch between the article style and a specific journal style. The journal style has ...
5
votes
1answer
135 views

I want to include a closing bracket } in a \newcommand definition

I want to use the closing bracket in a \newcommand definition. I can give more explanation as to why, but this seems unnecessary at the moment. Obviously the MWE does not work, but how to make this ...
2
votes
2answers
51 views

Passing the value of a register as a macro argument

I'm looking for a solution to the following problem: \def\m#1{{ \dimen0=200pt \#1=\the#1 % Outputs 200pt rather than 100pt }} \dimen0=100pt \m{\dimen0} EDIT: The code sample above ...
5
votes
3answers
208 views

Macros that write macros and unexpected side effects

I'm having some trouble fixing a macro I wrote. I believe that it has to do with \let, \def, and \edef. I have gone through: What is the difference between \let and \edef? but I still can't seem to ...
2
votes
1answer
73 views

Can't use command with square brackets in matrix environment

I've defined a command that uses square brackets, and when I use it within a matrix environment, the command is not parsed. I stumbled upon a solution to my problem here: "[" Square bracket ...
1
vote
1answer
38 views

How to renew the \rightarrow command?

I am playing and exploring the renewcommand and newcommand right now, and I tried to do: \renewcommand{\rightarrow}{\mathlarger{\mathlarger{\rightarrow}}} I get it to work with the newcommand like ...
2
votes
0answers
47 views

How to define a macro which does not read the next token after itself? [duplicate]

In LaTeX, I would like to define \newcommand{\ACROeg}{e.\,g.} This is a sample sentence, \ACROeg it does not make much sense. but this yields This is a sample sentence, e.\,g.it does not make ...
2
votes
1answer
71 views

Passing a command as an argument

I got a solution for my quoestion about Smaller roofs for forest but I want to pass a command instead of text to a procedure and this causes an error: ! Argument of \@rsbox has an extra }. ...
5
votes
4answers
126 views

Defining a macro a variable number of arguments

I want to define a macro that defines a series of other macros, each of which takes a variable (but in any given document fixed) number of arguments. I know that I can do this using something like ...
3
votes
0answers
40 views

Detecting currently running executable - and usage of Latex?

Somewhat in the similar vein as Getting Texlive version in pdflatex?, now I want to obtain the currently running executable inside a *tex run. Thanks to Write18: capturing shell (script) output as ...
0
votes
0answers
75 views

Wolfram Mathematica Functions in Lyx

Can I use all functions of mathematica in Lyx? I want to use functions like Solve[]