GeneralGeneric title page needs optimization

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

Generic title page needs optimization

Post by Cham »

This code is already much better. But I still don't understand a few parts :

Code: Select all

\RequirePackage[l2tabu,orthodox]{nag}
\documentclass[12pt,letterpaper,twoside]{article}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
 
\begin{document}
 
% CODE (2) :
\begin{titlepage}
	\centering
	
	\vfill

	Course number

	\vfill

	\rule{4.5in}{1.6pt}\vspace*{-\baselineskip}\vspace*{2pt}
	\rule{4.5in}{0.4pt}\\[\baselineskip]
		{\Huge\textsc{Book title}}\\[1\baselineskip]
		{\large Subtitle}\\[0.2\baselineskip]
	\rule{4.5in}{0.4pt}\vspace*{-\baselineskip}\vspace{3.2pt}
	\rule{4.5in}{1.6pt}\\[2\baselineskip]
	
	Author
	\vspace{0.5in}
			
	\includegraphics[width=4.5in]{example-grid-100x100pt}

	\vfill

	version, town, year.
\end{titlepage}
 
\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.

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Generic title page needs optimization

Post by Stefan Kottwitz »

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
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Generic title page needs optimization

Post by Stefan Kottwitz »

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
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Generic title page needs optimization

Post by Cham »

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) :

Code: Select all

\rule{4.5in}{1.6pt}\vspace*{-\baselineskip}\vspace*{2pt}
	\rule{4.5in}{0.4pt}\\[\baselineskip]
		{\Huge\textsc{Book title}}\\[1\baselineskip]
		{\large Subtitle}\\[0.2\baselineskip]
	\rule{4.5in}{0.4pt}\vspace*{-\baselineskip}\vspace{3.2pt}
	\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: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Generic title page needs optimization

Post by Stefan Kottwitz »

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
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Generic title page needs optimization

Post by Cham »

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: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Generic title page needs optimization

Post by Stefan Kottwitz »

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
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Generic title page needs optimization

Post by Cham »

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: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Generic title page needs optimization

Post by Stefan Kottwitz »

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

Centering looks this way:

Code: Select all

\rule{4.5in}{1.6pt}
\vfill 
Author
\vfill
\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
LaTeX.org admin
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Generic title page needs optimization

Post by Cham »

Sorry for the cross-posting. I used

Code: Select all

\rule{4.5in}{1.6pt}

\vfill {\large Author} \vspace{6pt} \vfill

\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
Post Reply