2

I want to create a blank page (no header, footer and page numbering) with only one word centered horizontally and 35% vertically from the top, with page margins in mind. For my headers/footers I use the package fancyhdr, and the document is compiled by pdflatex.

However, if I use the following code for my individual *.tex file I notice that the horizontal alignment is off by a couple of millimeters to the left. What is the cause of this?

\begingroup
    \thispagestyle{empty}
    \centering
    \vspace*{.34\textheight}
    \fbox{{\normalfont\fontsize{25}{25}\bfseries Anhang}}
    \vspace*{\fill}

\endgroup

Preview: enter image description here

4
  • 1
    Write a sign % after \fbox: \fbox{...}%
    – user91669
    Nov 19, 2017 at 11:47
  • The reason of this is that the line breaking after \fbox{...} generates a space!
    – user91669
    Nov 19, 2017 at 11:55
  • @tomacs Indeed. Now it's aligned correctly. Sometimes the answer is so simple. Thank you sir. Nov 19, 2017 at 12:02
  • How should I mark this question as answered? Perhaps by adding the solution to the thread? Nov 19, 2017 at 12:03

3 Answers 3

1

The reason of this is that the line breaking after \fbox{...} generates a space! Write % after \fbox: \fbox{...}%

0

Replace \centering with the center environment (maybe you'll have to adapt the vertical spacing):

\documentclass{article}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage[showframe]{geometry} 

\begin{document}

\begingroup
    \thispagestyle{empty}
    \vspace*{.34\textheight}
\begin{center}
    \fbox{{\normalfont\fontsize{25}{25}\bfseries Anhang}}
\end{center}
    \vspace*{\fill}

\endgroup

\end{document} 
1
  • Your answer is also correct, but then I additionally have to deal with the occurring space before the text. tomacs answer will suffice for this matter. Still a good answer. Nov 19, 2017 at 12:07
0

It's best to use \vspace between paragraphs. I also set the word in a zero height and depth box, after moving it down by half its total height plus depth.

\documentclass{book}

\usepackage{showframe}% for seeing the page margins

\begin{document}

% whatever before the appendix

\cleardoublepage

\begingroup
\thispagestyle{empty}
\centering

\fboxsep=-\fboxrule % just for the example

\vspace*{\stretch{0.35}}

\noindent\raisebox{-0.5\totalheight}[0pt][0pt]{%
%  \normalfont\fontsize{25}{0}\bfseries Anhang% <--- should be this
  \normalfont\fontsize{25}{0}\bfseries \fbox{Anhang}% <--- for the measuring
}

\vspace*{\stretch{0.65}}

\endgroup

\cleardoublepage

\end{document}

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.