我正在使用 tcolorbox 和 tcbset,标题位于页边距中,并且每个连续的标题都连在一起

我正在使用 tcolorbox 和 tcbset,标题位于页边距中,并且每个连续的标题都连在一起

在我的最后一个问题中,我需要 tcolorbox 的帮助,以便在左边距为我的框创建一个“标题”(并旋转 90 度)。解决方案很棒,但在某些情况下,就像下面的 MWE 中一样,“标题”会连在一起。

\documentclass[12pt]{article}

\usepackage{framed}
\usepackage{color}

\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{}
\author{}



\begin{document}

\maketitle


Gladsome Light of the Holy Glory of the Immortal Father, Heavenly, Holy, Blessed: O Jesus Christ. Now that we have come to the setting of the sun, and behold the light of evening, we praise God: Father, Son, and Holy Spirit, for meet it is at all times to worship Thee with voices of praise, O Son of God and Giver of life: therefore, all the world doth glorify Thee.\\

We now sing the appointed Prokimenon according to the day of the week:

\section*{Evening Prokimenon}

\begin{mybox}[colframe=blue]{Saturday Evening}
    
    
    The Lord is King: / He is robed in majesty.\\
    
    The Lord is robed, He is girded with strength.\\
    
    For He has established the world, so that it shall never be
    moved.\\
    
    Holiness befits Thy house, O Lord, forevermore!\\
    
\end{mybox}

\begin{mybox}[colframe=blue]{Sunday Evening}

    
    Behold now, bless the Lord, / all you servants of the Lord.\\
    
    
\end{mybox}

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

    
    The Lord will hear me / when I call upon Him.\\
    
    When I called, the God of my righteousness heard me.\\
\end{mybox}


\end{document}

结果

我对 tcolorbox 几乎一无所知,并且对 LaTeX 中的新环境和新命令只是有所熟悉,因此我尝试添加一些内容:

\small

以及其他一些字体大小如下:

{\small{\itshape #1}}

但由于我不知道在哪里更改框的字体大小,所以我不确定如何继续。

答案1

我对mytitle样式做了一些更改。标题现在横跨框的整个文本高度。如果您事先知道框高度会很小,您可以手动将其设置为足够大的值,以便正确呈现标题(参见本例中的第 2 个和第 3 个框)。

\documentclass[12pt]{article}

\usepackage{framed}
\usepackage{color}

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

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

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

%opening
\title{}
\author{}



\begin{document}
    
    \maketitle
    
    
    Gladsome Light of the Holy Glory of the Immortal Father, Heavenly, Holy, Blessed: O Jesus Christ. Now that we have come to the setting of the sun, and behold the light of evening, we praise God: Father, Son, and Holy Spirit, for meet it is at all times to worship Thee with voices of praise, O Son of God and Giver of life: therefore, all the world doth glorify Thee.\\
    
    We now sing the appointed Prokimenon according to the day of the week:
    
    \section*{Evening Prokimenon}
    
    \begin{mybox}[colframe=blue]{Saturday Evening}
        The Lord is King: / He is robed in majesty.\\
        
        The Lord is robed, He is girded with strength.\\
        
        For He has established the world, so that it shall never be
        moved.\\
        
        Holiness befits Thy house, O Lord, forevermore!
    \end{mybox}
    
    \begin{mybox}[colframe=blue,height=5em]{Sunday Evening}
        Behold now, bless the Lord, / all you servants of the Lord.
    \end{mybox}
    
    \begin{mybox}[colframe=blue,height=5em]{Monday Evening}
        The Lord will hear me / when I call upon Him.\\
        
        When I called, the God of my righteousness heard me.
    \end{mybox}
    
    
\end{document}

在此处输入图片描述

相关内容