Text FormattingHanging / Tabular / Tabbing

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
BertJ
Posts: 2
Joined: Tue Jul 03, 2018 12:26 pm

Hanging / Tabular / Tabbing

Post by BertJ »

Maybe a stupid question.

If I want a typesetting like this:

Code: Select all

Some general words blah blah blah.
Date/time/text1   Let's say some general blah blah blah blah
                  that is required to explain the current date
Date/time/text2   With some other blah blah blah blah blah blah
                  and more of it
In Word there is a hanging indent, in which you can set a [tab] between 'date/time/text' and the rest, id est the 'Let's say', to have appropriate alignment of the text.

In LateX there is the possibility to do it as tabular.

Code: Select all

Some general words.
\begin{tabular}{ p{2cm}  p{10cm} }
Date/time/text1:      & Let's say some general blah blah blah blah that is required to explain the current date \\
Date/time/text2:      & With some other blah blah blah blah blah blah and more of it \\
Date/time/text3:      & Etc \\
\end{tabular}
However, the 'Date' is now not aligned with 'Some general words'.
With tabbing, I have difficulties to have the sentence wrapped at the end of the line.
With \hanging I can't find a way to appropriate alignment of the 'Let's say' and the 'With some other'.

How is this normally done?
Should I consider 'list' ?

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Hanging / Tabular / Tabbing

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

tabbing is for simple tables, tabular for better alignment. There are some options for customizing, for example @{space} inserts space as column separation space, also at the beginning. An empty space puts the first column flushed left:

Code: Select all

\documentclass{article} 
\begin{document}
Some general words.

\begin{tabular}{ @{} p{3cm}  p{10cm} }
Date/time/text1:      & Let's say some general blah blah blah blah that is required to explain the current date \\
Date/time/text2:      & With some other blah blah blah blah blah blah and more of it \\
Date/time/text3:      & Etc \\
\end{tabular}
\end{document}
Stefan
LaTeX.org admin
BertJ
Posts: 2
Joined: Tue Jul 03, 2018 12:26 pm

Hanging / Tabular / Tabbing

Post by BertJ »

Looks like a nasty trick to me ;-) but it works perfectly. Thanks!
(and thanks for the welcome.... )
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Hanging / Tabular / Tabbing

Post by Johannes_B »

Welcome, with package scrextend from the KOMA-script bundle, you could also use a labeling list. Depending on how long a description can be, this is a great alternative.

Code: Select all

\documentclass{article} 
\usepackage{scrextend}
    \begin{document}
    Some general words.
     
    \begin{tabular}{ @{} p{3cm}  p{10cm} }
    Date/time/text1:      & Let's say some general blah blah blah blah that is required to explain the current date \\
    Date/time/text2:      & With some other blah blah blah blah blah blah and more of it \\
    Date/time/text3:      & Etc \\
    \end{tabular}
\begin{labeling}{Date/time/text1:}% <- basically the longest label 
   \item[Date/time/text1:]  Let's say some general blah blah blah blah that is required to explain the current date 
   \item[Date/time/text2:]  With some other blah blah blah blah blah blah and more of it 
   \item[Date/time/text3:]  Etc 
\end{labeling}
    \end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply