However, I have two problems -- a blank line appears above and below
the block.
(1)
The blank line that appears before the code block is apparently
related to this code, using xkeyval. The setup:
\define@boolkeys{code}[code@]{show}[true]{}
\presetkeys{code}{show = true,}{}
and in the newenvironment code:
\setkeys{code}{#1}\ifcode@show\verbatim\fi%
(2) The blank line that appears after the code block is apparently
related to this code. The setup:
\newlength{\gparindent}
\setlength{\gparindent}{3ex}%
and in the newenvironment code:
\renewcommand{\verbatim@startline}{\verbatim@line{\hskip\gparindent}}
%
Here is the commented minimal doc.
------------------------------------------------------
\documentclass{book}
\usepackage{verbatim,xkeyval,lipsum}
\makeatletter
\define@boolkeys{code}[code@]{show}[true]{}
\presetkeys{code}{show = true,}{}
\newcommand{\@zeroseps}{%
\setlength{\topsep}{\z@}%
\setlength{\partopsep}{\z@}%
\setlength{\parskip}{\z@}%
}
\newlength{\gparindent}
\setlength{\gparindent}{3ex}%
\newenvironment{Mycode}[1][]{%
\@zeroseps%
% comment this line to remove blank line before verbatim
\setkeys{code}{#1}\ifcode@show\verbatim\fi%
% comment this line to remove blank line after verbatim
\renewcommand{\verbatim@startline}{\verbatim@line{\hskip\gparindent}}
%
% comment or uncomment as needed depending on the setkeys line:
%\verbatim
}%
{\endverbatim}
\makeatother
\begin{document}
\lipsum[1]
\begin{Mycode}[show]
This should be indented by 3ex.
another line, further indented.
\end{Mycode}
\lipsum[1]
\end{document}
------------------------------------------------------
Why or how these two lines interact with the other code I cannot see.
Any suggestions, comments, very welcome!
thanks,
--Tim Arnold