文本和 tcolorbox 之间的空间太大

文本和 tcolorbox 之间的空间太大

我正在使用 tcolorbox,第二个 tcolorbox 之前的间距很乱,也就是说在框之前只有 3 行文本。

我尝试以 MWE 的形式输入文档,但我认为唯一的方法是输入所有 3 页文本,因为如果我删除页面上除间距问题文本之外的所有内容,间距看起来会很好。

那么我应该尝试制作一个 3 页的 MWE 吗?

谢谢

我最终使用 lipsum 包创建了一个可以重现该问题的 MWE。虽然这与我遇到的情况不完全相同(在我的完整文档中,从“来吧,让我们崇拜”开始的文本直到 tcolorbox 遍布整个页面),但这确实显示了我提到的间距问题。

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{indentfirst}
\usepackage{framed}
\usepackage{lipsum}

\usepackage[skins]{tcolorbox}

\tcbset{%
mytitle/.style={%
    enhanced,
    overlay={
        \node [rotate=90, anchor=south, fill=tcbcolframe!25] at (frame.west) {\itshape #1};
    },
},
}

\newtcolorbox{mybox}[2][]{%
mytitle={#2},
toprule=0pt,
bottomrule=0pt,
rightrule=0pt,
sharp corners,
#1
}

%opening
\title{Prayerbook Test}

\author{}

\begin{document}

    \maketitle

    \lipsum[1-4]

    \section*{Morning Troparia, Tone 2}

    Having risen from sleep, I thank Thee, O Holy Trinity, 
for in the abundance of Thy goodness and Thy
patience, Thou hast not become angry with me for
my laziness and sinfulness, nor hast Thou destroyed
me together with mine iniquities. Instead, in Thy
usual love for mankind, Thou hast raised me from
the gloominess of sleep, that I might rise up early
and glorify Thy power. Enlighten now the eyes of
my mind and open Thou my lips, that I might come
to learn Thy words, understand Thy commandments, 
accomplish Thy will, glorify Thee in heart-
felt confession, and praise Thine All-holy Name, of
the Father, Son, and Holy Spirit, now and ever, and
unto ages of ages. Amen.\\

Come, let us worship God our King!\\

Come, let us worship and fall down before Christ, our King and our God!\\

Come, let us worship and fall down before Christ Himself, our King and our God!\\

\section*{The Hexapsalms (The Six Psalms)}

\begin{mybox}[colframe=blue]{Monday Morning}

\subsection*{Psalm 3}

O Lord, why are they so many many that afflict me?
Many are they who rise up against me.
Many are they who say to my soul, ``There is no help for him in his God.''
But Thou, O Lord, art my defender; Thou art my glory, and the lifter up of my head.\\

I cried unto the Lord with my voice, and He heard me out of His holy hill.
I laid me down and slept; and I rose up again,
For the Lord sustained me.
I will not be afraid of the ten thousand that have surrounded themselves against me.\\

Arise, O Lord, and save me, O my God!
For Thou hast smitten all mine enemies upon the cheek,
Thou hast broken the teeth of the ungodly.
Salvation is of the Lord -- Thy blessing is upon Thy people.

\end{mybox}

\end{document}

抱歉,我最初的帖子表达得不够清楚。

非常感谢!

答案1

您可以tcolorbox跨多个页面创建可拆分项,以使用第一页剩余的空间。在您的示例中,使用\usepackage[skins, breakable]{tcolorbox}并将breakable参数添加到tcbset

A

\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{xcolor}
\usepackage{titlesec}
\usepackage{indentfirst}
\usepackage{framed}
\usepackage{lipsum}

\usepackage[skins,breakable]{tcolorbox} % changed <<<<<<<<<<<<

\tcbset{% changed <<<<<<<<<<<<
    mytitle/.style={%
        enhanced,
        overlay={
            \node [rotate=90, anchor=south, fill=tcbcolframe!25] at (frame.west) {\itshape #1};
        },
    },
breakable 
}

\newtcolorbox{mybox}[2][]{%
    mytitle={#2},
    toprule=0pt,
    bottomrule=0pt,
    rightrule=0pt,
    sharp corners,
    #1
}

%opening
\title{Prayerbook Test}

\author{}

\begin{document}
    
    \maketitle
    
    \lipsum[1-4]
    
    \section*{Morning Troparia, Tone 2}
    
    Having risen from sleep, I thank Thee, O Holy Trinity, 
    for in the abundance of Thy goodness and Thy
    patience, Thou hast not become angry with me for
    my laziness and sinfulness, nor hast Thou destroyed
    me together with mine iniquities. Instead, in Thy
    usual love for mankind, Thou hast raised me from
    the gloominess of sleep, that I might rise up early
    and glorify Thy power. Enlighten now the eyes of
    my mind and open Thou my lips, that I might come
    to learn Thy words, understand Thy commandments, 
    accomplish Thy will, glorify Thee in heart-
    felt confession, and praise Thine All-holy Name, of
    the Father, Son, and Holy Spirit, now and ever, and
    unto ages of ages. Amen.\\
    
    Come, let us worship God our King!\\
    
    Come, let us worship and fall down before Christ, our King and our God!\\
    
    Come, let us worship and fall down before Christ Himself, our King and our God!\\
    
    \section*{The Hexapsalms (The Six Psalms)}
    
    \begin{mybox}[colframe=blue]{Monday Morning}
        
        \subsection*{Psalm 3}
        
        O Lord, why are they so many many that afflict me?
        Many are they who rise up against me.
        Many are they who say to my soul, ``There is no help for him in his God.''
        But Thou, O Lord, art my defender; Thou art my glory, and the lifter up of my head.\\
        
        I cried unto the Lord with my voice, and He heard me out of His holy hill.
        I laid me down and slept; and I rose up again,
        For the Lord sustained me.
        I will not be afraid of the ten thousand that have surrounded themselves against me.\\
        
        Arise, O Lord, and save me, O my God!
        For Thou hast smitten all mine enemies upon the cheek,
        Thou hast broken the teeth of the ungodly.
        Salvation is of the Lord -- Thy blessing is upon Thy people.
        
    \end{mybox}
    
\end{document}

相关内容