Ignore empty environment

tomprice's picture

The following code ignores an empty IDBsource environment as long as there is not extra line between the begin and end commands. However, the SWP Item Tag I created always includes a blank line:
\begin{source}

\end{source}
Does anyone see a way around this? My existing code follows.
\newenvironment{IDBSource}{\@ifnextchar\end{\relax}{\IDBSformat}}{}
\def\IDBSformat{\noindent\footnotesize\textit{Source: }}%
\def\IDBSourceCont{%
\ifx\@tmptok\end\let\idb@next\relax\else
\ifx\@tmptok\space\let\idb@next\relax\else
\let\idb@next\IDBSformat\fi\fi
\idb@next}

texab's picture

Try to end the first two

Try to end the first two lines with a %

tomprice's picture

Thanks for the suggestion.

Thanks for the suggestion. The editor uses a cst file to control the environment, which, I think, adds the extra line. I do not see a way to add a %. I added some code below.
\newenvironment{IDBSource}{\@ifnextchar\end{\relax}{\IDBSformat}}{}
\def\IDBSformat{\noindent\footnotesize\textit{Source: }}%
\def\IDBSourceCont{%
\ifx\@tmptok\end\let\idb@next\relax\else
\ifx\@tmptok\space\let\idb@next\relax\else
\let\idb@next\IDBSformat\fi\fi
\idb@next}

The following code is part of the cst file.
[FILTER]
\newenvironment{error}{}{}
\newenvironment{proof}{}{}
\newenvironment{IDBSource}{}{}

texab's picture

Try to get a as small example

Try to get a as small example as possible and put a \tracingall (in a tex-field)just before. Then look at the log file (it will be very verbose). If you can not figure out was is wrong send the logfile to me and I will give it a try.

Mikael

tomprice's picture

Thank you. I set up a

Thank you. I set up a self-contained MWE (attached) as you suggested but I could not determine what is causing the problem.

texab's picture

When compiling your example I

When compiling your example I got something like Price and Story misaligned. This has to do with \and which is defined in latex.ltx as
\def\and{% % \begin{tabular}
\end{tabular}%
\hskip 1em \@plus.17fil%
\begin{tabular}[t]{c}}% % \end{tabular}

If you put a % before \hskip 1em \@plus.17fil% then they will align.
So the remedy is to put the code
\def\and{% % \begin{tabular}
\end{tabular}%
% \hskip 1em \@plus.17fil%
\begin{tabular}[t]{c}}% % \end{tabular}

Just before your \makeatother. If I understood you correctly then all is OK. If not we can continue at a higher level of understanding.

tomprice's picture

Thank you, again! The

Thank you, again! The modification works well except (I should have mentioned this was a problem) the authors align but are not side-by-side:
Price
Story
As opposed to
Price Story
They should be side-by-side until forced by the text width to begin a new line.

texab's picture

Why do you not write Author:

Why do you not write
Author: gname1 fname1, gname2 fname2 ?
Instead of
Author: gname1 fname1
Author: gname2 fname2
You can in this case also set
\let\and\relax (instead of previous suggestion)

There is something I do not understand about your wish. Can you give a simple example?

tomprice's picture

Thanks for your help! I am

Thanks for your help! I am using Author: gname1 fname1, gname2 fname2 now to avoid the problem. However, the
Author: gname1 fname1
Author: gname2 fname2
approach works better when I include addresses.

The code allows me to format a table's source within its width. See the attached straight LaTeX file.