(fancyvrb) Error when finishing environment followed by text

by Pablo González L   Last Updated September 11, 2019 18:23 PM

I'm trying to compare he different packages that support verbatim content and I noticed that there is a small, but, big difference in behavior when closing the environment followed by text (not a new line). With this example file:

\documentclass{article}%
%\usepackage{verbatim}\newenvironment{myverbatim}{\verbatim}{\endverbatim}
\usepackage{newvbtm}\newverbatim{mynewvbtm}{}{}{}{}
\usepackage{listings}\lstnewenvironment{mylistings}{\lstset{basicstyle=\ttfamily}}{}
\usepackage{fancyvrb}\DefineVerbatimEnvironment{myfancyvrb}{Verbatim}{}
\begin{document}
\noindent\hrulefill

This text is found just before opening the verbatim (default, no package) environment 
\begin{verbatim}
  default verbatim environment
\end{verbatim}This text is found just after closing verbatim environment

\noindent\hrulefill

This text is found just before opening the verbatim (with listings package) environment 
\begin{mylistings}
  verbatim with listings package
\end{mylistings}This text is found just after closing verbatim environment

\noindent\hrulefill

This text is found just before opening the verbatim environment 
\begin{mynewvbtm}
  verbatim with newvbtm package
\end{mynewvbtm}This text is found just after closing verbatim environment

\noindent\hrulefill

%This text is found just before opening the verbatim (with verbatim package) environment 
%\begin{myverbatim}
% LaTeX Warning: Characters dropped after `\end{verbatim}' on input line
%\end{myverbatim}This text is found just after closing verbatim environment
%\noindent\hrulefill

%This text is found just before opening the verbatim (with myfancyvrb package) environment 
%\begin{myfancyvrb}
%! FancyVerb Error:
%  Extraneous input `This text is found just after closing verbatim environment\
%end{}' between \end{myfancyvrb} and line end
%.
%\FV@Error ... {FancyVerb Error:
%\space \space #1
%}
%\end{myfancyvrb}This text is found just after closing verbatim environment
\end{document}

The text after \end{verbatim} is placed on the following line. If we use the {verbatim} package we get the message:

LaTeX Warning: Characters dropped after `\end{verbatim}' on input line

The text "This text is found..." is not displayed on the output, which is correct and appears in the package documentation, but with fancyvrb you only get one error:

! FancyVerb Error:
  Extraneous input `This text is found just after closing verbatim environment\
end{}' between \end{myfancyvrb} and line end
.
\FV@Error ... {FancyVerb Error:
\space \space #1
}

Is there any way to skip this error?, without having to place the text on the following line, either by placing the text on a new line or by sending a warning message (I don't know which one is the most indicated).

I don't know if it's an error in the package or if it's due to the implementation of this one. I've written an email to Herbert (I think he also belongs to this community), but, he hasn't given me an answer. Greetings



Related Questions


Updated August 23, 2017 20:23 PM

Updated July 18, 2017 07:23 AM

Updated January 04, 2018 15:23 PM

Updated September 12, 2018 15:23 PM

Updated April 12, 2015 06:09 AM