Tcolorbox:可破坏的内联框

Tcolorbox:可破坏的内联框

我想要一个可破坏的内联框来强调一些文本。如果可以使用 tcolorbox,您知道如何实现吗?

谢谢!

在此处输入图片描述

梅威瑟:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % To switch to the T1 encoding
\usepackage{lmodern} % To switch to Latin Modern
\usepackage{exscale}
\usepackage[most]{tcolorbox}

\pagestyle{empty}

\begin{document}
\noindent Base text:\\
\noindent\rule{4cm}{1pt}\\
\begin{minipage}{4cm}
  Hello I would like to have a breakable tcbox in order to have a nice text.
\end{minipage}

\vspace{1cm}
\noindent With box (no break ??):\\
\noindent\rule{4cm}{1pt}\\
\begin{minipage}{4cm}
  Hello \tcbox[enhanced,nobeforeafter,tcbox raise base,breakable,colback=red!5!white,bottom=0pt,top=0pt,right=0pt,left=0pt,
    colframe=red!75!black]{I would like to have a breakable tcbox} in order to have a nice text.
\end{minipage}

\end{document}

答案1

capture=minipage只需在选项中选择模式(参见手册 4.14 第 94 页)。

我加载了该showframe包以便能够看到边距。

盒子

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} % To switch to the T1 encoding
\usepackage{lmodern} % To switch to Latin Modern
\usepackage{exscale}
\usepackage[most]{tcolorbox}
\usepackage{showframe}
\pagestyle{empty}

\begin{document}
\noindent Base text:\\
\noindent\rule{4cm}{1pt}\\
\begin{minipage}{4cm}
  Hello I would like to have a breakable tcbox in order to have a nice text.
\end{minipage}

\vspace{1cm}
\noindent With box (no break ??):\\
\noindent\rule{4cm}{1pt}\\
\begin{minipage}{4cm}
  Hello \tcbox[capture=minipage,enhanced,tcbox raise base,breakable,colback=red!5!white,bottom=0pt,top=0pt,right=0pt,left=0pt,
    colframe=red!75!black]{I would like to have a breakable tcbox} in order to have a nice text.
\end{minipage}

\end{document}

相关内容