Eliminar espacio encima de la lista `itemize` dentro del entorno de la tabla

Eliminar espacio encima de la lista `itemize` dentro del entorno de la tabla

Quiero incluir una itemizelista dentro de un tableentorno, de forma compacta para ahorrar espacio. Sin embargo, hay un gran espacio encima de la lista cuando está en la tabla, pero no después de un párrafo en texto normal:

\documentclass[12pt]{scrbook}
%\usepackage[autooneside=false, headsepline, plainheadsepline, automark]{scrlayer-scrpage}
\linespread{1}
\usepackage{paralist}
\usepackage{enumitem} % enumerate?
\usepackage{tabularx}

\begin{document}
some text
\begin{compactitem}  \item  point1  \item point2 \end{compactitem}
\begin{table}[ht!]
    \setlength{\leftmargini}{7pt}
    \begin{tabularx}{\linewidth}{l | X | X }\hline \hline
        & ECB& FED\\ \hline
    M1 & \begin{itemize}[noitemsep,topsep=0pt]   \item  point1  \item point2 \end{itemize} 
      & \begin{compactitem}  \item  point1  \item point2   \end{compactitem}
    \end{tabularx}
\end{table}

\end{document}

Como puede ver, probé tanto el paquete compactitemfrom paralistcomo itemizeel from enumitemcon sus opciones [noitemsep,topsep=0pt]. Producen alturas ligeramente diferentes. Esto funciona entre párrafos normales, pero en la tabla no.Me gustaría que el "punto1" estuviera al mismo nivel que el "M1".

ingrese la descripción de la imagen aquí


Éste, con una ligera sangría que se ve cuando hay un salto de línea (la palabra "Activos" comienza un poco más a la derecha que la palabra "durante"), es el resultado de

\begin{minipage}[t]{\hsize}\begin{compactitem}
 \item Assets can be \textbf{difficult to value} during periods of hyperinflation
\end{compactitem}\end{minipage}

ingrese la descripción de la imagen aquí


Comparando las dos soluciones propuestas:El siguiente MWE compara las dos soluciones directamente, definiendo nuevos entornos, respectivamente, denominados compactitemty compactitemm.

\documentclass%[12pt,abstracton,titlepage,parskip=false, no, no,twoside=true,open=right]
{scrbook}
%\usepackage[autooneside=false, headsepline, plainheadsepline, automark]{scrlayer-scrpage}

%\usepackage{listings}
\usepackage{paralist}
%\usepackage{newtxtext}%antpolt mathpazo %\usepackage{mathptmx} %\usepackage{newtxtext} 
\usepackage{enumitem} % enumerate?
\newenvironment{compactitemm}{\begin{minipage}[t]{\hsize}\begin{compactitem}}{\end{compactitem}\end{minipage}} %this solution requires enumitem package
\newenvironment{compactitemt}{\begin{itemize}[nosep, wide=0pt,
  %left=0pt %for neat, wide=0pt %for flush left to save space
  before={\begin{minipage}[t]{\hsize}},
  after ={\end{minipage}} ]   }{ \end{itemize} }
\renewcommand{\familydefault}{\sfdefault}

\usepackage{tabularx}

\begin{document}

\begin{table}
\setlength{\leftmargini}{7pt} %this impacts the left margin of itemize package, i.e. ``stuff 2'' in table. 7pt aligns with the other solution. 
\begin{tabularx}{\linewidth}{X | X }\hline
\multicolumn{2}{c}{stuff 1}\\ \hline
\begin{compactitemt}
  \item x This line should break and we see where the next begins
  \item y
  \item z
\end{compactitemt}
& \begin{compactitemt}
  \item a This line should break and we see where the next begins
  \item b
\end{compactitemt}\\ \hline 
\multicolumn{2}{c}{stuff 2}\\ \hline
\begin{compactitemm}
  \item x This line should break and we see where the next begins
  \item y
  \item z This line should break and we see where the next begins
\end{compactitemm}
& \begin{compactitemm}
  \item a This line should break and we see where the next begins
  \item b
\end{compactitemm}\\ \hline 
\end{tabularx}
\caption{MWE}
\end{table}

\end{document}

ingrese la descripción de la imagen aquí

Respuesta1

  • Si utiliza el compactitementorno, debe incluirlo en declaraciones \begin{minipage}[t]{\hsize}y .\end{minipage}
  • Si usa un itemizeentorno junto con el enumitempaquete, puede agregar las declaraciones

    before={\begin{minipage}[t]{\hsize}},
    after ={\end{minipage}}
    

    a la lista de opciones que van con \begin{itemize}.

ingrese la descripción de la imagen aquí

\documentclass[12pt]{scrbook}
\usepackage{paralist,enumitem,tabularx}
\begin{document}

\begin{table}[ht!]
    \setlength\extrarowheight{2pt} % optional, for a slighly more open "look"
    \setlength{\leftmargini}{7pt}
    \begin{tabularx}{\linewidth}{l | X | X }
    \hline \hline
       & ECB & FED\\ 
    \hline
    M1 & \begin{itemize}[nosep, left=0pt,
                         before={\begin{minipage}[t]{\hsize}},
                         after ={\end{minipage}} ]   
         \item point1  
         \item point2 
         \end{itemize} 
       & \begin{minipage}[t]{\hsize}
         \begin{compactitem}  
         \item point1  
         \item point2   
         \end{compactitem}
         \end{minipage}\\
    \hline
    \end{tabularx}
\end{table}

\end{document}

Respuesta2

Para el espacio de arriba, basta con hacerle creer a LaTeX que la celda es una minipágina. Para ello, tomé prestado un \compresscomando que se encuentra en una respuesta a una pregunta en este sitio. Para el espacio siguiente, debe agregar un \baselineskip negativo al final.

\documentclass[12pt]{scrbook}
%\usepackage[autooneside=false, headsepline, plainheadsepline, automark]{scrlayer-scrpage}
\linespread{1}
\usepackage{paralist}
\usepackage{enumitem} % enumerate?
\usepackage{tabularx}
\makeatletter
\newcommand{\compress}{\@minipagetrue}
\makeatother

\begin{document}
some text
\begin{compactitem} \item point1 \item point2 \end{compactitem}
\begin{table}[ht!]
    \setlength{\leftmargini}{7pt}
    \begin{tabularx}{\linewidth}{l | >{\compress}X |>{\compress} X }\hline \hline
        & ECB& FED\\ \hline
    M1 & \begin{itemize}[nosep, after=\vspace{-\baselineskip}] \item point1 \item point2 \end{itemize}\\
\hline
    & & \begin{compactitem} \item point1 \item point2 \end{compactitem}\leavevmode\vspace*{-\baselineskip}
       \\
\hline
    \end{tabularx}
\end{table}

\end{document} 

Para eso, tomé prestado un comando `` \copress` y encontré un

información relacionada