New answers tagged

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}}% ...


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]{...


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.


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\...


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]{% \...


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 ...


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 \...


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[...


2

Since your formatting activation is done using *, you could use a macro-style approach to detect it using \@ifstar, similar to how \chapter conditions to \@chapter or \@schapter: \documentclass{article} \usepackage{pgffor,xcolor} \newtoks{\MyListA} \newtoks{\MyListB} \MyListA={ 2016-05-25: {Some plain comment, but has commas so is brace grouped}., ...


3

You need to expand \x once. \documentclass{article} \usepackage{xstring} \usepackage{amsmath} \usepackage{pgffor} \usepackage{xcolor} \usepackage{xparse} \newtoks{\MyListA} \newtoks{\MyListB} \MyListA={ 2016-05-25: {Some plain comment, but has commas so is brace grouped}., *2016-05-26: Some text with macros and "math" $sin^2 x + cos^2 x \ne 0$., ...


1

The \expandafter command tries to expand one level the token immediately following the next one. With your code, the tried token is {, which is not expandable. Reaching the last token in the argument is impossible with \expandafter, because you don't know how many of them there are. Some tricks are possible, though. The easiest one is to force complete ...


3

You want something like \edef\CurrentSubStage{% \unexpanded\expandafter\expandafter\expandafter {\csname SubStage\stage\endcsname}% } That is, you need to expand to the value in \csname SubStage\stage\endcsname. \edef is a TeX command which completely expands everything in the macro definition before assigning it the the macro it defines. In your ...



Top 50 recent answers are included