1

The following MWE closely reproduces a LaTeX file I created. I'm using @egreg's solution to my question about programatically creating dummy text.

The issue is that the quoted section on the second page is pushed to the second page. I suppose this is because of the altered definition of the quoting environment that I used, namely

\tcolorboxenvironment{quoting}{code={\mbox{}},nobeforeafter,boxrule=2pt,sharp corners,breakable,skin=enhanced,colback=white}

However, I've been using that definition of quoting in a style file for some time, and it's mostly worked for me. And it's probably used in a number of existing documents. So I'd like to keep it as it is.

I have the following questions.

1) First, a minor one. I am correct to think that using vskip=10in
in the following line was an error, in the sense that it gets
overwritten by the new definition of quoting?

\usepackage[vskip=10in]{quoting}

I'm only using the quoting environment from the quoting package, as shown below, nothing else.

If this the case, I'll remove vskip=10in from that package declaration.

2) My main question is whether there is a graceful way to avoid having a large amount of empty space at the bottom of the first page.

I suppose this is being caused by the \mbox{} in the \tcolorboxenvironment declaration.

I was thinking that I could just leave the changed definition of quoting in the preamble as it is, but temporarily alter the definition in such a way as to allow that box on the second page to move to the first page. Is that possible? Or is there a better way to do it?

    \documentclass[12pt, sections, headheight=30pt, headinclude, 
    firstfoot=false, enlargefirstpage=true, foldmarks=false,
    foldmarks=blmtP, fromalign=center, fromphone, fromemail, version=last,
    backaddress=false, subject=titled]{scrlttr2}

    \usepackage[most]{tcolorbox}
    \usepackage[vskip=10in]{quoting}
    \usepackage[T1]{fontenc}
    \usepackage{fouriernc}
    \tcolorboxenvironment{quoting}{code={\mbox{}},nobeforeafter,boxrule=2pt,sharp corners,breakable,skin=enhanced,colback=white}

\ExplSyntaxOn
\NewDocumentCommand{\dummy}{m m m}
  {
   \prg_replicate:nn { #3 }
     {
      \prg_replicate:nn { #2 } { #1 \hfill } \dummy_endline:
     }
 }
\cs_new:Npn \dummy_endline:
  { { \parfillskip=0pt\par } }

\ExplSyntaxOff

\begin{document}
\setkomavar{fromname}{Name}
\setkomavar{fromaddress}{Address}
\renewcommand{\phonename}{Landline}
\renewcommand{\mobilephonename}{Mobile}
\setkomavar{frommobilephone}{Mobile}
\setkomavar{fromemail}{Email}
\setkomavar{signature}{(\usekomavar{fromname})}
\setkomavar{subject}{Subject}
\setkomavar{date}{\today}

\setkomavar{firsthead}{%
  \parbox{\linewidth}{\centering
    \textbf{\jobname.tex} \input{"| hg log -v -l 1 \jobname.tex --template '{node}  {date|isodate}'"}
    \ifhmode \\ \fi
    {\fontfamily{pzc}\selectfont
    \hspace{\textwidth}
    \usekomavar{fromname}\\
    \usekomavar{fromaddress}\\
    \usekomavar*{mobilephoneseparator}\usekomavar{mobilephoneseparator}\usekomavar{frommobilephone}\\
    \usekomavar*{emailseparator}\usekomavar{emailseparator}\usekomavar{fromemail}
    }
  }%
}

\makeatletter
\@addtoplength{firstheadvpos}{30pt}
\@addtoplength{toaddrvpos}{40pt}
\@addtoplength{refvpos}{10pt}
\@addtoplength{sigbeforevskip}{20pt}
\makeatletter\@setplength{sigindent}{0.5\linewidth}\makeatother
\makeatother

\def\today{20th February, 2019}
\begin{letter}{
    Someone\\
    Company\\
    Building\\
    Street\\
    City
  }

  \opening{Hi}

  \dummy{HelloWorld!}{3}{5}
  \begin{quoting}
    \dummy{HelloWorld!}{3}{3}
  \end{quoting}

  \dummy{HelloWorld!}{3}{3}

  \begin{quoting}
    \begin{tabular}{p{4.5in}r}
      \textbf{\dummy{HelloWorld!}{3}{1}  }  & \\
      \dummy{HelloWorld!}{3}{2}             & \dummy{HelloWorld!}{1}{1}
    \end{tabular}
  \end{quoting}

\closing{Yours Sincerely,}

\end{letter}
\end{document}
Faheem Mitha
  • 7,778

1 Answers1

1

I suggest to remove code={\mbox{}} and nobeforeafter from the option list passed to the \tcolorbox definition:

\documentclass[12pt, sections, headheight=30pt, headinclude, 
    firstfoot=false, enlargefirstpage=true, foldmarks=false,
    foldmarks=blmtP, fromalign=center, fromphone, fromemail, version=last,
    backaddress=false, subject=titled]{scrlttr2}

    \usepackage[most]{tcolorbox}
    \usepackage[vskip=10in]{quoting}
    \usepackage[T1]{fontenc}
    \usepackage{fouriernc}
    \tcolorboxenvironment{quoting}{
        %code={\mbox{}},nobeforeafter,

        before skip=\baselineskip, % or before skip = 1cm or something else

        boxrule=2pt,sharp corners,breakable,skin=enhanced,colback=white}

\ExplSyntaxOn
\NewDocumentCommand{\dummy}{m m m}
  {
   \prg_replicate:nn { #3 }
     {
      \prg_replicate:nn { #2 } { #1 \hfill } \dummy_endline:
     }
 }
\cs_new:Npn \dummy_endline:
  { { \parfillskip=0pt\par } }

\ExplSyntaxOff

\begin{document}
\setkomavar{fromname}{Name}
\setkomavar{fromaddress}{Address}
\renewcommand{\phonename}{Landline}
\renewcommand{\mobilephonename}{Mobile}
\setkomavar{frommobilephone}{Mobile}
\setkomavar{fromemail}{Email}
\setkomavar{signature}{(\usekomavar{fromname})}
\setkomavar{subject}{Subject}
\setkomavar{date}{\today}

\setkomavar{firsthead}{%
  \parbox{\linewidth}{\centering
    \textbf{\jobname.tex} \input{"| hg log -v -l 1 \jobname.tex --template '{node}  {date|isodate}'"}
    \ifhmode \\ \fi
    {\fontfamily{pzc}\selectfont
    \hspace{\textwidth}
    \usekomavar{fromname}\\
    \usekomavar{fromaddress}\\
    \usekomavar*{mobilephoneseparator}\usekomavar{mobilephoneseparator}\usekomavar{frommobilephone}\\
    \usekomavar*{emailseparator}\usekomavar{emailseparator}\usekomavar{fromemail}
    }
  }%
}

\makeatletter
\@addtoplength{firstheadvpos}{30pt}
\@addtoplength{toaddrvpos}{40pt}
\@addtoplength{refvpos}{10pt}
\@addtoplength{sigbeforevskip}{20pt}
\makeatletter\@setplength{sigindent}{0.5\linewidth}\makeatother
\makeatother

\def\today{20th February, 2019}
\begin{letter}{
    Someone\\
    Company\\
    Building\\
    Street\\
    City
  }

  \opening{Hi}

  \dummy{HelloWorld!}{3}{5}
  \begin{quoting}
    \dummy{HelloWorld!}{3}{3}
  \end{quoting}

  \dummy{HelloWorld!}{3}{3}

  \begin{quoting}
    \begin{tabular}{p{4.5in}r}
      \textbf{\dummy{HelloWorld!}{3}{1}  }  & \\
      \dummy{HelloWorld!}{3}{2}             & \dummy{HelloWorld!}{1}{1}
    \end{tabular}
  \end{quoting}

\closing{Yours Sincerely,}

\end{letter}
\end{document}