2

I defined my self some macros for l- and L-spaces, to be specific some \l1, \L2, and so one. Now Latex throws errors while compiling, always exactly at the first \lx I defined:

! Use of \l doesn't match its definition. l.31 \item[(v)] Für $f \in \l1 $ oder $f \in \L1$ heißt $f$ \emph{summierba... If you say, e.g., \def\a1{...}', then you must always put1' after `\a', since control sequence names are made up of letters only. The macro here has not been followed by the required stuff, so I'm ignoring it.

It seems to ignore the numbers I put behind the \l or \L. I worked around it with using \lone, \Ltwo, and so on - so the matter is definitely not urgent. But I'm interested, why it behaves like that.

\documentclass{report}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsmath}

\DeclareMathOperator{\l1}{\ell^1(\mathbb{Z})}
\DeclareMathOperator{\L1}{L^1(\mathbb{R})}
\DeclareMathOperator{\l2}{\ell^2(\mathbb{Z})}
\DeclareMathOperator{\L2}{L^2(\mathbb{R})}
\DeclareMathOperator{\linf}{\ell^\infty(\mathbb{Z})}
\DeclareMathOperator{\Linf}{L^\infty(\mathbb{R})}

\begin{document}

Für $f \in \l1$ oder $f \in \L1$ heißt $f$ \emph{summierbar} oder \emph{integrierbar}.
Für $f \in \l2$ oder $f \in \L2$ heißt $f$ \emph{Signal von endlicher Energie}.
Für $f \in \linf$ oder $f \in \Linf$ heißt $f$ \emph{beschränkt}.

\end{document}
  • 1
    Welcome to TeX.SE! Control sequence names may contain only letters, except control sequence names consisting of only one character (called control symbols). This is a basic TeX rule. If there is already a letter in your control sequence name (l), what follows can be part of the name only if it's a letter. So, either you name your commands \li, \lii, etc. (using roman numbering), or you define a command that takes an argument: the figure (digit). – frougon Jul 29 '19 at 07:46
  • Thanks. Then this is solved. – thefilth Jul 29 '19 at 07:50
  • I'm defining the macro as \newcommand{\ppp}{\ensuremath{\mathfrak p}\xspace} and using it in a math environment as \ppp_i. It gives perfect results for the first few times (inside an equation environment, but suddenly shows this error when used inside $$. Is this a bug? I'm using overleaf. – Pagol Aug 03 '22 at 22:24

1 Answers1

3

You can't define macros with numbers in their name.

However, for the particular case, you can get something similar, by exploiting the fact that a one-token argument needs not to be braced. Thus \ls{1} can be typed \ls1 and the result will be the same. Beware that \ls{3/2} needs braces, of course.

\documentclass{report}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsmath}

\newcommand{\ls}[1]{\ell^{#1}(\mathbb{Z})}
\newcommand{\Ls}[1]{L^{#1}(\mathbb{R})}
\newcommand{\lsinf}{\ls{\infty}}
\newcommand{\Lsinf}{\Ls{\infty}}

\begin{document}

Für $f \in \ls1$ oder $f \in \Ls1$ heißt $f$ \emph{summierbar} oder \emph{integrierbar}.
Für $f \in \ls2$ oder $f \in \Ls2$ heißt $f$ \emph{Signal von endlicher Energie}.
Für $f \in \lsinf$ oder $f \in \Lsinf$ heißt $f$ \emph{beschränkt}.

\end{document}

Note that none of the symbols you want to define qualifies as an operator: they are just ordinary symbols.

Also, \l and \L are preempted and you should not redefine them: many Polish mathematicians were or are active in real analysis and you'd get into great troubles if trying to cite them in your documents.

enter image description here

egreg
  • 1,121,712