
Quero incluir um itemize
-list dentro de um table
-environment, de forma compacta para economizar espaço. No entanto, há uma grande lacuna acima da lista quando na tabela, mas não depois de um parágrafo no 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 você pode ver, testei tanto o pacote compactitem
from paralist
quanto itemize
o from enumitem
with its options [noitemsep,topsep=0pt]
. Eles produzem alturas ligeiramente diferentes. Isso funciona entre parágrafos normais, mas na tabela não.Eu gostaria que o "ponto1" estivesse no mesmo nível do "M1".
Este, com um leve recuo que fica visível quando há uma quebra de linha (a palavra "Ativos" começa um pouco mais à direita que a palavra "durante"), é o resultado de
\begin{minipage}[t]{\hsize}\begin{compactitem}
\item Assets can be \textbf{difficult to value} during periods of hyperinflation
\end{compactitem}\end{minipage}
Comparando as duas soluções propostas:O MWE a seguir compara as duas soluções diretamente, definindo novos ambientes, respectivamente, nomeados compactitemt
e 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}
Responder1
- Se você usar o
compactitem
ambiente, precisará incluí-lo nas instruções\begin{minipage}[t]{\hsize}
and .\end{minipage}
Se você usar um
itemize
ambiente junto com oenumitem
pacote, poderá adicionar as instruçõesbefore={\begin{minipage}[t]{\hsize}}, after ={\end{minipage}}
para a lista de opções que acompanham
\begin{itemize}
.
\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}
Responder2
Para o espaço acima, basta fazer o LaTeX acreditar que a célula é uma minipágina. Para isso, peguei emprestado um \compress
comando encontrado em resposta a uma pergunta neste site. Para o espaço abaixo, você deve adicionar um \baselineskip negativo no 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}