\preto{\@verbatim}{\topsep=0pt \partopsep=0pt}

    \vspace{-6pt} % NOTE!
lines within verbatim 
environment. Let's add
some more lines
    \vspace{-\baselineskip} % NOTE!
    ordinary lines out of
    verbatim environment 

\noindent Before verbatim
After verbatim



enter image description here

I looked for a solution that removes spaces before and after verbatim. Yes I found it (see line \preto) but, as you can see from the example above, it will not work in tabular's cell if I remove \vspaces. I empirically "hacked" the right values but I would like to understand what do I wrong. I want to use \verbatim just as is and see no odd leading spaces before or after in case of table cells.

  • To make the MWE compilable, the array, etoolbox and lipsum packages are missing. – leandriis Apr 1 '20 at 10:23
  • The new V type column defined by egreg in an answer to a previous question should also work in your case. – leandriis Apr 1 '20 at 10:26
  • I don't want to shift/affect all the column by defining some new type. Why couldn't it be solved just by affecting verbatim? – Timur Fayzrakhmanov Apr 1 '20 at 12:52
  • You can use \verb instead. No extra lines there. – John Kormylo Apr 1 '20 at 13:33
  • verb|something| doesn't allow line breaks. – Timur Fayzrakhmanov Apr 1 '20 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.