如何消除两个项目之间的差距

如何消除两个项目之间的差距

早上好

我有一张表格(longtable),其中有两列。在第二列中我使用工具itemize。当我这样做时,行与行之间会有间隙,但我不想有任何间隙,如下图所示。

感谢帮助。

\documentclass[10pt,a6paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[main=english,slovak]{babel}
\usepackage[cm]{fullpage}
\usepackage[a6paper, top=10mm, left=10mm, right=10mm, bottom=10mm,foot=5mm,marginparsep=0mm,showframe]{geometry}
%showframe
\usepackage{tipa}
\usepackage{tabularx,booktabs}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{array}
\usepackage{color}
\usepackage[dvipsnames]{xcolor}
\usepackage{longtable}
\usepackage{lscape}

\usepackage{enumitem}
\usepackage{tabularx,booktabs}
\usepackage{enumitem}
\usepackage{mathtools}
\pagenumbering{alph}
\pagenumbering{Roman}

\usepackage{ textcomp }
\usepackage{ marvosym }
\usepackage{fontawesome}
\usepackage{tfrupee}
\usepackage{stackengine}
\def\yenrule{\rule{1.3ex}{.1ex}}
\def\textyen{\renewcommand\stacktype{L}\stackon[.4ex]{\stackon[.65ex]{Y}{\yenrule}}{\yenrule}}
\usepackage{textcomp}

\begin{document}
\catcode`\-=12
\sloppy

{\small\setlist[itemize]{nosep , label=--, wide = 0pt, labelsep=.25em, leftmargin=*}
\begin{longtable}{p{3cm}p{3cm}}
  \toprule
  sometext      & \setlist{nosep,topsep=0sp,label=--} \vspace{-\baselineskip}
                  \begin{itemize}
                    \item[-] some long text 
                  \end{itemize}\\   
  sometext      & \setlist{nosep,topsep=0sp,label=--} \vspace{-\baselineskip}
                  \begin{itemize}
                    \item[-] some long text
                  \end{itemize}\\
  sometext      & \setlist{nosep,topsep=0sp,label=--} \vspace{-\baselineskip}
                  \begin{itemize}
                    \item[-] some long text
                  \end{itemize}\\                 
  sometext      & \setlist{nosep,topsep=0sp,label=--} \vspace{-\baselineskip}
                  \begin{itemize}
                    \item[-] some long text
                  \end{itemize}\\                 
  \toprule
\end{longtable}}

\end{document}

在此处输入图片描述

答案1

像这样?

在此处输入图片描述

摘自回答问题

\documentclass[10pt,a6paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[main=english,slovak]{babel}
\usepackage[cm]{fullpage}
\usepackage[a6paper, 
            margin=10mm,foot=5mm,marginparsep=0mm,
            showframe]{geometry}

    \usepackage{booktabs,longtable,makecell}
\renewcommand\theadfont{\bfseries\sffamily}
    \usepackage{ragged2e}

    \usepackage{enumitem}% for nice list
\newcommand{\tablistcommand}{% <-- for eliminating vertical space
                             %     before and after itemize
            \leavevmode\par\vspace{-\baselineskip}
                            }
\newlist{tableitems}{itemize}{1}% <-- defined new list
\setlist[tableitems]{nosep,     % <-- new list setup
                     topsep     = 0pt               ,
                     partopsep  = 0pt               ,
                     leftmargin = *                 ,
                     label      = -                 ,
                     before     = \tablistcommand   ,
                     after      = \tablistcommand
                     }

\begin{document}
%\catcode`\-=12
%\sloppy

\begin{longtable}{p{3cm}p{3cm}}
  \toprule
  sometext      & \begin{tableitems}
                    \item   some long text
                  \end{tableitems}         \\
  sometext      & \begin{tableitems}
                    \item   some long text
                  \end{tableitems}         \\
  sometext      & \begin{tableitems}
                    \item   first item in some long text
                    \item   second item in some long text
                    \item   thirs item in some long text
                  \end{tableitems}         \\
  sometext      & \begin{tableitems}
                    \item   some long text
                  \end{tableitems}\\
  \bottomrule
\end{longtable}

\end{document}

在上面的 MWE 中,我省略了 MWE 中所有不相关的包。

答案2

另一种方法是根本不使用 itemize,而是定义一个命令来为您完成这项工作。

lubomirLongtable条目

\documentclass[10pt,
    dvipsnames,
%a6paper% still unused
]{book}
\usepackage[utf8]{inputenc}
\usepackage[main=english,slovak]{babel}
\usepackage[a6paper, top=10mm, left=10mm, right=10mm, bottom=10mm,foot=5mm,marginparsep=0mm,showframe]{geometry}
%showframe
\usepackage{xcolor}% Load the package without any options.
\usepackage{booktabs}
\usepackage{longtable}
\pagenumbering{alph}
\pagenumbering{Roman}% does ist make sense to change the numbering of pages in the preamble, two times in a row? 



\newcommand{\blindtext}{This is a text that does not contain Ducks, nor Wombats}

\newcommand{\tabitem}[1]{--~\parbox[t]{.9\linewidth}{\small\raggedright#1\par}\vspace{2ex}}
\begin{document}
\catcode`\-=12
\sloppy

{\small
\begin{longtable}{p{3cm}p{3cm}}
    \toprule
    sometext      &  \tabitem{\blindtext} \\
    sometext      &  \tabitem{\blindtext} \\
    sometext      &  \tabitem{\blindtext} \\
    sometext      &  \tabitem{\blindtext} \\
    \bottomrule
\end{longtable}}

\end{document}

相关内容