Discussion:
LaTeX doesn't like \begin{Verbatim}[] in tabular environments
Steinar Bang
2003-04-27 21:38:51 UTC
Permalink
If I put <programlisting> or <screen> inside a table <entry>, I get
error messages like the one below:

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.282 \begin{Verbatim}[]

?

The reason seems to be that LaTeX doesn't like Verbatim environments
inside tabular enviroments.

The reason for the use of <screen> and <programlisting> in this case,
has been to ensure that the text has been rendered in a fixed width
font. So what I've done, is to add the following templates to my
db2latex local customization style sheet:

<xsl:template match="entry/screen">
\tt{<xsl:apply-templates/>}
</xsl:template>
<xsl:template match="entry/programlisting">
\tt{<xsl:apply-templates/>}
</xsl:template>

This will not solve the general case for <programlisting> or <screen>
inside <entry>, but it's perhaps better than having the LaTeX
processing stop?

A small table to reproduce this problem, can be found at the end of
this message.


- Steinar


---Table to make LaTeX croak
<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry><programlisting>Some fixed width text</programlisting></entry>
<entry>Some normal text</entry>
</row>
<row>
<entry><screen>More fixed width text</screen></entry>
<entry>More normal text</entry>
</row>
</tbody>
</tgroup>
</informaltable>



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
James Devenish
2003-04-27 23:30:14 UTC
Permalink
Post by Steinar Bang
If I put <programlisting> or <screen> inside a table <entry>, I get
! LaTeX Error: Something's wrong--perhaps a missing \item.
Hi, this is a paragraph-/lr- mode issue. This also arises with list
environments and our basic workaround is to force p-type or X-type
columns. I had simply not realised that Verbatim also required this
workaround. But there is an additional problem with verbatim
environments...they won't work with tabularx (which DB2LaTeX uses
in some circumstances). I'm not sure about this one... I have
implemented a workaround like the one you suggested, though.




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Steinar Bang
2003-04-29 20:08:44 UTC
Permalink
[snip!]
I'm not sure about this one... I have implemented a workaround like
the one you suggested, though.
It works well most of the time, but it doesn't seem to like #
characters in the verbatim elements:

! Illegal parameter number in definition of \***@a.
<to be read again>

l.302 {{\texttt{Some fixed# width text}
}} & {{Some normal text}} \tabularnew...

?

Here's the table that created the problem:

<informaltable>
<tgroup cols="2">
<tbody>
<row>
<entry><programlisting>Some fixed# width text</programlisting></entry>
<entry>Some normal text</entry>
</row>
<row>
<entry><screen>More fixed width text</screen></entry>
<entry>More normal text</entry>
</row>
</tbody>
</tgroup>
</informaltable>



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

Loading...