I'd like to modify a piece of code, namely Friedhelm Sowa's picinpar.sty.
There is the command
\figwindow[#1,#2,#3,#4]
which inserts a picture (#3) #1 lines below the start of a paragraph at position #2 with caption #4
In the picinpar.sty file this command is defined as
\long\def\figwindow[#1,#2,#3,#4] {%
\advance\c@figure -1
\begin{window}[#1,#2,{#3},{\def\@captype{figure}%
\wincaption#4\par}] %
}
I do not explore here further, what the window-environment is about, it is irrelevant for my question. What I'd like to achieve is an option that no caption is printed. That works well, if I rewrite figwindow as
\long\def\figwindow[#1,#2,#3,#4] {%
\advance\c@figure -1
\begin{window}[#1,#2,{#3},{}]%
}
My idea was now to use a conditional that prints no caption if #4 is {} and prints a caption otherwise. My attempt was:
\long\def\figwindow[#1,#2,#3,#4] {%
\advance\c@figure -1
\begin{window}[#1,#2,{#3},\if #4{} {} \else {\def\@captype{figure}%
\wincaption#4\par}\fi]
}
Which unfortunately does not work. It ends up in the else-branch, if I call
\figwindow[#1,#2,#3,{}]
or \figwindow[#1,#2,#3,]
However modifying the style to comparing to a '*' instead to an empty token works perfectly:
\long\def\figwindow[#1,#2,#3,#4] {%
\advance\c@figure -1
\begin{window}[#1,#2,{#3},\if #4* {} \else {\def\@captype{figure}%
\wincaption#4\par}\fi]
}
\figwindow[#1,#2,#3,*]
Although I have a working solution, I'd prefer to make the {} one work (it appears more intuitive to me Surprisingly
\newcommand{\Compare}[2]{#1 \if #2{} EMPTY \else --- #2 ---\fi\par}
\Compare{EMPTY}{}
\Compare{FILLED}{HOW?}
works as I'd expect its output is
EMPTY - EMPTY -
FILLED - HOW? -
Any suggestions? Thank you in advance right now
{}then\ifx\relax#4\relax– David Carlisle Sep 11 '22 at 07:45\if\relax\detokenize{#4}\relax(now only a really empty argument results in true). – Skillmon Sep 11 '22 at 07:55