开发者

Latex: Vertical space before and behind the lists

I cannot get rid of the vertical space before and behind the lists. I have code like below:

\begin{list}{-}{}
    \setlength{\itemsep}{0pt}
    \setlength{\parskip}{0pt}
    开发者_如何学JAVA\setlength{\parsep}{0pt}

    \item First item
    \item Second item

\end{list}


Updated answer: now accounts for both single and multi-line list items.


One line items (simple) Itemize without itemizing...

Some text that is here and I want to see what it does. \\
  \indent$\bullet$\,first item \\
  \indent$\bullet$\,second item \\
Some text that is here and I want to see what it does.

Replace $\bullet$ with whatever you want.

\indent- first item\\
\indent$\cdot$\,first item\\
\indent$\circ$\,first item\\
\indent$\ast$\,first item\\

The "-" seems to work fine with the whitespace as shown but the rest need the trailin \, which inserts a space between the math symbol and the next word. Without it there will be no space between the "bullet" and the text that follows.


Multi-line items (just a tad more complex) Well, not much complex. Just found a reference about doing "hanging indents" which appears to make this flexible enough to do whatever you want. [1]

\documentclass{article}

\begin{document}

\newlength{\originalParindent} %see comments below
\setlength{\originalParindent}{\parindent} 

Some text that is here and I want to see what it does and to show the current
indentation behavior of a blob of text. Some text that is here and I want to
see what it does. Some text that is here and I want to see what it does. \par

\leftskip .3in % see comments below
\parindent -0.09in % see comments below

\indent$\bullet$\,first item that spills onto a second line to demonstrate the
function of leftskip and it's ability to make hanging indents. Might as well
make sure we hit three lines with this first item to be sure it works.\\

\indent$\bullet$\,second item can run onto a second line as well; hopefully
this solves the problem\par

\leftskip 0in %reset the defaults
\setlength{\parindent}{\originalParindent} %resent the defaults

Some text that is here and I want to see what it does. Just want to make sure
the defaults are restored and paragraphs indent with their proper functionality.

\end{document}

Comments

  • Parindent stuff: we're going to trick things into looking like an itemized bullet with multiple lines indented to match the first indented text. To do this we fiddle with parindent and leftskip values. Leftskip is usually zero but I don't know what parindent is set to so we save it in a variable and restore it later. Found this trick while trying to find something equivalent to \setlength{\parindent}{default}.[2]

  • leftskip: this plays with how far the overall thing is indented. If you want it further to the right, just increase the value. Zero means the bullets are flush left with the paragraphs.

  • parindent: this overrides the default behavior of making the subsequent lines aligned with the left edge of our bullet. The -0.9 value just happens to look right for compensating for the bullet and the space so that subsequent lines look like they're matched up with the first line. You can tweak this, too. For example, something like this might look better.

Bigger space between bullet and text; parindent adjusted accordingly:

\leftskip .3in % see comments below
\parindent -0.215in % see comments below

\indent$\bullet$\quad first item that spills onto a second line to demonstrate
the function of leftskip and it's ability to make hanging indents. Might as
well make sure we hit three lines with this first item to be sure it works.\\

Hope that helps! The parindent and leftskip handles should allow you to perfect what you want.


[1] http://www.wkiri.com/today/?p=76

[2] http://www.cs.cmu.edu/afs/cs/usr/bovik/database/tsf-bboard/Tex/enumerate


It is continuation of Hendy answer: Latex: Vertical space before and behind the lists

I took his notes and I prepared the following:

\newlength{\originalParindent}                                            
\newenvironment{my_itemize}
{
    \setlength{\originalParindent}{\parindent}                            
    \leftskip .3in                                                        
    \parindent -0.11in

    \newcommand{\originalItem}{\item}                                     
    \renewcommand{\item}{\indent - }                                      
}
{                                                                         
    \par

    \leftskip 0in
    \setlength{\parindent}{\originalParindent}                            
    \renewcommand{\item}{\originalParindent}                              
}   

After that I can only write:

\begin{my_itemize}

     \item Something very short

     \item Somethnig very long. Somethnig very long. Somethnig very long. Somethnig very long. Somethnig very long. Somethnig very long.

\end{my_itemize}

To get proper list wherever in my document.


Expanding on the previous answers, a variation with no bullet points at all, but instead first lines without indentation, and other lines (from 2nd line onwards) with indentation:

\newenvironment{table_itemize}
{
    \begingroup                 % Start of formatting properties

    \leftskip 0.1in             % indentation for lines except first line
    \parindent -0.1in           % first line: no indentation

    \renewcommand{\item}{}      % no bullets
}{
    % restore all formatting that we changed since begingroup
    % (e.g. leftskip, parindent)
    \endgroup
}

Then, use in the same way as already indicated in post by Kogut:

\begin{table_itemize}

    \item Something very short

    \item Something very long. Something very long. Something very long. Something very long. Something very long. Something very long.

\end{table_itemize}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜