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: 813
Joined: Sat Apr 02, 2011 4:06 pm

Generic title page needs optimization

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

This code is already much better. But I still don't understand a few parts :
  1. \RequirePackage[l2tabu,orthodox]{nag}
  2. \documentclass[12pt,letterpaper,twoside]{article}
  3. \usepackage[letterpaper,margin=1in]{geometry}
  4. \usepackage[T1]{fontenc}
  5. \usepackage{graphicx}
  6.  
  7. \begin{document}
  8.  
  9. % CODE (2) :
  10. \begin{titlepage}
  11. \centering
  12.  
  13. \vfill
  14.  
  15. Course number
  16.  
  17. \vfill
  18.  
  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.  
  26. Author
  27. \vspace{0.5in}
  28.  
  29. \includegraphics[width=4.5in]{example-grid-100x100pt}
  30.  
  31. \vfill
  32.  
  33. version, town, year.
  34. \end{titlepage}
  35.  
  36. \end{document}


How to make the Author in the middle, without the \vspace{0.5in} command ? \vfill doesn't seem to help there and I don't understand what's going on in this part.

Also, I don't understand the title part. Why the extra { } around the Book title and around the Subtitle ? I suspect this part could be much simpler.

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

Postby Stefan Kottwitz » Sun Dec 03, 2017 5:06 pm

Braces do grouping and are limiting the effect of local commands (scoping). So, {\large Subtitle} means that after the group with braces has ended, \large is not affecting the following text. {...}acts like an environment, limiting the effect of commands, such as centering and font size or color or shape commands.

Stefan
Site admin

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

Postby Stefan Kottwitz » Sun Dec 03, 2017 5:10 pm

Cham wrote:How to make the Author in the middle, without the \vspace{0.5in} command ?


It's just a single title page. It's ok to manually tweak here and there for that single case.

LaTeX' centering commands and such staff is usually working on base lines. Even if you would get the base line perfectly centered, the text is nor centered since it has some height. One could put it into a box and center that one.. but I would just quickly insert vertical space here to adjust.

Stefan
Site admin

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sun Dec 03, 2017 5:23 pm

Stefan, how would you do the part inside the rules? I still don't understand the vertical spacing commands there (there's even a negative -\baselineskip) :
  1. \rule{4.5in}{1.6pt}\vspace*{-\baselineskip}\vspace*{2pt}
  2. \rule{4.5in}{0.4pt}\\[\baselineskip]
  3. {\Huge\textsc{Book title}}\\[1\baselineskip]
  4. {\large Subtitle}\\[0.2\baselineskip]
  5. \rule{4.5in}{0.4pt}\vspace*{-\baselineskip}\vspace{3.2pt}
  6. \rule{4.5in}{1.6pt}\\[2\baselineskip]


The space between the thick and thin lines should be an exact fixed constant. The title and subtitle should be equilibrated inside the rules. This code was an old "hack" done a long time ago, and I probably got some parts from elsewhere without a clear understanding of what was going on (my use of the picture and center environments talks by themselves! :oops: )

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

Postby Stefan Kottwitz » Sun Dec 03, 2017 5:44 pm

Cham wrote:I still don't understand the vertical spacing commands there (there's even a negative -\baselineskip)


When one adds vertical space, the current line ends, since it has to go downwards now. But ending a line means there's a new line with the distance \baselineskip. So, to have a distance of 2pt between the first line and the second, you remove that line skip space, that's why it's negative, then you add 2pt as desired space. I would do it similar or make a macro for it, when it's about several rules.

Stefan
Site admin

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sun Dec 03, 2017 6:00 pm

Then why not simply use something like \vspace{2pt} between each rule ? Would it give a fixed constant space between the thick and thin rules ?

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

Postby Stefan Kottwitz » Sun Dec 03, 2017 6:03 pm

There is a line break between the two rules! LaTeX is line based in normal text mode. So you would have the line break space and 2pt.

Stefan
Site admin

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sun Dec 03, 2017 6:11 pm

Hmm, you're right. I tend to think in a "graphical mode" (with absolute measures), instead of a text mode.

But I still dont understand that part. I feel there should be a simpler way in doing this.

Also, the author's name not vertically centered annoys me and using \vspace{} by hand is clumsy..

EDIT : Okay, I fixed the author's name by simmply adding \vspace{6pt} below it, which is about half the name's height.

Now, how to make the Main title as long as the rules themselves (i.e 4.5 inches) ?
Last edited by Cham on Sun Dec 03, 2017 6:20 pm, edited 1 time in total.

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

Postby Stefan Kottwitz » Sun Dec 03, 2017 6:19 pm

It wasn't centered, you just added space (2 line skips) after the rule before the author.

Centering looks this way:

  1. \rule{4.5in}{1.6pt}
  2. \vfill
  3. Author
  4. \vfill
  5. \includegraphics[width=4.5in]{example-grid-100x100pt}


or inserting equal space before and after.

Sure, there are more logical ways in graphic mode, but in text mode we have to link about text lines. Even \rule is a luxury in text mode.

Stefan
Site admin

User avatar
Cham
Posts: 813
Joined: Sat Apr 02, 2011 4:06 pm

Postby Cham » Sun Dec 03, 2017 6:22 pm

Sorry for the cross-posting. I used
  1. \rule{4.5in}{1.6pt}
  2.  
  3. \vfill {\large Author} \vspace{6pt} \vfill
  4.  
  5. \includegraphics[width=4.5in]{...


and then the output appears to be right. The name is now well centered.

But is it possible to make the main title as long as the rules themselves, i.e 4.5 inches in lenght? In other words: can we stretch a line of text so its lenght have an exact value? There's surely a way in doing this in LaTeX.

EDIT : Damn typos and auto-correctors in the browser! :x


Return to “General”

Who is online

Users browsing this forum: No registered users and 13 guests