Text Formattingwrapping in tabbing environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

wrapping in tabbing environment

Post by juliette »

As the following code shows, the tabbing environment doesn't allow wrapping.

Code: Select all

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage{mathtools}


\begin{document}

\begin{tabbing}
        Below \= is a list that i want tabbed\\
                 \> Here I am going to write a long sentence which I would like to wrap around but will instead keep traveling to the right even after the page stops even though I want it to wrap to the next like and start from where the beginning of this stentence started, or maybe even a little bit more to the left\\
                 \> Here I am going to write a long sentence which I would like to wrap around but will instead keep traveling to the right even after the page stops even though I want it to wrap to the next like and start from where the beginning of this stentence started, or maybe even a little bit more to the left
        \end{tabbing}

\end{document}

So in order to wrap things, I have to manually add the \\ command everywhere. But in order to know where to put the \\ commands, I need to keep recompiling dozens of times to see where the end of the sentence should be.


Is there a way to get automatic word-wrapping ??

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

wrapping in tabbing environment

Post by gmedina »

Hi,

can't you just use a tabular environment instead?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

Re: wrapping in tabbing environment

Post by juliette »

Hmm, thanks for the suggestion,

It seems that could work although it would require a lot of tilde's and multicolumn's

If there's an easier way, I'd be eager to learn it!
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: wrapping in tabbing environment

Post by gmedina »

A more explicit description of your actual intent, would help us to suggest a convenient solution.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

Re: wrapping in tabbing environment

Post by juliette »

Thank you,
Well in the code above, when I compile it, both sentences starting with the word "Here" are printed on one line each. Since the page is only 8.5 inches wide, I only see a small portion of the sentence.

If the text wrapped around, each of those sentences would be 4 or 5 lines long each.

In order to make this happen, I would need to use the \\ command to cut the line short and put the rest on a new line. But it's hard to know in advance where to put those \\ commands, and it would of course me a lot nicer if the latex could calculate where to put the \\'s for me.

I am using the tabbed environment because I want the first to lines to be indented slightly, and \qquad doesn't work for indenting lines (maybe becaue I'm using revtex4).
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

wrapping in tabbing environment

Post by gmedina »

And what's the problem with something like the following:

Code: Select all

\documentclass[11pt]{revtex4}
\usepackage{lipsum}% jus to generate some text

\begin{document}

\lipsum[1]
\noindent\begin{tabular}{@{\hspace{.2\textwidth}}p{.78\textwidth}}
Here I am going to write a long sentence which I would like to wrap around but will instead keep traveling to the right even after the page stops even though I want it to wrap to the next like and start from where the beginning of this stentence started, or maybe even a little bit more to the left\\
Here I am going to write a long sentence which I would like to wrap around but will instead keep traveling to the right even after the page stops even though I want it to wrap to the next like and start from where the beginning of this stentence started, or maybe even a little bit more to the left
\end{tabular}
\lipsum[1]

\end{document}
If indentation is all that you want, you could also try defining a new environment, using a list, to produce the desired indentation.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

Re: wrapping in tabbing environment

Post by juliette »

Thank you very much gmedina,
The example really helped me understand how to use a table to solve the problem.

When you first said table, for some reason I was thinking of making the first line a multicolumn line ... clearly my brain is not working today,

but that example definitely helped.

Thank you very much!
Post Reply