I'm trying to define a new single-character LaTeX command (to insert a 1 pt space with \kern1pt) and want to use one of the characters obtained through the AltGr key on a US International keyboard layout. I've chosen the Unicode U+00A6 '¦', aka 'Broken Bar' character. This is my preamble
\documentclass[11pt,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{babel}
and this is my newcommand definition
\expandafter\newcommand\csname u8:\detokenize{¦}\endcsname{\kern1pt}
and the error I get:
! LaTeX Error: Command \u8:¦ already defined.
. Or name \end... illegal, see p.192 of the manual.
So, trying to understand what is going on, I replaced '¦' with '∙', the Unicode U+2219 'Bullet Operator' character. I first made sure that LaTeX complained, in insertions in normal text, as loudly with '∙' as it does with '¦', (it does) and then changed my newcommand definition thus:
\expandafter\newcommand\csname u8:\detokenize{∙}\endcsname{\kern1pt}
This time I got no errors, so I proceeded to use my new macro
a\∙b
and got this error:
! Undefined control sequence.
l.530 a\Ô
. êÖb
Trying to fix that, I added this to my preamble,
\DeclareUnicodeCharacter{2219}{\textsurd} % Recognise `∙' character in input
and got this error instead:
! LaTeX Error: Command \u8:ÔêÖ already defined.
. Or name \end... illegal, see p.192 of the manual.
Can someone please save me hours sifting through the newunicodechar package manual? (And I remind that it's a '¦', not '∙' that I need to use.)
Best Answer
There are a couple of problems:
There is already an action defined for
¦
, precisely\IeC{\textbrokenbar}
, which is kind of expected; thus\newcommand
will give you the error.If you do
you're not defining the macro
\∙
, but a meaning for the Unicode character∙
. Since∙
is represented in UTF-8 by the tripleE2 88 99
, TeX will see\^^e2
and the error message uses some representation of the three bytes.With
newunicodechar
you don't have to do anything special:The output is
and the log file will report
which would be
if the
verbose
option is used (\usepackage[verbose]{newunicodechar}
).Here's the relevant part from the documentation of
newunicodechar
.