LaTeX forum ⇒ GeneralGeneric title page needs optimization Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
User avatar
Cham
Posts: 820
Joined: Sat Apr 02, 2011 4:06 pm

Generic title page needs optimization

Postby Cham » Sun Dec 03, 2017 6:13 am

I have a working generic title page that I want to add to some template documents (book, report, scrbook, scrreprt). As a simple example, take this small code :
  1. \RequirePackage[l2tabu,orthodox]{nag}
  2. \documentclass[11pt,letterpaper,twoside]{book}
  3. \usepackage[T1]{fontenc}
  4. \usepackage{lmodern}
  5. \usepackage{microtype}
  6. \usepackage[total={6.25in,10in},left=1.25in,top=0.5in,includehead,includefoot]{geometry}
  7.  
  8. \begin{document}
  9.  
  10. % CODE (1) :
  11. \title{Title}
  12. \author{Isaac Newton}
  13. \date{}
  14. \maketitle
  15. % END OF CODE (1)
  16.  
  17. \tableofcontents
  18.  
  19. \chapter{Chapter title} Text
  20.  
  21. \end{document}


Now, here's the title page :
  1. \RequirePackage[l2tabu,orthodox]{nag}
  2. \documentclass[12pt,oneside]{article}
  3. \usepackage[letterpaper,margin=1in]{geometry}
  4. \usepackage[T1]{fontenc}
  5. \usepackage{graphicx}
  6. \usepackage{float}
  7.  
  8. \begin{document}
  9.  
  10. % CODE (2) :
  11. \begin{titlepage}
  12. \hfill {}\par
  13. \vspace{0.25in}
  14.  
  15. \begin{center}
  16. {Course number}\par
  17. \vspace{0.5in}
  18. \vspace*{\baselineskip}
  19. \rule{4.5in}{1.6pt}\vspace*{-\baselineskip}\vspace*{2pt}
  20. \rule{4.5in}{0.4pt}\\[\baselineskip]
  21. {\Huge\textsc{Book title}}\\[1\baselineskip]
  22. {\large Subtitle}\\[0.2\baselineskip]
  23. \rule{4.5in}{0.4pt}\vspace*{-\baselineskip}\vspace{3.2pt}
  24. \rule{4.5in}{1.6pt}\\[2\baselineskip]
  25. Author
  26. \vspace{0.5in}
  27. \begin{figure}[H]
  28. \centering
  29. \includegraphics[width=4.5in]{example-grid-100x100pt}
  30. \end{figure}
  31. \vfill
  32. version, town, year.
  33. \end{center}
  34. \end{titlepage}
  35.  
  36. \end{document}


Preview :
page.jpg
page.jpg (24.65 KiB) Viewed 114 times


I believe that the title code (2) given above could be simplified and optimized in some way. The vertical spacings could also be adjusted for a better looking output.

What would be the best way in replacing the code (1) in the first code by a better version of the code (2) ?

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

Postby Johannes_B » Sun Dec 03, 2017 9:36 am

Never ever use a figure environment on a title page.
Get rid of all those weird spaces.
Start from scratch.
Have a look at https://en.wikibooks.org/wiki/LaTeX/Title_Creation ( and the links at the bottom) as well as http://tex.stackexchange.com/questions/ ... 280#210280
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
Cham
Posts: 820
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sun Dec 03, 2017 12:40 pm

Johannes, I don't agree. What do you mean about weird spaces? It's a good looking title page. The code may not be great, but the output is nice.

What would be your suggestion anyway ? You're not helping much.

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

Postby Johannes_B » Sun Dec 03, 2017 1:00 pm

  1. \vspace{0.5in}
  2. \vspace*{\baselineskip}

This is weird spacing for me.

Apart from that, the page is fine and i don't know what you want to optimize.
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
Cham
Posts: 820
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sun Dec 03, 2017 4:12 pm

Ah, yes here I agree! That vertical space is badly defined! :lol:

But you say that the rest is okay? What about the picture environment? You said that we shouldn't use that in a title page. How to show the picture without the picture environment?

And how to properly introduce the vertical spacings so the text (for example "Author") is centered between the "title box" and the picture below it?

The "Course number" should also be centered between the top (paper border) and the "title box".

The "title box" (with its horizontal frame) should be centered at about 2/3 (or 3/4 ?) of the bottom (paper edge), or maybe the golden ratio.

The picture should have the same size (horizontally) as the "title box".

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

Postby Johannes_B » Sun Dec 03, 2017 4:33 pm

Just leave out the figure environment. You do not need it to include a graphic.

Have you looked at TikZ? It allows you absolute positioning on the page. It can also draw the lines for you.

I think this is what you are looking for.

Unfortunately, i am not a TikZ person.
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
Cham
Posts: 820
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sun Dec 03, 2017 4:42 pm

Ahaa! Now I understand about the picture environment. Right, we don't need it. Code now already simpler.

I don't like Tikz. I already used it before for a few things, but I prefer to leave it out of my projects.

I need to fix the various vertical spacements. Any suggestions?

EDIT : The \begin{center} \end{center} appears to be useless too. Just using a \centering seems to be enough!

User avatar
Stefan Kottwitz
Site Admin
Posts: 8539
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sun Dec 03, 2017 4:47 pm

Yes, \centering is enough. The setting is valid until the current environment (titlepage here) ends.

\begin{center} ... \end{center} is for standalone centered text, displayed with additional space before and after.

Stefan
Site admin

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

Postby Johannes_B » Sun Dec 03, 2017 4:48 pm

No, not really a suggestion from my side.
It sounds lie you want self adjusting code, the spacing will be different for each different titlepage.

I suggest to space stuff by hand by looking at the output.
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
Stefan Kottwitz
Site Admin
Posts: 8539
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sun Dec 03, 2017 4:50 pm

Cham wrote:I need to fix the various vertical spacements.


Centering is usually done by inserting elastic space, such as \vfill. Several \vfill take the same space each, so it's used for centering (above and below) and for equal distances.

Stefan
Site admin


Return to “General”

Who is online

Users browsing this forum: Google [Bot] and 8 guests