I just realized that when I use \par as a macro parameter delimiter the parameter then contains a trailing space.
MWE:
\def\test #1\par{\def\param{#1}}
\test test
\hbox{\vrule\param\vrule} % prints "|test |"
\bye
Is it a bug or standard behaviour, and if the latter, why is it so? Thx.
In reply to wipet's answer
@wipet: Thx, but I need more complex solution and I am not sure I would be able to adapt your suggestion for that.
Here is what I am doing. I have a file with a lot of macros, among others those to define and to place pictures and their descriptions, looking as follows.
% picture definition
% #1 - reference name (must be unique within a book or article, not necessarily within a volume or entire collection)
% #2 - base file name (without suffix)
% #3 - picture title
\def\picdef #1 #2 #3\par{%
\expandafter\ifx\csname picfile-#1\endcsname\relax\else
\errmessage{Picture definition duplicity: reference #1 already defined!}\fi
\expandafter\def\csname picfile-#1\endcsname{\localPath/imgs/#2}%
\expandafter\def\csname pictitle-#1\endcsname{#3\unskip}%
}
% picture description definition
% #1 - reference name
% #2 - picture description
\long\def\picdesc #1 #2\descend{%
\expandafter\ifx\csname picfile-#1\endcsname\relax
\errmessage{Define picture first before defining its description}%
\else
\expandafter\expandafter\expandafter\long\expandafter\def\csname picdesc-#1\endcsname{#2\unskip}%
\fi
}
% user macros to actually place the picture or its description
\def\obrazek #1 {%
\expandafter\ifx\csname picfile-#1\endcsname\relax
\message{Warning: unknown picture reference #1 (typo or not yet defined?)!}%
\else
\ifhmode\par\fi
\begin{figure}[t]
\centerline{\includegraphics[width=0.9\textwidth]{\csname picfile-#1\endcsname}}
\vskip 14pt
\centerline{\large \bfseries {\csname pictitle-#1\endcsname}}
\end{figure}
\fi
}
\def\obrazekPopis #1 {%
\expandafter\ifx\csname picfile-#1\endcsname\relax
\message{Warning: unknown picture reference #1 (typo or not yet defined?)!}%
\else
\ifhmode\par\fi
\csname pictitle-#1\endcsname: \csname picdesc-#1\endcsname\par
\fi
}
Then for a particular work within a volume there is a file with picture definitions like this:
\picdef
logo-s % small logo
logo_min % logo_min.pdf
Obr. 1 % Czech for Pic. 1
\picdesc logo-s
This is what a~small logo is supposed to look like.
\descend
\endinput
And finally within an actual text pictures are placed like this:
Some text
and text
\obrazek logo-s
Some other text
etc.
\obrazekPopis logo-s
And text continues on

