GeneralUsing verbatim inside tabular

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
snpagliarini
Posts: 2
Joined: Fri Sep 17, 2010 3:35 pm

Using verbatim inside tabular

Post by snpagliarini »

Hey guys,

I am trying to use verbatim inside a tabular but I am not getting the look I want. I have attached a screen-shot of the issue. It seems as verbatim is always placing blank lines before and after.

My latex source looks like this:

Code: Select all

\begin{table}
\renewcommand{\arraystretch}{1.3}
\caption{Linting checks}
\label{tab_lint}
\begin{center}
\begin{tabular}{|l|p{3cm}|p{3.5cm}|}
\hline
ID & Explanation & Example \\
\hline
RCAS & Illegal continuous assignment to a reg. &\begin{alltt}reg a;
assign a = 1;\end{alltt} \\
\hline
WPAS & Illegal procedural assignment to a wire. & \begin{verbatim}wire a;
always @(*)
a = 1;\end{verbatim}
Any ideas how to get rid of those lines?
Attachments
issue.jpg
issue.jpg (30.29 KiB) Viewed 10080 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

snpagliarini
Posts: 2
Joined: Fri Sep 17, 2010 3:35 pm

Re: Using verbatim inside tabular

Post by snpagliarini »

I replaced the verbatim environment with the \verb one. The problem is that verbatim creates a paragraph.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Using verbatim inside tabular

Post by localghost »

If the problem is solved, please be so kind and mark the topic accordingly as clearly written in the Board Rules (to be read before posting). Otherwise tell us what is missing.

Please always post a full but minimal example. Otherwise it becomes difficult to give specific help. You can also try to typeset the right column in a typewriter font as shown below.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption}
\usepackage{array}

\begin{document}
  \begin{table}[!ht]
    \renewcommand{\arraystretch}{1.3}
    \centering
    \caption{Linting checks}\label{tab_lint}
    \begin{tabular}{|l|p{3cm}|>{\ttfamily\arraybackslash}p{3.5cm}|}\hline
      ID & Explanation & \textnormal{Example} \\ \hline
      RCAS & Illegal continuous assignment to a reg. & reg a;\newline assign a = 1; \\ \hline
      WPAS & Illegal procedural assignment to a wire. & wire a;\newline always @(*)\newline a = 1; \\ \hline
    \end{tabular}
  \end{table}
\end{document}

Best regards and welcome to the board
Thorsten
Post Reply