0

Edit 1: The image should be "Three Lines Instead of Four".

Edit 2: Compilable Code updated.

I am new to Latex, and I have the following piece of template code that provides a title for my thesis:


\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided
\usepackage{graphicx}
\usepackage[ngerman,american]{babel}
\newcommand*{\getUniversity}{University of Earth}
\newcommand*{\getFaculty}{Engineering Department}
\newcommand*{\getDegree}{Computer Science}
\newcommand*{\getSchool}{School of Public Science}
\newcommand*{\getTitle}{This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break}
\newcommand*{\getTitleGer}{This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break}
\newcommand*{\getAuthor}{Author}
\newcommand*{\getDoctype}{Thesis}
\newcommand*{\getSupervisor}{Faculty Professor}
\newcommand*{\getAdvisor}{Faculty Advisr}
\newcommand*{\getSubmissionDate}{\today}
\newcommand*{\getSubmissionLocation}{Somewhere In between}

\begin{document}

\begin{titlepage}
  \centering

    \includegraphics[height=20mm]{example-image-a}
  

  \vspace{5mm}
  {\huge\MakeUppercase{School of \getSchool{} --- \getFaculty{}} \par}

  \vspace{5mm}
  {\large\MakeUppercase{\getUniversity{}} \par}

  \vspace{20mm}
  % \vspace{6mm}
  {\Large \getDoctype{} in \getDegree{} \par}

  \vspace{15mm}
  % \vspace{4mm}
  {\huge\bfseries \getTitle{} \par}

  \vspace{5mm}
  {\huge\bfseries \foreignlanguage{ngerman}{\getTitleGer{}} \par}

  \vspace{10mm}
  \begin{tabular}{l l}
    Author:          & \getAuthor{}         \\
    Supervisor:      & \getSupervisor{}     \\
    Advisors:         & \getAdvisor{}        \\
    Submission Date: & \getSubmissionDate{} \\
  \end{tabular}
  
  
    \vfill{}
    \includegraphics[height=15mm]{example-image-b}
  
\end{titlepage}



\end{document}

I have two questions:

  1. Is there a way to increase the margin of the line for the \getTitle{} part? I want to keep the font size and the vspace{} specification. As the title gets longer, it tends to break into 3-4 lines very fast. I want to stretch it to get around 2-3 lines.

  2. In case the title is too long, the authorship part and the final faculty_logo (Image Example B in the code snippet) would break into the next page. Is there a way to always fix these two components at the bottom of the page without moving to the next page?

Overall, I want 2 titles, each with 3 lines of the same text length defined in the code snippet, and everything should stay on the same page.

2
  • Please name the used you used and please make your code snippet be compilable, then we do not have to guess what you are doing ...
    – Mensch
    Apr 13 at 17:08
  • @Mensch Pardon my clumsiness, I have updated a compilable code snippet and removed the confusing image.
    – John
    Apr 13 at 18:24

1 Answer 1

0

Probably a macro is sufficient which produces a \parbox that sticks out into the margins:

\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided

%---------------------------------------------------------
\newsavebox\scratchbox
\newcommand\boxIntoMargins[4]{%
  \savebox\scratchbox{%
     \mbox{%
       \kern-\dimexpr(#1)\relax
       \parbox[b]{\dimexpr((#1)+(#2)+(#3))\relax}{#4}%
     }%
  }%
  \wd\scratchbox=\linewidth
  \usebox\scratchbox
}%
%---------------------------------------------------------


\usepackage{graphicx}
\usepackage[ngerman,american]{babel}
\newcommand*{\getUniversity}{University of Earth}
\newcommand*{\getFaculty}{Engineering Department}
\newcommand*{\getDegree}{Computer Science}
\newcommand*{\getSchool}{School of Public Science}
\newcommand*{\getTitle}{%
  \boxIntoMargins{1.5cm}{\linewidth}{1.5cm}{%
    \centering
    This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break%
  }%
}
\newcommand*{\getTitleGer}{%
  \boxIntoMargins{1.5cm}{\linewidth}{1.5cm}{%
    \centering
    This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break%
  }%
}
\newcommand*{\getAuthor}{Author}
\newcommand*{\getDoctype}{Thesis}
\newcommand*{\getSupervisor}{Faculty Professor}
\newcommand*{\getAdvisor}{Faculty Advisr}
\newcommand*{\getSubmissionDate}{\today}
\newcommand*{\getSubmissionLocation}{Somewhere In between}

\begin{document}

\begin{titlepage}
  \centering

    \includegraphics[height=20mm]{example-image-a}
  

  \vspace{5mm}
  {\huge\MakeUppercase{School of \getSchool{} --- \getFaculty{}} \par}

  \vspace{5mm}
  {\large\MakeUppercase{\getUniversity{}} \par}

  \vspace{20mm}
  % \vspace{6mm}
  {\Large \getDoctype{} in \getDegree{} \par}

  \vspace{15mm}
  % \vspace{4mm}
  {\huge\bfseries \getTitle{} \par}

  \vspace{5mm}
  {\huge\bfseries \foreignlanguage{ngerman}{\getTitleGer{}} \par}

  \vspace{10mm}
  \begin{tabular}{l l}
    Author:          & \getAuthor{}         \\
    Supervisor:      & \getSupervisor{}     \\
    Advisors:         & \getAdvisor{}        \\
    Submission Date: & \getSubmissionDate{} \\
  \end{tabular}
  
  
    \vfill{}
    \includegraphics[height=15mm]{example-image-b}
  
\end{titlepage}

\end{document}

Screenshot of compiling using Overleaf:

enter image description here



In a supplemental comment the following question was raised:

I forgot to adjust the default value for the template again. The height of the image b should be 20mm, which still breaks to the second page. Is there a way to always keep it on one page?

The author of the initiall release of this answer guesses there is no way to always keep things on a single page as the condition of having too much text to fit on a single page can always be fulfilled by just having more text. ;-) And he thinks trying to automatize tweaking things for increasing the chance of having things fit on a single page might not be worth the efforts.

You could probably put the content of the titlepage into a separate \newsavebox where things may exceed the measurements of the paper and combine the usage of the the command \scalebox from the package graphicxs and the command \usebox for down-scaling the box to fit on the paper.

Or have the titlepage in a separate .tex-document from which a separate .pdf-file is to be createed, which in turn is to be included into your main document via \includegraphics whereby down-scaling to fit the size of the main document's paper can be done. Within the separate .tex-document a box holding the titlepage which exceeds the measurements of the paper of your document is shipped out after adjusting the \(pdf)pagewidth and \(pdf)pageheight.
The following might be an outline of how to approach the matter this way:

\documentclass{article}
\newbox\BoxWithTitlepage
\newcommand\ShipoutAsPage[1]{%
  \begingroup
  \setbox\BoxWithTitlepage=\vbox{%
    \hrule height 0pt
    #1\ifvmode\else\expandafter\endgraf\fi
    \hrule height 0pt
  }%
  \csname @ifundefined\endcsname{pagewidth}{}{\pagewidth=\wd\BoxWithTitlepage}%
  \csname @ifundefined\endcsname{pdfpagewidth}{}{\pdfpagewidth=\wd\BoxWithTitlepage}%
  \csname @ifundefined\endcsname{pageheight}{}{\pageheight=\ht\BoxWithTitlepage
                                               \advance\pageheight\dp\BoxWithTitlepage}%
  \csname @ifundefined\endcsname{pdfpageheight}{}{\pdfpageheight=\ht\BoxWithTitlepage
                                                  \advance\pdfpageheight\dp\BoxWithTitlepage}%
  \shipout\vbox{\kern-1truein\hbox{\kern-1truein\box\BoxWithTitlepage}}%
  \endgroup  
}%
\begin{document}
\ShipoutAsPage{%
  % Content of your titlepage
  % Content of your titlepage
  % Content of your titlepage
  % Content of your titlepage
}%
\end{document}

But there are good reasons why this cannot really be recommended:

  • This way you cannot easily have hyperlinks from the titlepage to some other place of the document.
  • Scaling won't look good as fonts are not in their natural sizes any more.
  • Rules/lines, eg., of tables or of images created with the tikzpictureenvironment, and the like might get too thin when scaling things to smaller size and thus might not be printable.

Therefore you might probably be better off tweaking things "by hand", e.g., enlarging the typearea of the titlepage a bit towards the bottom of the paper and also kerning things upwards a little bit. The following is a "quick'n dirty"-solution, but might probably fulfill the purpose:

\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook} % one-sided

%---------------------------------------------------------
\newsavebox\scratchbox
\newcommand\boxIntoMargins[4]{%
  \savebox\scratchbox{%
     \mbox{%
       \kern-\dimexpr(#1)\relax
       \parbox[b]{\dimexpr((#1)+(#2)+(#3))\relax}{#4}%
     }%
  }%
  \wd\scratchbox=\linewidth
  \usebox\scratchbox
}%
%---------------------------------------------------------


\usepackage{graphicx}
\usepackage[ngerman,american]{babel}
\newcommand*{\getUniversity}{University of Earth}
\newcommand*{\getFaculty}{Engineering Department}
\newcommand*{\getDegree}{Computer Science}
\newcommand*{\getSchool}{School of Public Science}
\newcommand*{\getTitle}{%
  \boxIntoMargins{1.5cm}{\linewidth}{1.5cm}{%
    \centering
    This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break%
  }%
}
\newcommand*{\getTitleGer}{%
  \boxIntoMargins{1.5cm}{\linewidth}{1.5cm}{%
    \centering
    This is a Long title that I want to stretch the Margin so that instead of 4 lines, it should only be 3 lines, and the logo at the end won't break%
  }%
}
\newcommand*{\getAuthor}{Author}
\newcommand*{\getDoctype}{Thesis}
\newcommand*{\getSupervisor}{Faculty Professor}
\newcommand*{\getAdvisor}{Faculty Advisr}
\newcommand*{\getSubmissionDate}{\today}
\newcommand*{\getSubmissionLocation}{Somewhere In between}

\begin{document}

\begin{titlepage}
  \enlargethispage{1cm}%
  \hrule height 0mm
  \kern-.5cm

  \centering

    \includegraphics[height=20mm]{example-image-a}
  

  \vspace{5mm}
  {\huge\MakeUppercase{School of \getSchool{} --- \getFaculty{}} \par}

  \vspace{5mm}
  {\large\MakeUppercase{\getUniversity{}} \par}

  \vspace{20mm}
  % \vspace{6mm}
  {\Large \getDoctype{} in \getDegree{} \par}

  \vspace{15mm}
  % \vspace{4mm}
  {\huge\bfseries \getTitle{} \par}

  \vspace{5mm}
  {\huge\bfseries \foreignlanguage{ngerman}{\getTitleGer{}} \par}

  \vspace{10mm}
  \begin{tabular}{l l}
    Author:          & \getAuthor{}         \\
    Supervisor:      & \getSupervisor{}     \\
    Advisors:         & \getAdvisor{}        \\
    Submission Date: & \getSubmissionDate{} \\
  \end{tabular}
  
  
    \vfill{}
    \includegraphics[height=20mm]{example-image-b}
  
\end{titlepage}

\end{document}

enter image description here

In case ratio ⟨height-of-top-margin⟩:⟨height-of-bottom-margin⟩ is not 1:1 you might need to do a bit more calculation to ensure that with vertically kerning upwards while enlarging the typearea downwards that ratio is still preserved.

In case ratio ⟨width-of-margin-at-the-left⟩:⟨width-of-margin-at-the-right⟩ is not 1:1 you might need to do a bit more calculation to ensure that with

\boxIntoMargins{<amount of horizontal space that sticks into left margin>}%
               {\linewidth}%
               {<amount of horizontal space that sticks into right margin>}%
               {...}%

that ratio is preserved.


Probably with the line
{\huge\MakeUppercase{School of \getSchool{} --- \getFaculty{}} \par}
it might look nice when things are arranged so that in case both a linebreak occurs right before the first em-dash, and the entire string denoting the faculty fits on a single line on its own. an em-dash is appended behind \getFaculty{} so that the faculty-string is nested between two em-dashes. ;-)


Btw: The code of your example reminds me of Cover Page and Title Page with scrbook with unwanted empty page after Title Page. Probably you find some helpful insight there.

6
  • I cannot compile it on overleaf with the Undefined Control Sequence Errors. The first ones look like this: pastebin.com/FdASzHYr
    – John
    Apr 13 at 20:19
  • @John I just created a new project on Overleaf and inserted the example code and Recompiled from scratch, using TeX Live version 2023 and pdfLaTeX and did not get any errors. Same with lualatex. Here's a screenshot. Apr 13 at 20:38
  • @John The error about "Undefined control sequence l.7 \abx@aux@refcontext" indicates that the package Biblatex was loaded at some time and left its traces in the .aux-files while with my example the package Biblatex is not loaded at all. See Problem with Biblatex, Latex does not compile the pdf. I guess the the error is due to an .aux-file with obsolete data which is a leftover from compiling your project before inserting my example. What happens when you click on the small triangle at the right of "Recompile" and select "Recompile from scratch"? Apr 13 at 21:01
  • This is a super great insight for me!!! It works like a charm. One more question: I forgot to adjust the default value for the template again. The height of the image b should be 20mm, which still breaks to the second page. Is there a way to always keep it on one page?
    – John
    Apr 13 at 21:17
  • @John I added a few remarks to my answer. Apr 13 at 23:52

You must log in to answer this question.

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