2

What I mean with markdown like syntax, is for example using *...* or **...** instead of \emph{...} or \(...\) or \begin{blabla}...\end{blabla}.

It seems to be possible to use this "markdown" kind of syntax in latex:

\catcode`\*=\active
\def*#1*{\emph{#1}}

There are many subjectives reasons why one may prefer the one or the other. One may argue that *...* is more readable, someone else may find \emph{...} better readable. One may say it is more clear what is the beginning and what is the end with LaTex syntax, the other may say that you must blind if you don't understand what is the beginning and the end with *...*.

I would like to understand if there are any objective reasons to not use these "markdown like" commands in LaTeX ? I thought that LaTeX may be not really designed to process those kind of commands that doesn't have a clear beginning and end and therefore may cause errors ? Or is it totally fine to use this kind of syntax ?

Another question is, could I somehow define `...` in LaTeX ? I tried:

\catcode`\`=\active
\def`#1`{\emph{#1}}

But this doesn't work.

  • 1
    Related question: tex.stackexchange.com/questions/101717/… – Torbjørn T. Nov 13 '13 at 23:12
  • This code seems to go wrong with this kind of syntax: This goes *wrong*: $a^*=b^*$ – Kasper Nov 13 '13 at 23:31
  • @Kasper $a^\emph{=b^}$ would also go wrong... – user4686 Nov 14 '13 at 10:07
  • 1
    @ChrisH ...because e.g. all star variants of commands will not work, which has no easy workaround whereas $a^{\string*}$ works. – user4686 Nov 14 '13 at 10:14
  • 1
    @ChrisH :-) no no I never ever thought about the * as complex conjugate, I was speechless from realizing that. I just looked at the code with * now active, so for me the reason it does not work is about the same as the reason it would not have worked with \emph. – user4686 Nov 14 '13 at 10:18
1

I suggest you write markdown syntax, and then pre-process your text in pandoc. Alternatively, you may use a text editor (Emacs, Vim) where you can redefine the keyboard and use short-cuts to write LaTeX-markup.

0

Regarding your second question, it does work:

\documentclass{article}
\begin{document}
\catcode`\`=\active
\def`#1`{\emph{#1}}
`abc`
\end{document}

actives

But this has consequences: verbatim will not work, because the left tick is not in the list of sanitized characters. The same for *. They will remain active also in verbatim environment. Both are sanitized by \nfss@catcodes, though.

And , regarding specifically *, making it active will break all star-variants such as \section* etc...

Babel has a mechanism for making things active and it must patch many commands of the kernel such as the \label+\ref system. However it doesn't pay attention to the possibility of math active characters.

It is surely possible nevertheless to do simple things (I have experienced this in a document where @ is active for circa 120 pages) but it is impossible to ensure world-wide compatibility. Any macro from a package using \scantokens will most certainly be surprised if @ is active.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.