3

How can I achieve consistent separation between each item in a list, regardless of whether a tcolorbox is used or not?

I want to ensure that the vertical spacing between items remains the same, regardless of whether there is a tcolorbox around the item or not. Currently, the tcolorbox affects the height of the text lines and disrupts the uniform separation.

I have attempted to set the \setlength\itemsep{.5em} to control the spacing, but it hasn't resolved the issue.

Here's a minimal example of the code I'm working with:

\documentclass[aspectratio=169]{beamer}
\usepackage[most]{tcolorbox}
\usepackage{minted}
\tcbset{on line,
    boxsep=4pt, left=0pt,right=0pt,top=0pt,bottom=0pt,
    colframe=white,colback=blue,
    highlight math style={enhanced}
}

\newcommand{\inlinecode}[1]{%
    \tcbox{\Verb|#1|}%
}

\begin{document}

\begin{frame}{Example}
    \begin{itemize}
        \item Item One
        \item Foo \inlinecode{Item Two}
        \item Bar \inlinecode{Item Three}
    \end{itemize}
\end{frame}

\end{document}

The current output of the code can be seen in the following image:

enter image description here

I would greatly appreciate any suggestions or solutions to achieve consistent separation between list items, while accounting for the presence of tcolorbox elements.

1 Answer 1

2

As a quick hack you could add something to the itemize item which makes it as tall and deep as your tcolorboxes (fine tune the numbers as needed):

% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}

\documentclass[aspectratio=169]{beamer}
\usepackage[most]{tcolorbox}
\usepackage{minted}
\tcbset{on line,
    boxsep=4pt, left=0pt,right=0pt,top=0pt,bottom=0pt,
    colframe=white,colback=blue,
    highlight math style={enhanced}
}

\newcommand{\inlinecode}[1]{%
    \tcbox{\Verb|#1|}%
}

\addtobeamertemplate{itemize item}{}{\rule[-0.75ex]{0pt}{3ex}}

\begin{document}

\begin{frame}{Example}
    \begin{itemize}
        \item Item One 
        \item Foo \inlinecode{Item Two} 
        \item Bar \inlinecode{Item Three}
    \end{itemize}
\end{frame}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .