为什么示例 2 中有一个额外的垂直空间

为什么示例 2 中有一个额外的垂直空间

在以下 MWE 中,为什么示例 2 中有一个额外的垂直空格?

\documentclass{article}

\usepackage[most]{tcolorbox}
\usepackage{showframe}
\usepackage{harmony}

\newtcolorbox{myFrame}
{colback = red, colframe = white, top = 0mm, bottom = 0mm, boxrule = 0pt, left = 2mm, right = 2mm}

\newcommand{\easy}{%
    \llap{\parbox[t][0pt]{1.7cm}{%
            \Acht{}test\\
            \small{}easy
    }}%
}
\newcommand{\easyBis}{%
    \llap{\parbox[t][0pt]{1.7cm}{%
            test\\
            \small{}easy
    }}%
}

\begin{document}
    
    \begin{myFrame}
        \easy
        Example 1\par
        This is the text of the exercise.\par
        By the way, I use tcolorbox to make my boxes.
    \end{myFrame}
    

    \begin{myFrame}
        \easyBis
        Example 2\par
        This is the text of the exercise.\par
        By the way, I use tcolorbox to make my boxes.
    \end{myFrame}
    
\end{document}

在此处输入图片描述

答案1

不要在垂直模式下使用原始 tex 框,它们很少能达到您所期望的效果。

在此处输入图片描述

\documentclass{article}

\usepackage[most]{tcolorbox}
\usepackage{showframe}
\usepackage{harmony}

\newtcolorbox{myFrame}
{colback = red, colframe = white, top = 0mm, bottom = 0mm, boxrule = 0pt, left = 2mm, right = 2mm}

\newcommand{\easy}{%
    \leavevmode\llap{\parbox[t][0pt]{1.7cm}{%
            \leavevmode\Acht{}test\\
            \small{}easy
    }}%
}
\newcommand{\easyBis}{%
    \leavevmode\llap{\parbox[t][0pt]{1.7cm}{%
            test\\
            \small{}easy
    }}%
}

\begin{document}
    
    \begin{myFrame}
        \easy
        Example 1\par
        This is the text of the exercise.\par
        By the way, I use tcolorbox to make my boxes.
    \end{myFrame}
    

    \begin{myFrame}
        \easyBis
        Example 2\par
        This is the text of the exercise.\par
        By the way, I use tcolorbox to make my boxes.
    \end{myFrame}
    
\end{document}

或者更好的是,隐藏音符的高度以获得相同的上方空间Example

在此处输入图片描述

\documentclass{article}

\usepackage[most]{tcolorbox}
\usepackage{showframe}
\usepackage{harmony}

\newtcolorbox{myFrame}
{colback = red, colframe = white, top = 0mm, bottom = 0mm, boxrule = 0pt, left = 2mm, right = 2mm}

\newcommand{\easy}{%
    \leavevmode\llap{\parbox[t][0pt]{1.7cm}{%
            \leavevmode\strut\smash{\Acht}test\\
            \small{}easy
    }}%
}
\newcommand{\easyBis}{%
    \leavevmode\strut\llap{\parbox[t][0pt]{1.7cm}{%
            test\\
            \small{}easy
    }}%
}

\begin{document}
    
    \begin{myFrame}
        \easy
        Example 1\par
        This is the text of the exercise.\par
        By the way, I use tcolorbox to make my boxes.
    \end{myFrame}
    

    \begin{myFrame}
        \easyBis
        Example 2\par
        This is the text of the exercise.\par
        By the way, I use tcolorbox to make my boxes.
    \end{myFrame}
    
\end{document}

相关内容