I wanted to define my own version of a verbatim-like environment, that has some less line spacing and uses alltt
instead of verbatim
, so what I can use \(\cdots\)
inside.
What I tried was:
\newenvironment{codify}{\begin{spacing}{0.8}\begin{alltt}}{\end{alltt}\end{spacing}\noindent}
But as long as it works between paragraphs:
it causes some mess inside my (long)table. I wanted to use it inside a table cell, but it produces too much vertical space above it and below it:
And I actually tried everything I could find to get rid of that, but not breaking the out-of-a-table behavior.
It seems like every usage of an environment inside a cell produces such results? How can I make it behave like text, not adding empty lines above and below?
Edit: This is the minimal test case that reproduces the problem:
% -*- coding: utf-8 -*-
\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{setspace}
\usepackage{caption}
\usepackage{array}
\usepackage{longtable}
\usepackage{alltt}
\usepackage{multirow}
%\usepackage{polski}
\newenvironment{codify}{\noindent\begin{spacing}{0.8}\begin{alltt}}{\end{alltt}\end{spacing}\noindent\ignorespacesafterend}%
\begin{document}
This is a structure definition:
\begin{codify} node \{
id: integer,
name: string,
children: [ node, \(\cdots\) ]
\} \end{codify}
with some text directly after the structure, because it's a continuation of the last sentence.
\small
\begin{longtable}{|m{0.16\textwidth}|m{0.45\textwidth}|m{0.32\textwidth}|}
\caption[Some more stuff]{More stuff} \label{tab_conn_fb} \\
\hline
\textbf{Field} & \textbf{Descr} & \textbf{Structure} \\ \hline
\endfirsthead
\multicolumn{3}{c}{{ \tablename\ \thetable{} -- continuation}} \\
\hline
\textbf{Field} & \textbf{Descr} & \textbf{Structure} \\ \hline
\endhead
\hline \multicolumn{3}{r}{{continued on the next page}} \\
\endfoot
\hline \hline
\endlastfoot
\hline
\texttt{accounts} & The Facebook apps and pages owned by the current user. This description will take less space than the structure.
& \begin{codify}Object \{
data: [
Object \{
id: string,
category: string,
name: string
\}, \(\cdots\) ]
\} \end{codify} \\
\hline
\texttt{activities} & The activities listed on the user's profile, e.g. \textit{Towel Day} czy \textit{Janusz A. Zajdel Award} & \begin{codify}Object \{
data: [
Object \{
id: string,
category: string,
create_time: time\-stamp
\}, \(\cdots\) ]
\} \end{codify} \\
\hline
\texttt{albums} & And this description is higher than the structure. And this description is higher than the structure. And this description is higher than the structure. And this description is higher than the structure. \textbf{And touches the box} & \begin{codify}Object \{
data: [ Album, \(\cdots\) ]
\} \end{codify} \\
\hline
\end{longtable}
\normalsize
\end{document}
![...]
tag). Someone with edit privileges will add these images for you.