Page Layout\addtolength{}{} and \Huge{\baselineskip}

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
LaTeX
Posts: 11
Joined: Sun Sep 27, 2015 11:04 am

\addtolength{}{} and \Huge{\baselineskip}

Post by LaTeX »

Hello,

I tried to add the length of a Huge baselineskip to a previously defined length with the following code, but apparently I receive an error:

Code: Select all

\newlength{\length}
\setlength{\length}{5cm}
\addtolength{\length}{\Huge{\baselineskip}}
Without the Huge, it works fine:

Code: Select all

\newlength{\length}
\setlength{\length}{5cm}
\addtolength{\length}{\baselineskip}
Any ideas?

Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

\addtolength{}{} and \Huge{\baselineskip}

Post by Johannes_B »

Welcome,

what exactely are your trying to achieve? I bet there is a more simple way to get there. Can you provide a minimal working example?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
LaTeX
Posts: 11
Joined: Sun Sep 27, 2015 11:04 am

\addtolength{}{} and \Huge{\baselineskip}

Post by LaTeX »

Yes, I want to put a box around the title which is exactly a Huge baselineskip away from the text:

Code: Select all

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\begin{document}

\newlength{\Length}
\settowidth{\Length}{\Huge{Minimal working example}}
\addtolength{\Length}{2\baselineskip}

\title{Text over the title \vspace{\baselineskip} \\ \fbox{\parbox{\Length}{\begin{center} \Huge{\vspace{\baselineskip} Minimal working example \vspace{\baselineskip}} \end{center}}}}

\author{Author}

\maketitle

\end{document}
And actually I want to have

\addtolength{\length}{\Huge{\baselineskip}}

instead of

\addtolength{\length}{\baselineskip}

which gives an error.

Furthermore I just encountered that in this minimal working example the box also get's bigger as soon as I add the \begin{center} and \end{center} commands which is not the case in my original document.

Does anybody have a suggestion?
Last edited by Stefan Kottwitz on Sun Sep 27, 2015 5:15 pm, edited 1 time in total.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

\addtolength{}{} and \Huge{\baselineskip}

Post by cgnieder »

Since\Huge makes assignments it cannot be used in the argument of \settowidth. (Also \Huge does not take an argument! It is a font-size switch.)

Do you want something like this:

Code: Select all

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\begin{document}

\newlength{\titleboxwidth}

\title{%
  Text over the title \\[\baselineskip]
  \framebox{%
    \Huge
    \settowidth{\titleboxwidth}{Minimal working example}%
    \addtolength{\titleboxwidth}{2\baselineskip}%
    \parbox[c][3\baselineskip]{\titleboxwidth}{%
      \centering
      Minimal working example%
    }%
  }%
}

\author{Author}

\maketitle

\end{document}
site moderator & package author
LaTeX
Posts: 11
Joined: Sun Sep 27, 2015 11:04 am

Re: \addtolength{}{} and \Huge{\baselineskip}

Post by LaTeX »

Thanks for the answer! It comes close, but it seems to me that the space above and below the text is not quite the same size than the space left and right of the text?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

\addtolength{}{} and \Huge{\baselineskip}

Post by Johannes_B »

I didn't actaully measure the space, but a thing to consider. The letters of the alphabet have a width, a height and a depth (as far as TeX is concerned). Letter p and q have a positive depth, while m does not. An l or a t or any uppercase latter (A) have a bigger height than others. I bet the rules may never look evenly spaced by automatic measures. You would need to space the rules by hand.

By the way, i don't recommend to use \maketitle here. Using the titlepage environment might be far better.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

\addtolength{}{} and \Huge{\baselineskip}

Post by cgnieder »

LaTeX wrote:it seems to me that the space above and below the text is not quite the same size than the space left and right of the text?
You're right. But it wasn't clear to me from your question that this was your goal. The reason is that a line of text vertically needs less space than one \baselineskip. So instead of 3\baselineskip we need less vertical space for the \parbox.

Here is another try:

Code: Select all

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\begin{document}

\newlength{\titleboxwidth}
\newlength{\titleboxheight}

\title{%
  Text over the title \\[\baselineskip]
  \framebox{%
    \Huge
    \settowidth{\titleboxwidth}{Minimal working example}%
    \settoheight{\titleboxheight}{Minimal working example}%
    \addtolength{\titleboxwidth}{2\baselineskip}%
    \addtolength{\titleboxheight}{2\baselineskip}%
    \parbox[c][\titleboxheight]{\titleboxwidth}{%
      \centering
      Minimal working example%
    }%
  }%
}

\author{Author}

\maketitle

\end{document}
The space above an below still may seem to look uneven. The reason for this is (as Johannes noted) the depth of the letters with descenders vs those without…

Regards
site moderator & package author
LaTeX
Posts: 11
Joined: Sun Sep 27, 2015 11:04 am

Re: \addtolength{}{} and \Huge{\baselineskip}

Post by LaTeX »

Great, thanks for your answers!
Post Reply