几何:计算垂直引线的 tcolorbox 的可填充垂直空间

几何:计算垂直引线的 tcolorbox 的可填充垂直空间

对于最后一页,在页脚上方输入了一个新句子,导致与重叠tcolorbox

因此,我想tcolorbox计算最后一页的可填充垂直空间,而不与新句子重叠End of the Exam

但是,为了保持第一页的布局相同,我不想改变页脚几何形状。

在此处输入图片描述

\documentclass{exam}
\usepackage[fontsize = 14pt]{scrextend}
\usepackage{lipsum}
\usepackage[xparse,breakable]{tcolorbox}
\usepackage[
includefoot,
foot = 0 mm,
bottom = 20 mm
]{geometry}


\pagestyle{headandfoot}

\newcommand{\myfooter}{
    \iflastpage{\raisebox{5pt}[0pt][0pt]{\large End of the Exam}}{}%
    \hrule\vspace{5pt}%
    Instructors%
}

\firstpagefooter{}{\myfooter}{}
\runningfooter{}{\myfooter}{}

\ExplSyntaxOn

\keys_define:nn { diaa / answers }
{
    d .dim_set:N = \l__diaa_answers_distance_dim,
    t .dim_set:N = \l__diaa_answers_thickness_dim,
    c .tl_set:N  = \l__diaa_answers_color_tl,
    d .initial:n = 10mm,
    t .initial:n = 0.2pt,
    c .initial:n = gray,
}

\NewTColorBox { fillAnswerRules } { O{} }
{
    height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners,
    boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1
}

\NewDocumentCommand{\FillAnswerRules}{O{}}
{
    \begin{fillAnswerRules}
        \keys_set:nn { diaa / answers } { #1 }
        \leaders \hbox:n
        {
            \makebox[\textwidth][s]
            {
                \color{\l__diaa_answers_color_tl}
                \vrule width 0pt height 0.5\l__diaa_answers_distance_dim
                depth 0.5\l__diaa_answers_distance_dim
                \leaders \hrule height \l__diaa_answers_thickness_dim \hfill
            }
        }\vfill
        \null
    \end{fillAnswerRules}
}

\ExplSyntaxOff


\begin{document}
    \lipsum[1-2]
    \FillAnswerRules
    \newpage
    \lipsum[1-2]
    \FillAnswerRules
\end{document}

答案1

您可以使用\enlargethispage{-1cm}或类似的方法,以使tcolorbox使用环境/tcb/height fill看到更短的最后一页:

\documentclass{exam}
\usepackage[fontsize = 14pt]{scrextend}
\usepackage{lipsum}
\usepackage[xparse,breakable]{tcolorbox}
\usepackage[includefoot,foot=0mm,bottom=20mm]{geometry}

\pagestyle{headandfoot}

\newcommand{\myfooter}{%
    \iflastpage{\raisebox{5pt}[0pt][0pt]{\large End of the Exam}}{}%
    \hrule\vspace{5pt}%
    Instructors%
}

\firstpagefooter{}{\myfooter}{}
\runningfooter{}{\myfooter}{}

\ExplSyntaxOn

\keys_define:nn { diaa / answers }
{
    d .dim_set:N = \l__diaa_answers_distance_dim,
    t .dim_set:N = \l__diaa_answers_thickness_dim,
    c .tl_set:N  = \l__diaa_answers_color_tl,
    d .initial:n = 10mm,
    t .initial:n = 0.2pt,
    c .initial:n = gray,
}

\NewTColorBox { fillAnswerRules } { O{} }
{
    height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners,
    boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt, #1
}

\NewDocumentCommand{\FillAnswerRules}{O{}}
{
    \begin{fillAnswerRules}
        \keys_set:nn { diaa / answers } { #1 }
        \leaders \hbox:n
        {
            \makebox[\textwidth][s]
            {
                \color{\l__diaa_answers_color_tl}
                \vrule width 0pt height 0.5\l__diaa_answers_distance_dim
                depth 0.5\l__diaa_answers_distance_dim
                \leaders \hrule height \l__diaa_answers_thickness_dim \hfill
            }
        }\vfill
        \null
    \end{fillAnswerRules}
}

\ExplSyntaxOff

\begin{document}
    \lipsum[1-2]
    \FillAnswerRules
    \newpage
    \lipsum[1-2]%
    \enlargethispage{-1cm}%
    \FillAnswerRules
\end{document}

在此处输入图片描述

为了好玩,经过评论中的讨论:

\documentclass{exam}
\usepackage[fontsize = 14pt]{scrextend}
\usepackage{lipsum}
\usepackage{calc}
\usepackage[breakable, skins, xparse]{tcolorbox}
\usetikzlibrary{decorations.pathmorphing}
\usepackage[includefoot,foot=2mm,bottom=20mm]{geometry}

\pagestyle{headandfoot}

\newcommand{\myfooter}{%
  \iflastpage{\raisebox{5pt}[0pt][0pt]{\large End of the Exam}}{}%
    \par
    \vspace*{5pt}%
    Instructors%
}

\firstpagefooter{}{\myfooter}{}
\runningfooter{}{\myfooter}{}

\ExplSyntaxOn

\keys_define:nn { diaa / answers }
{
    d .dim_set:N = \l__diaa_answers_distance_dim,
    t .dim_set:N = \l__diaa_answers_thickness_dim,
    c .tl_set:N  = \l__diaa_answers_color_tl,
    d .initial:n = 10mm,
    t .initial:n = 0.2pt,
    c .initial:n = gray,
}

\NewTColorBox { fillAnswerRules } { O{} }
{
    enhanced, height~fill, text~fill, colback=white, boxrule=2pt, sharp~corners,
    boxsep=0pt, left=10pt, right=10pt, top=8pt, bottom=0pt,
    overlay={
      \draw[red, decorate, decoration=snake] ([yshift=-4pt]frame.south~west) --
                 ([yshift=-4pt]frame.south~east);}, #1
}

\NewDocumentCommand{\FillAnswerRules}{O{}}
{
    \begin{fillAnswerRules}
        \keys_set:nn { diaa / answers } { #1 }
        \leaders \hbox:n
        {
            \makebox[\textwidth][s]
            {
                \color{\l__diaa_answers_color_tl}
                \vrule width 0pt height 0.5\l__diaa_answers_distance_dim
                depth 0.5\l__diaa_answers_distance_dim
                \leaders \hrule height \l__diaa_answers_thickness_dim \hfill
            }
        }\vfill
        \null
    \end{fillAnswerRules}
}

\ExplSyntaxOff


\begin{document}
    \lipsum[1-2]
    \FillAnswerRules
    \newpage
    \lipsum[1-2]%
    \enlargethispage{-1cm}%
    \FillAnswerRules
\end{document}

蛇形页脚

相关内容