62 questions linked to/from When to use \LetLtxMacro?
132 views

### \let, \renewcommand, and optional arguments [duplicate]

Possible Duplicate: When to use \LetLtxMacro? I have a problem in redefining a command with an optional argument in terms of its old definition. Here is what I did: \newcommand{\testopt}[2][...
65 views

### renewcommand cause memory error when using default argument [duplicate]

I would like to add a warning in my log when using the \todo command. To do so i did: \documentclass{book} \usepackage[colorinlistoftodos,prependcaption,textsize=tiny]{todonotes} \let\oldtodo\todo \...
47 views

### \let on macro defined by \newcommand with optional argument [duplicate]

Suppose we have \newcommand{\foo}[2][optional]{#1 #2} defined somewhere (e.g. some package) and want to redefine it and re-use the original definition. This usually works with \let like described in ...
11 views

### Renewenvironment of with optional arguments enumerate goes wrong with enumitem (compilation stalls) [duplicate]

I want to modify the enumerate environment (from enumitem) to always be passed a certain optional argument. I expected the following code to work, but it always stalls (takes forever). \documentclass{...
20k views

### “Closed” (square) root symbol

I found a cool trick in the LaTeX wikibook which allows the square root sign to be altered such that it "closes" over its contents. Here's an example: ("closed" root on the left, normal one on the ...
712 views

### A new environment to decide dynamically which commands to run?

I am having some user defined commands defined and used in my latex document. I need a way to check whether any of the commands is used. I want to make decisions based on the argument used in the ...
3k views

### Duplicating Environments

When I want to globally modify a command in my document, I will often use a duplicated version of the original in the stencil, with the help of the \let macro. For example, if I wanted to do ...
5k views

### How to redefine a command properly to avoid recursive call to itself? [duplicate]

I'm trying to renew a command in terms of its old definition... something similar to this: \renewcommand{\vec}[1]{\vec{\mathbf{#1}}} But this seems to send the interpreter in an infinite loop. How ...
1k views

### Changing all single quotes to be straight when within texttt

I have a document with many ' characters inside of texttt. Is there a way to make them all appear straight when in texttt? I know that I can search/replace all ' with \textsinglequote: Adding ...
962 views

### TeX \newcommand and D.R.Y. (don't repeat yourself)

My goal is to create a list within a varwidth, and alternate the colors of each item. At the time, the best I could do is this: \documentclass{article} \usepackage[T1]{fontenc} \usepackage[utf8]{...
10k views

### Redefine \emph to be both bold and italic

2k views

### Problem with \renewcommand

I am trying to use \renewcommand to change the size of footnotes throughout the main text. I do this by changing \footenotesize to a different command, \scriptsize. Later on, I would like the command \...
2k views

### Command that returns current font size as a length?

I need a way to get the current fontsize as a length. I hope I didn't overlook anything that already provides this. What I found that I can do \makeatletter \newlength{\fsize} \setlength{\fsize}{\f@...
9k views

### How to rename an existing command?

I would like to know if renaming a command is possible in LaTeX. For instance, could I change the \section by \sec ? I read that some people used something called "alias".
5k views

### How to redefine the section symbol (§)?

I'm trying to redefine the section symbol (§) so that it automatically places a space after it. When inserting the symbol in text, I typically write \S{} Section Number which gets me the spacing ...
1k views

### Change Color of Proof

I'm using the \begin{proof} of the amsthm package. And I want to change the color of everything in this environment. Currently, I use {\color{blue} \begin{proof} ... \end{proof}}. But I need to do ...
990 views

### Automatically Determine which TeXLive Version is being used

I would like to be able to automatically determine which release of TeXLive that I am running. I sometimes encounter a problem where it is useful to test that the file compiled correctly in an older ...
607 views

### Auto-insert “Ref.” word before citation

I would like to ask if there is an easy way to auto-include a "Ref." word before any of my citations ie if I do Have a look in \cite{pub1} then to show up like Have a look in Ref. [1]
286 views

### Macro only to be defined in math mode

I often use short macros in mathematical formulas for frequently used symbols, e.g. \d x for a differential dx or, say, \v if I need a vector v very often in my text to make things more readable. ...
692 views

### \AtBeginChapter?

Are there any hooks that work like \AtBeginDocument for chapters, sections, etc.? Something like \AtBeginChapter? I would like to have the following code: \AtBeginChapter{% \setcounter{mycounter}{...
687 views

### How to get around \renewcommand?

1k views

### Using \textbf{} to make also math bold in sentence

Consider the following MWE: \documentclass{amsart} \begin{document} Let $(M,d)$ be a metric space. For any $x \in M$ and $r > 0$, the \textbf{open ball of radius $r$ around $x$} is the set \...
412 views

### Patching \printbibliography for displaying content to both document and log

Friends, I'm using a clever idea from Joseph, David and egreg in order to get the bibliography content displayed in both document and log (Henrique and I are trying to create a semi-automatic analyzer ...
278 views

### Empty optional argument or Not giving optional argument at all?

I learnt that \parbox has five arguments, that is: \parbox[<align>][<height>][<inner-align>]{<width>}{<text>}. So I constrcut my own \myparbox in which I add \sloppy\...
472 views

### Pass frame option to \includegraphics by default?

I'm a professional typesetter and in my job I format papers for scientific journals. One of my task is (in some cases) to crop images to remove extra space between the images and the bounding box. ...
279 views

### Delaying command expansion that appears in \begin handler until \end handler executes

I have a custom environment for handling a code interface declaration that is specified as: \begin{decl}{FOO} \param{in}{bar} the bar input parameter \param{out}{baz} the baz input parameter \end{...
127 views

### Replicating an environment to another and making changes to original

I would like to define a new environment with the name oldproof which is basically the proof environment and then make changes to the proof environment. I would still like to be able to access the ...
146 views

### Why doesn't my redefinition of \item recognize that it's been passed an optional argument?

I wanted to redefine \item temporarily, but also wanted to allow it to behave as much as the normal \item should. So, I thought by closely following the definition of \item, I would get the results I ...
1k views

### How do you change the font size globally for the \texttt environment?

597 views

### Font for small caps in (French style) figure caption labels

Polyglossia {french} in Memoir Class. My preferred font is Open Sans. MWE compiled with XeLaTeX: \documentclass[a4paper,article]{memoir} \usepackage[demo]{graphicx} \usepackage{polyglossia} \...
738 views

### Problem with \newcommand that mimics lstinline

I'm trying to replicate a part of a scanned book. Book is about programming (pure C). I need to use many commands with a same name but with different surrounding, for example, background color etc. I'...
1k views

### How to prevent line break within a (multiple) citation

I sometimes cite two or three references. When the citation is at the end of the line, latex inserts a line break. How can I prevent this from happening? I already tried what was suggested here Note:...
384 views

### \emph and punctuation

I know \emph is to be used to emphasize text. However once in a while, a punctuation mark follows emphasized text, mostly commas and periods. When \emph makes text italic, it should extend to the ...
517 views

### Force line break after item (with label) [duplicate]

I have looked at this solution and while it works for items without labels in my case I have the labeling environment (to be more specific: \begin{labeling}{alligator} ... \end{labelling}) and ...
297 views

### white space before \citep Macro

I am working on big book and need to ensure that all citations have a white space before them. I tried \let\citep ~\citep But that does not seem the right thing to do. Could you please help. ...
181 views

### Optional argument to \item to appear in brackets after the counter

Usually, when you have the following document: \documentclass{article} \usepackage{enumitem} \begin{document} \begin{enumerate} \item Mary \item[had] a little \item lamb \end{enumerate} \end{...
95 views

### Macro inserted via \everypar in \obeylines context doesn't see some commands

I have the following code which works as expected except, as noted in the code, when a macro begins a line of the xltabular being built: \documentclass{article} \usepackage[papersize={5.5in,8.5in},...
419 views

### Styling \Blindtext and \blindtext (aka renewcommand with optional arguments)

I am using blindtext package to draw out how the layout of the document will look like and then swapping the "dummy" parts with real text. Problem is that I would like to give some style to these text ...
390 views

### Bolding the first line of \item elements, question/answer sytle

I was wondering if it was possible to bold the first line of an enumerated list without effecting the remainder of the list. The output I want would be the same as: \begin{enumerate} \item \...
131 views

### Use \LetLtxMacro with a \Macro* (starred variant)

If I use: \LetLtxMacro{\MacroToUse}{\FormatText} then using \MacroToUse invokes \FormatText exactly as desired. But, how do use this construct to invoke \FormatText*? The MWE below yields: but ...
168 views

### Patching a command with an optional argument or declared with \DeclareRobustCommand

To re-define a command to contain itself (patching in TeX parlance) you usually use \let. This answer by @egreg says: Never use \let on commands defined with \DeclareRobustCommand or commands ...
419 views

### Wrap natbib macros \citep and \citet

How can I patch the natbib commands \citep, \citet and the like? I have tried xparse (MWE below), etoolbox (the \pretocmd and \apptocmd commands) and xpatch (the \xpretocmd and \xapptocmd commands) ...
252 views

### Aliasing, with or without argument?

411 views

### renewcommand \index

To make sure I've indexed what I should I want to footnote every indexed item in a draft of my document. The MNWE that follows is what I've tried. The renewed \index command properly creates an index ...
231 views

### Add prefix command(s) - counter of todos

I would like to see the number of todos I have left. Therefor I tried to redefine the todo command as follows: \newcounter{todocounter} \renewcommand{\todo}[2][]{\stepcounter{todocounter}\todo[#1]{#2}...
65 views

### How to store the definition of a command? Or, how to disable locally a command?

what? I would like to "store" the definition of \includegraphics into \something so that the following logics will work: % the following line is what I am looking for store(\includegraphics, \...
78 views

### Adding content to nonexpandable commands without a huge hassle

I'm wondering if there is a package or method to add content around delicate commands without changing the command's name. For example, let's say I want to change \sqrt[#1]{#2} command to yield \...
210 views

### change \eqref format with \RenewDocumentCommand (or other way)

This is a follow on for an answer in: What is the correct way to type "See Eq. (n) \documentclass[12pt]{report} \usepackage[UKenglish]{babel} \usepackage{graphicx} \usepackage{epstopdf} ...