New answers tagged

0 votes

Recursively update macro

You are doing full expansion (\xdef) of previous macro declated by \update but \underbrace is more complicated macro which uses \halign with # in its preamble and this cannot be fully expanded without ...
user avatar
  • 53.4k
0 votes

Recursively update macro

underbrace is a robust command protected by LaTeX's \protect mechanism. For the mechanism to work properly you need the protected@ functions. \documentclass{article} \begin{document} \def\temp{} \...
user avatar
  • 2,071
0 votes

How do I create macros that take + (plus) or - (minus) separated arguments as inputs and stores them to variables (e.g., coefficients of polynomials)?

You can read numbers to registers \coefnum and \expnum and run next macro using \afterassignment. \newcount\coefnum \newcount\expnum \def\polycoeff#1{\polyA#1\relax} \def\polyA{\afterassignment\...
user avatar
  • 53.4k
1 vote

Math Symbols Palette?

Check out: https://www.caam.rice.edu/~heinken/latex/symbols.pdf This is a pdf document listing all mathematical symbols with Latex coding. Nice document to have for reference.
user avatar
0 votes

Doing an interlinear text

Using expl3 - a demonstration The same Greek text, three times, can keep things in sync. First line, each word is looked up as a key in a property list to find the Strong reference number as value, ...
user avatar
  • 7,344
0 votes

escape hashs (#) passed as argument to use them in inner macro

In this specific case there are some "workarounds": In case you can tolerate some "global namespace pollution" you can do this \documentclass{article} \usepackage{xcolor} \begin{...
user avatar
  • 2,071
2 votes

How to use new line command while using multicolumn in tabular?

Like this? With talltblr defined by the tabularray package: \documentclass{article} \usepackage{tabularray} \begin{document} \begin{talltblr}[ caption = {Overview of statistic. Diff.: Differened}, ...
user avatar
  • 255k
3 votes

TikZ \foreach loop with macro-defined list

Starting with version 3.1.7 (November 2020), TikZ supports the expand list option for \foreach. From the TikZ & PGF manual: /pgf/foreach/expand list={<boolean>} (default false) If this key ...
user avatar
  • 2,914
0 votes

Using \Makelowercase in includegraphics

In case \includegraphics' optional argument contains things that shall not be lowercased and/or some component of the filename shall not be lowercased, you can use a macro for composing the call to \...
user avatar
  • 23.4k
1 vote

escape hashs (#) passed as argument to use them in inner macro

For comparison: what we need to do in OpTeX: \fontfam[lm] \def\Foodeclared{} \optdef\DeclareFoo[]{\ea\def \ea\Foodeclared \ea{\the\opt}} \optdef\Foo[]#1{{\em \Foodeclared \the\opt #1}} \DeclareFoo ...
user avatar
  • 53.4k
2 votes

Using \Makelowercase in includegraphics

The \Makelowercase LaTeX macro uses \lowercase TeX primitive and this command cannot be used as an argument denoting file name. This argument is only expanded but commands like \lowercase cannot be ...
user avatar
  • 53.4k
3 votes

Using \Makelowercase in includegraphics

I'm very sorry, I can't solve your problem very elegantly, I think the following code should make your project work: \ExplSyntaxOn \cs_set_eq:NN \Lowercase \str_lowercase:n \ExplSyntaxOff \newcommand{\...
user avatar
  • 875
0 votes

Understanding the code and trying to learn

Two more examples: \documentclass[10pt,a4paper]{article} \usepackage{tikz} \usetikzlibrary{calc,snakes} \usetikzlibrary{ decorations.markings} \begin{document} \begin{tikzpicture}[scale=.6] ...
user avatar
0 votes

Understanding the code and trying to learn

Another pedagogical (I hope) example: \documentclass[border=10pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=1.5] % rotate (six time) a square around hi center ...
user avatar
1 vote
Accepted

Include PDF with section title only on first page

Just test the number of pages in the PDF first (cf. this question). \newcommand{\insertScore}[3] {% \pdfximage{#1/score.pdf}% \addcontentsline{toc}{section}{#2}% \includepdf[scale=0.8,pages=1,...
user avatar
  • 12.7k
1 vote
Accepted

Automate an equation form previous code

In \addsubnumlinetoright (sign tex-sx doesn't support diff highlighting), % before \node at (\xtxt,1) {$-5 +8 = 3$}; %code I would like to change % after \node at (\xtxt,1) {$#1 + \the\numexpr#2-(...
user avatar
  • 21.7k
0 votes

Compile to PDF file with different name than the source

LuaTeX has a callback that can be used for this. %! TEX program = lualatex \documentclass{article} \usepackage{luacode} \begin{document} 123 \begin{luacode*} luatexbase.add_to_callback("...
user avatar
  • 2,071
1 vote
Accepted

Setting left margin in itemize pushes right-margin to be unaligned to section-right

Unless you're getting different results from me, the problem isn't that they're not right aligned. The problem is that the items inside the lists started with \resumeSubHeadingListStart are typeset ...
user avatar
  • 36.6k
0 votes

Get \string-ification of first opening brace in argument?/Get \string-ification of first opening brace's matching closing brace in argument?

Use \tl_analysis_map_inline:nn. The inner code can use three arguments: one is a representation of the token, then the character code if the item is a character, and finally the category code. You can ...
user avatar
  • 992k
0 votes

Get \string-ification of first opening brace in argument?/Get \string-ification of first opening brace's matching closing brace in argument?

Since I think writing complex code such as the above is way too complex, I decide to write a "compiler" that compiles easy-to-understand imperative-style code such as this... that's the ...
user avatar
  • 2,071
3 votes

What is the best way to expand macros inside keyval input in expl3

You can recursively scan the list of options, expanding once an item that's a single control sequence. \documentclass{article} \ExplSyntaxOn \clist_new:N \l__ljr_keysexp_clist \bool_new:N \...
user avatar
  • 992k
2 votes

What is the best way to expand macros inside keyval input in expl3

The following remarks do not answer your question, so probably don't upvote this "answer". The following remarks do not fit in a comment. They are intended to draw attention towards ...
user avatar
  • 23.4k
1 vote

What is the best way to expand macros inside keyval input in expl3

Create a new expanded variant of \keys_set:nx? \documentclass{article} \ExplSyntaxOn \keys_define:nn { test } { key1 .code:n = \tl_to_str:n {#1}, key2 .code:n = \tl_to_str:n {#1}, key3 ....
user avatar
  • 4,123
2 votes
Accepted

Understanding the code and trying to learn

Your code: contain error(s), therefore we cannot test it; is very -- to my opinion unnecessary -- complex and unclear (I must confes, that I went lost in it); is not entirely clear, what should your ...
user avatar
  • 255k
1 vote
Accepted

Failed to use TikZ to draw lines matching \delimsize

Give the line correct height (equivalent to non-latex3 code \the\dimexpr\ht\mybox+\dp\mybox if \newbox\mybox \setbox\mybox=\vbox{$#1\vert$} is set) Set the correct baseline for tikz drawing (at ...
user avatar
  • 21.7k
1 vote

Declare new command to denote the condition with additional settings

Here is a solution via my own, slightly non-standard package, SemanTeX. I took the liberty to change the order and meaning of some arguments and keys in a way that made the implementation easier: \...
user avatar
  • 11k
1 vote
Accepted

Using a CSV File to Drive Custom Macro

In your definition of \checkboxYesNo you find the line \str_if_in:eeTF { \str_foldcase:n { #2 } } { \str_foldcase:n { #1 } }. My guess is that \str_if_in:eeTF triggers expansion of \str_foldcase:n ...
user avatar
  • 23.4k
0 votes

Call specific Command in combination with argument in Latex

If your LaTeX installation is up to date (2022-06-01 version) you can do \newcommand{\SomeCommand}[3]{\UseName{Hello#1} \UseName{Hello#2} \UseName{Hello#3}}
user avatar
  • 315
1 vote

Call specific Command in combination with argument in Latex

I'd do it with property lists. You can define a property list based on an arbitrary name, in the example Hello and populate it. Then you can extract the items by key. \documentclass{article} \...
user avatar
  • 992k
3 votes
Accepted

What is `\mathopen{}` for?

Some people write ]-1,1[ to denote the open interval from -1 to 1. The default TeX math status of the characters [ and ] is mathopen and mathclose, respectively. To properly typeset the open interval ...
user avatar
  • 439k
1 vote
Accepted

Regarding the separation line in the expression of sets

This is a proof of concept. You may want to use TikZ for a better dashed or dotted line, but the idea is the same: measure the height plus depth of \delimsize\vert. \documentclass{article} \usepackage{...
user avatar
  • 992k
0 votes

Misplaced \omit and \multicolumn in \IfEqCase

For information, if you use {NiceTabular} of nicematrix, with its built-in command \Block instead of \multicolumn, you have directly the output you wish (because \Block is a protected command which ...
user avatar
  • 25.4k
3 votes
Accepted

Remove Whitespace After a Macro

You could replace \NewDocumentCommand{\programName}{m}{% \textbf{#1} program } with \NewDocumentCommand{\programName}{m}{% \textbf{#1} program} If you don't want to move the closing curly ...
user avatar
  • 439k
1 vote
Accepted

Create a version of a theorem whose environment name is capitalised

I'm not sure what would the usage of this would be: having two environments defi and Defi that do exactly the same is useless and possibly confusing. Anyway, you can use \text_titlecase:n (with a ...
user avatar
  • 992k
1 vote

Create a version of a theorem whose environment name is capitalised

You can use the TeX primitive \uppercase directly, but this is still not expandable, so we have to trick a bit. \createTheorem@a is used to get the first character, and calls \createTheorem@b after ...
user avatar
  • 48.9k
1 vote

Create a version of a theorem whose environment name is capitalised

As mentioned above, MakeUppercase is not expandable. You can use expl3 functions str_uppercase:f instead which is expandable: %! TEX program = lualatex \documentclass{article} \usepackage{amsmath} \...
user avatar
  • 2,071
2 votes
Accepted

Is there an equivalent of "AtBeginSection" for appendix?

Turns out, as John suggested in his comment, this is very easy to do by redefining \appendix! I did not add a hook, as I have trouble getting \write\@auxout to work, and instead simply made the ...
user avatar
1 vote

From \newcommand to \NewDocumentCommand

Suggestion: To save typing the name twice, you can do: % def characters \newcommand\declname[1]{% \expandafter\newcommand\csname #1\endcsname{\par\vspace{5mm}\noindent\makebox[35mm][l]{#1}\...
user avatar
  • 7,344
3 votes
Accepted

From \newcommand to \NewDocumentCommand

If you would like to simplify it, you can define a common macro for each four persons because there is the same format commands for each person. % def characters \def\declname#1#2{% \def#1{\...
user avatar
  • 53.4k
4 votes
Accepted

\NewDocumentCommand not working in pgfplots when \newcommand does

pgfplots does one-step expansion when it encounters a control sequence in <coordinates list> from input \addplot ... coordinates {<coordinates list>}, see \pgfplots@foreach@plot@coord@...
user avatar
  • 21.7k
3 votes

\NewDocumentCommand not working in pgfplots when \newcommand does

\NewDocumentCommand defines \protected macros. As such, they aren't expanded inside \edef, \write, etc. The macros defined by \NewExpandableDocumentCommand don't have this property, so it is a natural ...
user avatar
  • 22.7k
1 vote

How to make an environment for a tikz nodes content

You can not nest tikzpictures — dragons will be there. But if you have a new enough latex, you can "grab" the whole environment using the +b type of parameter, and you can nest a tikzpicture ...
user avatar
  • 30.1k
2 votes

How to make an environment for a tikz nodes content

Nested tikzpictures are unsupported and unneeded here, as far as I understand the goal. You can use \bgroup and \egroup to avoid the brace-balancing issue. \documentclass{article} \usepackage{graphicx}...
user avatar
  • 22.7k
1 vote

How to make an environment for a tikz nodes content

The environ package has a \BODY macro that contains what you have fed to the environment. If I have understood your wishes correctly I think that this could work for you. :) \documentclass{article} \...
user avatar
2 votes

How to check if figures are on the same page of call out/text?

OpTeX users can create following definition of the \check macro: \def\check{\label[x/\_lastreflabel]\wlabel{}% \space \ea\ifx\csname _pgref:x/\_lastreflabel\ea\endcsname \csname ...
user avatar
  • 53.4k
3 votes
Accepted

How to make \NewDocumentCommand respect spaces and paragraphs?

Spaces and endlines have always been a problem in TeX programming. When starting to develop a new programming style for LaTeX, namely expl3, the team decided to provide tools for controlling ...
user avatar
  • 992k
2 votes

How to implement token.get_char

If you are using \directlua (i.e. no external .lua file) then you can get the value from TeX world to the Lua world by expanding it inside the Lua code, because \directlua expands its argument before ...
user avatar
  • 53.4k
2 votes
Accepted

Define new command for split environment

The following is copy-and-pasted from technotes.tex in the amsmath distribution 6 Why can’t I use abbreviations for \begin{align} . . . \end{align}? Authors often like to use abbreviations such as \...
user avatar
  • 19.9k
0 votes

Define new command for split environment

This way it will work: \documentclass[12pt]{article} \usepackage{amsfonts,amsfonts,amsmath,amssymb,bm} \newcommand{\beq}{\begin{equation}} \newcommand{\eeq}{\end{equation}} \newcommand{\bsp}{\begin{...
user avatar
  • 1,735
3 votes
Accepted

How to implement token.get_char

The fastest way is to extract the value from the token using .index \directlua{ local char_given = token.command_id'char_given' local function get_char(name) local tok = token.create(name) ...
user avatar

Top 50 recent answers are included