\documentclass{scrartcl}
\usepackage{calc}
\usepackage{showframe}
\begin{document}
\setlength\parindent{0pt}
\newsavebox\maintitleBox
\newlength\maintitleHeight
\newcommand{\maintitle}[1]{%
\clearpage%
\savebox\maintitleBox{%
\parbox{\textwidth}{%
#1
\rule{\textwidth}{1mm}\par%
}%
}%
\setlength\maintitleHeight{\ht\maintitleBox + \dp\maintitleBox}%
\vspace*{-\maintitleHeight}\usebox\maintitleBox
}%
\maintitle{Test}
\end{document}
The maintitle is supposed to go above the text area on some pages. What I am trying to do is to save the height of the box and move the box up by exactly the height of the box.
However, I can't get it to work. What am I missing?
Edit: Would I have been more committed to testing, I would have seen that \maintitleHeight
is only the height of the text; not of the rule below. Now the question is: why is that and how can I fix this?
\ht\maintitleBox + \dp\maintitleBox
is a syntax error unless you have loaded thecalc
package (it would be clear what packages were in use in a complete document)fancyhdr
(while you're using a KOMA-script class, you're not using any of its functionality, so I doubt it's really in-use).