1

I have created a MWE where one can picture my issue.

\documentclass[12pt]{article}
\usepackage[
    left   =0cm,
    right  =0cm,
    top    =0cm,
    bottom =0cm,
    paperwidth  = 521pt,
    paperheight = 384pt
    ]{geometry}
\usepackage{lipsum}
\usepackage[skins, breakable, theorems]{tcolorbox}

\pagestyle{empty}

\newtcolorbox{Mybox}{
    %enhanced,
    arc = 0pt,
    boxrule = 0pt,
    colback = blue,
    colupper = white,
    top= 2pt,
    bottom = 1pt
}


\begin{document}

\begin{Mybox}
    Some small upper text.
\end{Mybox}

\lipsum[1]

\vspace*{\fill}%
\begin{Mybox}
    Some small lower text.
\end{Mybox}

\end{document}

MWE

In the previous image, one can see that the top tcolorbox sticks perfectly to the top but the bottom one is not (quite). How can I fix this? Note the unusual geometry.

The geometry package does not show any other spacing than bottom so I should be able to reach the bottom of the page. Is that a flaw of the \vfill then?

PS: I do not want to work with fancyhdr here since I want something far more simple.

4
  • Ok so the problem actually come from tcolorbox and the option after=0pt should be added to Mybox and this solves the problem. If any admin is around, should I delete my question then? Commented May 24 at 17:20
  • 2
    I think it's better that you answer your own question.
    – jlab
    Commented May 24 at 17:58
  • (1) If you are trying to do presentations without know Beamer, take a look to this package. (2) You do not need the asterisk in \vspace in this case here, and instead of \vspace{\fill} you can use simply \vfill (3) If beamer is not option, maybe fancyhdr to place boxes as header and footers? (4) You can also have a perfect bottom box without dealing with spaces with options float, floatplacement=b. This option is only suitable if you have a good understanding of how floats behave.
    – Fran
    Commented May 25 at 9:00
  • @Fran [thanks for the comment] (1) This question comes as a detail in the full class for presentation I am building. I'm avoiding Beamer because it is either too constraining or too difficult to use. (2) I corrected that in my answer. (3) I did not manage to make fancyhdr work with tcolorbox. Furthermore, I am not using complicated headers/footers so that I find my environments more convinient. (4) I did not thought of using floats and that could be a good idea! All the more that tcolorbox allows one to treat the box as floats if one asks for it. Commented May 25 at 19:12

1 Answer 1

3

My issue was actually caused by a spacing specific to tcolorbox (that one can find in their documentation, page 11). Therefore, to solve my issue one just need to add after=0pt as option for the tcolorbox.

\documentclass[12pt]{article}
\usepackage[
    left   =0cm,
    right  =0cm,
    top    =0cm,
    bottom =0cm,
    paperwidth  = 521pt,
    paperheight = 384pt
    ]{geometry}
\usepackage{lipsum}
\usepackage[skins, breakable, theorems]{tcolorbox}

\pagestyle{empty}

\newtcolorbox{Mybox}{
    %enhanced,
    arc = 0pt,
    boxrule = 0pt,
    colback = blue,
    colupper = white,
    top= 2pt,
    bottom = 1pt,
    after = 0pt
}


\begin{document}

\begin{Mybox}
    Some small upper text.
\end{Mybox}

\lipsum[1]

\vfill%
\begin{Mybox}
    Some small lower text.
\end{Mybox}

\end{document}

I also changed \vspace*{\fill} to \vfill, as suggested by Fran.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .