3

I am trying to associate sequence of characters that can contain special symbols (accents, dollars, and in particular inputs in utf8) to some content. This is to be used with htlatex. Accents yield problems as shown in the following example:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{document} 
\expandafter\def\csname è\endcsname{an acentuated token}
\end{document}

This compiles fine with pdftex, but using htlatex, I obtain:

! Missing \endcsname inserted.
<to be read again> 
                   \protect 
l.6 \expandafter\def\csname è
                              \endcsname{an accentuated token}
? 

I was not able to figure out where was the problem with htlatex (indeed \IeC has a different definition, but simply correcting it does not suffice).

I would also understand answers like `you should not even think about constructing token with weird symbols'. But then, what ways are available for maintaining tables that with such kind of entries?

1 Answers1

4

The fact that it works with pdflatex is completely incidental. If you use

\csname è\endcsname

in a context where \protect is \@unexpandable@protect (for instance, when writing a section title in the .toc file), you'd get the same error

! Missing \endcsname inserted.
<to be read again> 
                   \IeC 
l.11 \csname è
               \endcsname

Not with \protect, but the concept is the same.

What you're defining with

\expandafter\def\csname è\endcsname{an acentuated token}

is the token \^^e8, but you surely can't use instead of \csname è\endcsname.

Don't use accented characters in the context of \csname under any circumstance.

You might use

\expandafter\def\csname\detokenize{è}\endcsname{an acentuated token}

but the usefulness of this is very dubious.

egreg
  • 1,121,712
  • Thank you for this answer which helps me a lot.

    The purpose would be, for instance, to be able to use \label with accents, or more precisely in htlatex to obtain a command like:

    Given a \implicitref{field}, etc...
    
    

    In an `hypertext' context, such a reference would at the same type (a) typeset "field", and (b) link to some definition of "field" known from somewhere else. Of course, this would have to be compatible with special characters.

    But maybe, there are already packages performing such a thing ?

    – Thomas Colcombet Aug 08 '14 at 20:19
  • @TTC Avoid accented characters in labels. – egreg Aug 08 '14 at 20:22