32
votes
Accepted
Use Markdown-style formatting for bold and italic
The nice thing here is that you can turn the feature on with \starON and turn it off with \starOFF (the default condition).
Here is the MWE.
\documentclass{article}
\makeatletter
\def\starparse{\@...
16
votes
Accepted
How to deactivate % as special character?
You can make % punctuation character by
\catcode`\%=12
13
votes
How to deactivate % as special character?
In ConTeXt you can use ASCII mode by saying \asciimode. This will disable the special meaning of #$%&^_|~ for the whole document from that point. You can still have comments with double percent ...
11
votes
Accepted
Why is \active defined as \char13 (and not 13)?
There are three issues here, two about performance and one about 'safety'. A \chardef'd token is parsed slightly faster than TeX looking for the end of a number, so \active is a little better in that ...
11
votes
Use Markdown-style formatting for bold and italic
The following solution uses LuaLaTeX's capabilities to define a function, called allstars, which converts instances of pairs of groups of asterisks -- ***...***, **...**, and *...* -- into "...
11
votes
Accepted
Why does \def@#1\space not work?
\def@#1\space{<#1>} doesn't work, unless TeX finds the token \space before the current paragraph ends.
Recall that TeX doesn't do expansion when
absorbing the parameter text of a macro
looking ...
11
votes
Accepted
In LaTeX3, how do I peek ahead for an active character?
You're almost there. \exp_last_unbraced:NV expands \c_catcode_active_tl only once, then
\exp_last_unbraced:NV \peek_catcode_ignore_spaces:NTF \c_catcode_active_tl
{ true } { false }
becomes
\...
10
votes
Accepted
Replace digits by arbitrary symbols
Changing category codes is the worst method, in my opinion.
Here's a simple implementation with xparse:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\overrideDigits}...
9
votes
Accepted
How to make active characters work differently in mathmode and text mode?
\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}
\catcode`*=13
\def*{\relax\ifmmode\expandafter\bm\else\expandafter\bstar\fi}
\def\bstar#1*{\textbf{#1}}
\begin{document}
*this bold* ...
9
votes
Accepted
'Missing \begin{document}' when using the \lowercase trick
The '\lowercase trick' relies on you having a char that is already active. The usual one in a document is ~ as it is active in plain, LaTeX and ConTeXt for creating a non-breaking space. However, ...
7
votes
Accepted
LuaTeX analogue of \ifcsname for active characters
The manual says
Active characters are internally implemented as a special type of multi-letter control sequences that uses a prefix that is otherwise impossible to obtain.
Poking around the ...
7
votes
Replace digits by arbitrary symbols
Here's a LuaLaTeX-based solution. I deliberately didn't optimize the Lua-side code, to make it easy to modify the output of each substitution operation even if you're not at all not familiar with Lua.
...
7
votes
Apostrophe in math formula prevents luatex compilation for Slovak
slovak.ldf loaded by \usepackage[slovak]{babel} is from 2008, it has not be adapted to the unicode engines and is imho completly useless and unsuited.
An alternative is to use the new ini-files from ...
7
votes
What are use-cases for active characters?
The classic example is ~ which in plain tex and latex is a macro (also known as \nobreakspace in LaTeX) that makes a non breakable space.
In LaTeX every character (byte) above 127 is active to ...
7
votes
Why don't unexpandable active characters work in \csname...\endcsname?
A \chardef token is not a character, but a command to print a character.
As such, it is not allowed inside \csname...\endcsname where only character tokens (after macro expansion) are permitted.
The ...
6
votes
Accepted
How to use comma-separated argument list in Verbatim environment?
Yes, you're right: the comma is made active in order to break ligatures (,, is a ligature defined in the T1 encoded fonts).
Since this is done as part of the initialization of verbatim environments, ...
6
votes
Accepted
Make equality-sign automatically blue
You need to make = math active.
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
% set up = to be math active
\begingroup\lccode`~=`=\lowercase{\endgroup\def~}{\mathrel{\textcolor{...
5
votes
Accepted
Error in some rare circumstances: babel with french option after listings, active character in moving argument, code in listing across pages
Here in short whats going on.
The colon is defined as \active@prefix :\active@char:. This definition is so that under certain conditions (e.g. in a protected@write, or when \if@safe@actives is true
(...
5
votes
Accepted
How can I conditionally designate an active quote in csquotes.cfg?
Upon seeing \MakeAutoQuote or \MakeAutoQuote*, csquotes defines \csq@string@<number> for both arguments in a suitable way. The <number> represents the decimal ASCII codes of the UTF-8 ...
5
votes
Use Markdown-style formatting for bold and italic
If you have not objection to use ' instead of *, then the wiki package is the easy solution.
This way there are not collision with starred macros. Moreover, it use the common Wikipedia syntax and ...
5
votes
Accepted
Modify catcode in the preamble or in the \AtBeginDocument?
In the argument of \AtBeginDocument, the comma is not active. The comma becomes active, when the argument with the category code setting is executed later in \begin{document}. Also keep in mind, that ...
5
votes
Accepted
babel's active " making problems in math mode
This is described in the babel documentation as a typical error, see section 1.5 on Shorthands. The problem is caused by the combination "}; the solution given is to add an empty pair of braces so ...
5
votes
How to deactivate % as special character?
A category code assignment is of the form
\catcode <number> = <number>
(spaces and = are optional). The first <number> is the character we want to assign the category code (so ...
5
votes
Accepted
Code redefining ampersand stops working when put in command
This will work:
\documentclass[]{article}
\begin{document}
\newcommand{\myampersand}{?}
% https://tex.stackexchange.com/a/392770/82912
\begingroup%
\catcode`&=\active%
\gdef\redefineampersand{\...
5
votes
Accepted
Characters made active and used the same way to define macros behave differently in verbatim environments
Every verbatim environment (also fancyvrb's descendants) explicitly sets & to category code 12 before starting to read the material.
The fancyvrb package has a facility to state category codes of ...
5
votes
Characters made active and used the same way to define macros behave differently in verbatim environments
Currently I use texlive of debian-linux. After updating the debian-package luaotfload-tool, compiling the following via lualatex
\documentclass{article}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{...
5
votes
In LaTeX3, how do I peek ahead for an active character?
An alternative way to extract the active character token from \c_catcode_active_tl is to use \exp_args:Ne:
\documentclass{article}
\ExplSyntaxOn
\NewDocumentCommand\zzMath{}{
\...
4
votes
Accepted
Conflict of active strings in WinEdt
Q. I would like to know whether there is a solution still using the original active strings "\c?}" and "\f?}"
A. No, there is no solution. As you've noticed already, when you type "}" the first ...
3
votes
Accepted
How can I use the ampersand (&) as a delineator for tabs in LaTeX3 (expl3)/xparse syntax?
You're trying to start a loop in a cell, ending it in another one. This can't work, because alignment cells form groups.
You want to use \clist_use:Nn
\documentclass[draft]{article}
\usepackage{...
3
votes
How to make hyperref work with bibitem keys containing a colon and using babel french option?
This should really be solved by hyperref, but here's a hack that seems to work (for the colon); however, the best thing, when babel-french is involved, is not to use colons in labels.
\documentclass{...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
active-characters × 47catcodes × 7
macros × 6
babel × 5
luatex × 4
expl3 × 4
characters × 4
csquotes × 4
math-mode × 3
tex-core × 3
best-practices × 2
xparse × 2
shorthands × 2
csname × 2
mathcode × 2
tables × 1
beamer × 1
spacing × 1
pdftex × 1
hyperref × 1
symbols × 1
listings × 1
citing × 1
longtable × 1
page-breaking × 1