General ⇒ Strange missing \endcsname inserted error
Strange missing \endcsname inserted error
Well i am having a strange error when i compile my sources and i just can't figure out why it happens.
Problem:
1) I have defined a command that prints one thing most of the time, but in case of recieving some special input it prints another. It uses the ifthenelse command.
Here it is the command that generates the error (sometimes):
\newcommand{\scenref}[1]{
\ifthenelse{\equal{#1}{scenario:unbounded2}}
{Scenario 007}
{Scenario~\ref{#1}}
}
command explanation:
when \scenref is invoked with any label different then scenario:unbounded2 it prints out the bottom line: {Scenario~\ref{#1}}
Otherwise it prints Scenario 007.
And apparently this command works fine, except:
2) When i use this command inside a caption, more pricesly in the facultative field that goes into the index, i get the error saying that and \endcsname is missing.
Here is an example:
2.1)Bugy code example:
\caption[\scenref{scenario:unbounded2} it blows here]{\scenref{scenario:unbounded2} this side here works ok}
2.2) Working code example:
\caption[Scenario~007 crappy fix]{\scenref{scenario:unbounded2} this side here works ok}
2.3) Compile error of 2.1:
[41] (section/ch4/table_scenario3_input.tex
! Missing \endcsname inserted.
<to be read again>
\let
l.26 ...unded2} input: \codett{PROFILE} instance.}
Even more, i have tries using the a standard example of the ifthenelse command instead of my own command, but it results in the same problem. Would anyone care to try to create a command that uses the ifthenelse command and see if they can get it to work inside the [] area of the \caption command?
I just can get this thing to work. And until i do, i guess i gotta work with a crappy fix.
Thanks in advance,
my best regards.
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Strange missing \endcsname inserted error
Best regards and welcome to the board
Thorsten
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Strange missing \endcsname inserted error
Code: Select all
\documentclass{article}
\usepackage{ifthen}
\newcommand{\scenref}[1]{
\ifthenelse{\equal{#1}{jondoe}}
{Johndoe}
{Not Johndoe}
}
\begin{document}
\title{Ups You Did it again}
\author{99Sono}
\maketitle
\newpage
\section{working command}
Is John Doe doe john doe? \scenref{I guess not!}
\newpage
\section{Does Caption Like The New command?}
\begin{table}[ht]
Here it works: \scenref{I guess not!}
\caption[This caption blows \scenref{I guess not!}]{So sorry!}
%\caption[This captioon does not blow:]{It works fine: \scenref{I guess not!}}
\end{table}
\end{document}
Well the only common denomitor is that the command works everywhere but in the [] field of th caption.
The cause is the same, the effect is the same, only the outputed erros has differed for some reason that escapes my understanding.
Once more, thanks in advance.
Re: Strange missing \endcsname inserted error
Cheers,
Tomek
Strange missing \endcsname inserted error
Code: Select all
\DeclareRobustCommand\scenref[1]{...}
Code: Select all
\newcommand\scenref[1]{...}
HTH,
Axel
Re: Strange missing \endcsname inserted error

Cheers mates, i do not know how you did it... but that worked out just fine.
Strange though: in my mmw the error the compiler complained about was the \equal, and in my actual document is the \endcsname. It did however solve the problem.
So ... whatever.
I'll just take it as part of the byzantine world we live in
