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{\@...
user avatar
16 votes
Accepted

How to deactivate % as special character?

You can make % punctuation character by \catcode`\%=12
user avatar
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 ...
user avatar
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 ...
user avatar
  • 243k
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 "...
user avatar
  • 439k
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 ...
user avatar
  • 993k
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 \...
user avatar
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}...
user avatar
  • 993k
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* ...
user avatar
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, ...
user avatar
  • 243k
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 ...
user avatar
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. ...
user avatar
  • 439k
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 993k
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, ...
user avatar
  • 993k
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{...
user avatar
  • 993k
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 (...
user avatar
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 ...
user avatar
  • 993k
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 ...
user avatar
  • 73.3k
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 993k
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{\...
user avatar
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 ...
user avatar
  • 993k
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]{...
user avatar
  • 23.5k
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{}{ \...
user avatar
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 ...
user avatar
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{...
user avatar
  • 993k
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{...
user avatar
  • 993k

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