This MWE gives an error when % is at the end the line as show below
\documentclass[11pt]{article}%
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{Xsmall}{Verbatim}{fontsize=\small}
\begin{document}
\begin{Xsmall}
test
\end{Xsmall}% ------> This causes the error
\end{document}
Then pdflatex gives
) (/usr/local/texlive/2015/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty
Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix
<2008/02/07> (tvz)
(/usr/local/texlive/2015/texmf-dist/tex/latex/graphics/keyval.sty)) (./foo.aux)
! FancyVerb Error:
Extraneous input `%\end{}' between \end{Xsmall} and line end
.
\FV@Error ... {FancyVerb Error:
\space \space #1
}
l.11 \end{Xsmall}%
Of course the solution is not to put % there. But life is not that simple. I use another software to help me generate these tex file. And this software keeps adding this % there each time. If I remove it, and reload the tex file again into it, it will add this % again.
My question is, is there something I can change in the definition of the Xsmall above, such that adding this % do not cause a problem compiling it? Some kind of a trick or option or macro?
Again, I have to use this other software (it is Scientific word) but I also need to use this macro and be able to compile my file using tex live. There is no way to tell SW not to keep adding % at end of lines like this. I tried. It just keeps adding % each time.
Here is file list
article.cls 2014/09/29 v1.4h Standard LaTeX document class
size11.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
fancybox.sty 2010/05/15 1.4
fancyvrb.sty 2008/02/07
keyval.sty 2014/10/28 v1.15 key=value parser (DPC)
TL 2015 on Linux.
search-replacefunction withsed(or any other programs available in your system) before each compilation to remove the%from the document. I tried this on my terminal:sed -i 's/end{Xsmall}\%/end{Xsmall}/g' <file> | pdflatex <file>– Sunilkumar KS Nov 27 '15 at 07:04%in that position”. Sorry. – egreg Nov 27 '15 at 10:05