6

I've been struggling with titlingpage and Memoir a few hours, trying to make the document title have equal linespacing between its lines when using \\.

The code is:

\documentclass[10pt,a4paper,oneside]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[brazil]{babel} %Hifenização em português

\title{Estudo e modelagem de \\ soluções de otimização discreta para \\ grades horárias}

\newcommand{\subtitle}{
    Trabalho de Conclusão do Curso de\\[-5pt]
    Bacharelado em Ciência da Computação
    }

%flushright alinha a direita
%DoubleSpacing, ver pag. 48 manual memoir
\pretitle {\begin{DoubleSpace} \begin{flushright} \begin{huge} \scshape}

%sffamily = sans serif
%tamanho grande = \Large
\posttitle {\end{huge} \\[1cm] \sffamily \Large \subtitle \end{flushright} \end{DoubleSpace}}

\begin{document}
\begin{titlingpage}
   \maketitle
\end{titlingpage}
\end{document}

The result:

Rendering of title

It has a small, but evident, difference in vertical space between lines, could you help me get rid of that ?

Thanks in advance.

EDIT (solved!):

Worked!

After applying \strut as suggested!

2
  • I am not able to compile your MWE. You could try adding \strut on each line. This is a box of zero width and height that extends just above and below the baseline. Nov 29, 2011 at 2:38
  • This really worked! But the space added is the one between the 1st and 2nd lines, and it's too big. I would like the second spacing to be applied. I will try the onehalf spacing in Memoir now.
    – Niloct
    Nov 29, 2011 at 3:12

2 Answers 2

13

Add \strut on each line. This is a box of zero width and height that extends just above and below the baseline which ensures that each line has the same vertical dimension.

Alternatively you could add a \vphantom so that each line has the same vertical dimension. This has the advantage of producing a tighter box, but the disadvantage that you need to specify paramterts which include the characters with the largest depth and height.

Here is a comparison of boxes with no adjustment, using \strut and \vphantom{}:

enter image description here

\documentclass{article}
\begin{document}
\begin{tabular}{c c c}
 & strut & vphantom\\
    \fbox{g}\fbox{f} &
    \fbox{g\strut}\fbox{f\strut} &  
    \fbox{g\vphantom{f}}\fbox{f\vphantom{g}}
\end{tabular}
\end{document}
2
  • Please try \fbox{g}\fbox{\"A}\fbox{g\strut}\fbox{\"A\strut}\fbox{g\vphantom{\"A}}\fbox{\"A\vphantom{g}}. \strut does not give the expected result. Mar 31, 2013 at 0:47
  • @Karl'sstudents: So, looks like \vphantom is better. Appears that \strut does not account for accents. Apr 1, 2013 at 4:05
6

There's no huge environment; there's the switch \huge:

\documentclass[10pt,a4paper,oneside]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[brazil]{babel}

\title{Estudo e modelagem de \\ soluções de otimização discreta para \\ grades horárias}

\newcommand{\subtitle}{
    Trabalho de Conclusão do Curso de \\
    Bacharelado em Ciência da Computação
    }

\pretitle {\begin{OnehalfSpacing} \begin{flushright}\huge\scshape}
\posttitle {\\[1cm]\normalfont\sffamily\Large \subtitle\end{flushright}\end{OnehalfSpacing}}

\begin{document}
\begin{titlingpage}
   \maketitle
\end{titlingpage}
\end{document}

enter image description here

4
  • Hi, your example worked, but when I added the subtitle it broke saying that "There's no line here to end." \posttitle {\par \\[1cm] \sffamily \Large \subtitle \end{flushright} \end{OnehalfSpacing}} (I am using OnehalfSpacing now).
    – Niloct
    Nov 29, 2011 at 3:28
  • (Obviously I defined the \subtitle as above).
    – Niloct
    Nov 29, 2011 at 3:35
  • @Niloct Yeah... obviously after you edited your question. Anyway, see my updated answer for a simple solution. Nov 29, 2011 at 3:59
  • I meant no offence man, I just said that I was aware that \subtitle needed and had a definition. Thank you for the answer, it is elegant but it was not the first working solution to the problem, therefore I reserve myself the right to grant the solution to another answer. +1 though, for sure.
    – Niloct
    Nov 29, 2011 at 4:45

You must log in to answer this question.

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