tcolorbox 中相同枚举的不同间距

tcolorbox 中相同枚举的不同间距

在 MWE 中:

\documentclass{article}
\usepackage[a4paper, portrait, margin=1in, top=.25in, bottom=1.75in]{geometry}
\usepackage{%
  fontspec,
  parskip,
  lastpage,
  booktabs,
  polyglossia,
  graphicx, 
  fancyhdr,
  lato
}

\usepackage[many]{tcolorbox}

\usepackage[shortlabels]{enumitem}

\setmainfont{Lato}

\usepackage{hyperref}

\setlength{\headheight}{1.15in}
\setlength{\headsep}{.15in}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\lhead{\footnotesize{Hello\\Hello }}
\rhead{}
\rfoot{}
\pagestyle{fancy}

\setcounter{secnumdepth}{-1}

\begin{document}
  \begin{center}
      \begin{tcolorbox}[enhanced jigsaw,opacityback=0,sharp corners]
        \begin{enumerate}
          \item This is 1
          \item This is 2
        \end{enumerate}
      \end{tcolorbox}
  \end{center}
    \begin{enumerate}
      \item This is 1
      \item This is 2
    \end{enumerate}

\end{document}

tcolorbox 内外项目之间的枚举间距不同。

如何使 tcolorbox 中的间距与 tcolorbox 之外的间距相同(项目之间的默认间距)?

答案1

您正在使用 parskip 包,但 tcolorbox 在内部使用 minipage 来重置 parskip。如果您希望将框外的间距作为间距,则可以使用以下选项避免更改内部间距parbox=false

\documentclass{article}
\usepackage[a4paper, portrait, margin=1in, top=.25in, bottom=1.75in]{geometry}
\usepackage{%
  fontspec,
  parskip,
  lastpage,
  booktabs,
  polyglossia,
  graphicx,
  fancyhdr,
  lato
}

\usepackage[many]{tcolorbox}

\usepackage[shortlabels]{enumitem}

\setmainfont{Lato}

\usepackage{hyperref}

\setlength{\headheight}{1.15in}
\setlength{\headsep}{.15in}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\lhead{\footnotesize{Hello\\Hello }}
\rhead{}
\rfoot{}
\pagestyle{fancy}

\setcounter{secnumdepth}{-1}

\begin{document}
  \begin{center}
      \begin{tcolorbox}[enhanced jigsaw,opacityback=0,sharp corners,parbox=false]
        \begin{enumerate}
          \item This is 1
          \item This is 2
        \end{enumerate}
      \end{tcolorbox}
  \end{center}
    \begin{enumerate}
      \item This is 1
      \item This is 2
    \end{enumerate}

\end{document}

在此处输入图片描述

答案2

noitemsep您可以通过使用设置简单地实现内部间距enumitem。(顺便说一句:我已经删除了不必要的center环境。)

列表间距

\documentclass{article}
\usepackage[a4paper, portrait, margin=1in, top=.25in, bottom=1.75in]{geometry}
\usepackage{%
  fontspec,
  parskip,
  lastpage,
  booktabs,
  polyglossia,
  graphicx, 
  fancyhdr,
  lato
}

\usepackage[many]{tcolorbox}

\usepackage[shortlabels]{enumitem}

\setmainfont{Lato}

\usepackage{hyperref}

\setlength{\headheight}{1.15in}
\setlength{\headsep}{.15in}
\renewcommand{\headrulewidth}{1pt}
\renewcommand{\footrulewidth}{1pt}
\lhead{\footnotesize{Hello\\Hello }}
\rhead{}
\rfoot{}
\pagestyle{fancy}

\setcounter{secnumdepth}{-1}
\setlist[enumerate]{noitemsep}

\begin{document}
    \begin{tcolorbox}[enhanced jigsaw,opacityback=0,sharp corners]
      \begin{enumerate}
        \item This is 1
        \item This is 2
      \end{enumerate}
    \end{tcolorbox}
    \begin{enumerate}
      \item This is 1
      \item This is 2
    \end{enumerate}

\end{document}

相关内容