Hot answers tagged

8

whatever is defining \r is incorrect and breaking latex so you should report a bug even if you can not change it. Use \let\temp\r before importing the bad definitions and put \let\r\temp after them to restore \r. You could of course redefine \AA but \r is an encoding specific command so it is (re)defined if you switch encodings such as \usepackage[T1]{...


5

From the description of the flow required this seems quite simple \newcommand\buildmacro[1]{% % Create a new counter named after the argument \newcounter{#1Xcounter}% % Create a new command named after the argument, % itself taking one argument \expandafter\newcommand\csname #1\endcsname[1]{% % Step the counter \stepcounter(#1Xcounter)% ...


5

As I mentioned in a comment, neither a hyphen nor a numeral can be used when constructing macro names unless you will always write the equivalent of \csname ... \endcsname or ensure the catcodes are changed when using them. Hence, it is necessary to modify the user interface from that suggested. The basic idea seems to be to create a series of indexed ...


4

A \@namedef and \@nameuse version, faking 'macro' names that would not be possible without catcode change. The allocation of \newcounter inside of macros may cause troubles with counter registers. \documentclass{article} \makeatletter \newcommand{\buildmacro}[1]{% \newcounter{#1Xcounter}% \expandafter\newcommand\csname #1\endcsname[1]{% \...


4

You need to supply an explicit control sequence for \newcommand, and \csname <text>\endcsname is not a control sequence until it is expanded. Using \expandafter\newcommand\csname hello\endcsname{<stuff>} expands to \newcommand\hello{<stuff>} as a result of the \expandafter skipping over \newcommand and expanding \csname hello\...


3

The “official” syntax for \newcommand is \newcommand{<macro name>}[<args>]{<text>} or \newcommand{<macro name>}[<args>][<default>]{<text>} but it turns out that the braces around the <macro name> are optional, so long as a single token appears. The braces are good for avoiding mistakes, but some self-...


3

The effect you're showing in your pseudocode is much more easily obtained with a list macro, that allows to do a loop without having to know how many objects are in it and without stepping counters. \documentclass{article} \makeatletter \newcommand{\Titlecontainer}{\@empty}% initialize \newcommand{\Title}[1]{% \expandafter\def\expandafter\Titlecontainer\...


2

You're starting and ending the \vtop in the “begin” part, so \begin{itemize} is executed and the box ends before the contents of the environment is even examined. TeX allows starting a box with \bgroup and ending it with \egroup. \documentclass[12pt]{article} \usepackage[a5paper]{geometry} \usepackage{microtype} \usepackage{multicol} \usepackage[...


1

A big issue you have to deal with is expandability of content, since you're writing to the terminal. To get around this, I define two versions of your \myapp and \myproduct functions. The regular \myapp and \myproduct are declared to be robust, while \@myapp and \@myproduct are expandable and simplified versions of their counterparts (removing font-related ...


1

Is this what you want? \documentclass{article} \usepackage{fontspec}% use xelatex \usepackage{titlesec}% adds \thetitle and \@currentlabelname \usepackage{nameref} \usepackage{regexpatch} \usepackage{currfile}% adds \currfilepath % Define a couple commands to track \newcommand\myapp[1]{\textit{#1}} \newcommand\myproduct[1]{MacGyver.\textit{#1}}% ...


1

\def\activatelayerone#1{% \def\layertwo##1{% \appendmacro{##1} }% }% Apart from defining \layertwo to be append and add a spurious space because of the missing %, this acts as \@gobble to discard the next token as #1 is not used. Here the next token is \layertwo so that is discarded and {item5} is just typeset at that point.


1

Handling LuaTeX with hyperref and lacking the unicode option is going to be tricky, but the other cases can all be covered by forcing expansion. You have to remember that hyperref is seeing not the result of the case changing but the input, otherwise. Something like \usepackage{xparse,letltxmacro} \LetLtxMacro\oldsection\section \makeatletter \...



Only top voted, non community-wiki answers of a minimum length are eligible