GeneralText wrapping in tabbing and tabular environments

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
Steztric
Posts: 12
Joined: Sat Oct 25, 2008 2:00 pm

Text wrapping in tabbing and tabular environments

Post by Steztric »

Hi Community, this is my first time!

I am confused. I want to make text appear like this:

Subject 1: Text relating to subject 1 that
............ wraps to the next line at the
............ edge of the page margin
Subject 2: Text relating to subject 2 that
............ also wraps to the next line


(without the dots, but excluding them makes the text align left on the web...)

When I attempt to do this using the tabbing environment using this code;

Code: Select all

\begin{tabbing}
\hspace{4cm} \= \kill
Build the network: \> Click Module Run~$\Rightarrow$ SATNET~$\Rightarrow$ Network Data File~$\Rightarrow$ NOCHARGE.DAT~$\Rightarrow$ Open~$\Rightarrow$ Run\\
Build the trip matrix: \> Click Module Run~$\Rightarrow$ Building~$\Rightarrow$ MXM1~$\Rightarrow$ Matrix Data File~$\Rightarrow$ TRIPS.DAT~$\Rightarrow$ Run\\
\end{tabbing}
The columns are tabulated correctly, but it doesn't wrap the text in the second column. It in fact runs off the edge of the page!

How do I get it to wrap at the edge of the standard page's margin?

Thanks in advance!

Steve

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Text wrapping in tabbing and tabular environments

Post by localghost »

The tabbing environment is not the right one for this purpose. Take a new defined list environment.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[centering,includeheadfoot,margin=2cm]{geometry}
\usepackage{txfonts}
\parindent0em

\newenvironment{xlist}[1][\rule{3em}{0em}]{%
  \begin{list}{}{%
    \settowidth{\labelwidth}{#1:}
    \setlength{\labelsep}{0.5cm}
    \setlength{\leftmargin}{\labelwidth}
    \addtolength{\leftmargin}{\labelsep}
    \setlength{\rightmargin}{0pt}
    \setlength{\parsep}{0.5ex plus 0.2ex minus 0.1ex}
    \setlength{\itemsep}{0 ex plus 0.2ex}
    \renewcommand{\makelabel}[1]{##1:\hfil}
    }
  }
{\end{list}}

\begin{document}
  \begin{xlist}[\rule{10em}{0em}]
    \item[Build the network] Click Module Run~$\Rightarrow$ SATNET~$\Rightarrow$ Network Data File~$\Rightarrow$ NOCHARGE.DAT~$\Rightarrow$ Open~$\Rightarrow$ Run
    \item[Build the trip matrix] Click Module Run~$\Rightarrow$ Building~$\Rightarrow$ MXM1~$\Rightarrow$ Matrix Data File~$\Rightarrow$ TRIPS.DAT~$\Rightarrow$ Run
  \end{xlist}
\end{document}
Note that the new xlist environment has an optional argument to set the width for the item text.


Best regards and welcome to the board
Thorsten¹
User avatar
Steztric
Posts: 12
Joined: Sat Oct 25, 2008 2:00 pm

Text wrapping in tabbing and tabular environments

Post by Steztric »

Thanks Thorsten, that does the trick perfectly!

The code to do that is quite complicated though. I found a more elegant way of doing it using the eqlist environment, which is specifically designed for exactly this purpose;

Code: Select all

\begin{eqlist}[\def\makelabel#1{#1:}\labelsep1em]
  \item[Build the network] Click Module Run~$\Rightarrow$ SATNET~$\Rightarrow$ Network Data File~$\Rightarrow$ NOCHARGE.DAT~$\Rightarrow$ Open~$\Rightarrow$ Run
  \item[Build the trip matrix] Click Module Run~$\Rightarrow$ Building~$\Rightarrow$ MXM1~$\Rightarrow$ Matrix Data File~$\Rightarrow$ TRIPS.DAT~$\Rightarrow$ Run
\end{eqlist}
This package also allows me to format the labels however I want, set the spacing from the labels to the text however I want, and all sorts.

I hope this helps anyone else with this query.

Thanks,

Steve
Post Reply