Page LayoutDifficulty with title page and logo

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Difficulty with title page and logo

Post by Johannes_B »

What kind of error are you getting? Can you upload the log file of my example?

Where are you loosing track? I can explain the parts in more detail.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Difficulty with title page and logo

Post by Cham »

Well, I don't understand the whole code, except the small part at the bottom. It doesn't look like a standard LaTeX code to me.

Even the error message is alien to me ! I don't even know what is a sty file. How should I use the large part of the "alien" code ? I suspect I need to add it to a new file (chamPlanDeCours) with the .sty extension and put it somewhere.

I found a partial solution that appears to be working great. But I need help in setting a proper code, before I start the whole writing process (I don't want to accumulate code mistakes).

Also, the output style is, well, not ideal yet. The vertical spacing and the font styles are arbitrary, so the output is pretty ugly. Of course, this is just a draft.

Code: Select all

\documentclass[12pt,letterpaper,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{setspace}
\setstretch{1.0}
\raggedbottom
\usepackage{graphicx}
\usepackage{mdframed}
\usepackage[dvipsnames,table]{xcolor}
\usepackage{tabto}
\usepackage[pagestyles,medium]{titlesec}

\newpagestyle{principal}{
	\sethead[\thepage][][\itshape\footnotesize\MakeUppercase{\thesection. \sectiontitle}]{\itshape\footnotesize\MakeUppercase{\thesection\ \sectiontitle}}{}{\thepage}
	\headrule
}

\begin{document}

% The title page :
  \begin{titlepage}

	%\flushleft{\includegraphics[height=0.76666in]{logo.jpg}} \\[1in]

	\begin{mdframed}[
		linecolor=gray,
		backgroundcolor=gray!10,
		linewidth=3pt,
		leftmargin=1cm,
		rightmargin=1cm,
		topline=true,
		bottomline=true,
		leftline=false,
		rightline=false
		]
		\center{\textsf{\Large PLAN DE COURS}} \\[0.25in]
		\center{\textbf{\textsf{\Large Ondes et physique moderne}}} \\[0.1in]
	\end{mdframed}

	\flushleft{
		\textsc{Numéro du cours : \tabto{2in} \textbf{203-NYC-05}} \\[12pt]
		\textsc{Pondération : \tabto{2in} \textbf{3-2-3}} \\[12pt]
		\textsc{Compétence visée : \tabto{2in} \textbf{Texte à changer}} \\[12pt]
		\textsc{Programme : \tabto{2in} \textbf{Sciences de la nature (200.BO)}} \\[12pt]
		\textsc{Département : \tabto{2in} \textbf{Physique}} \\[12pt]
		\textsc{Session : \tabto{2in} \textbf{Hiver 2015}} \\[12pt]
		\textsc{Préalable : \tabto{2in} \textbf{Mécanique (203-NYA-05)}} \\[1in]
	}

	\begin{mdframed}[
		linecolor=gray,
		backgroundcolor=gray!10,
		linewidth=3pt,
		leftmargin=1cm,
		rightmargin=1cm,
		topline=true,
		bottomline=true,
		leftline=false,
		rightline=false
		]
		{\textsf{Professeur \tabto{2in} Local \tabto{3in} Téléphone}} \\[0.1in]
		\textbf{\textsf{John Doe}} \tabto{2in} C3510 \tabto{3in} (514) 696-2828 \\[0.1in]
		\textbf{\textsf{Bozo the Clown}} \tabto{2in} C3910 \tabto{3in} (514) 111-0000 \\[0.1in]
	\end{mdframed}

	\centering
	\vfill
	\large
    \emph{Une phrase idiote à changer.}

  \end{titlepage}

% The main text :
\newpage

\pagestyle{principal}

\section{Titre de section}

Test

\newpage

Test...

\end{document}
What do you think of this code ? Take note that I commented out the logo commands, just because of the missing picture. I don't know how to add a command to use a generic logo.jpg, so it could compile here.

What would you suggest to optimize it, and make a better output ?

I would like to have an output similar to what your code is giving.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Difficulty with title page and logo

Post by Johannes_B »

A sty-file is a package file, a package provides some functionality. You are using packages without being aware of that. fancyhdr, amsmath, mathtools, mdframed, alle these are packages with the ending sty. In more generic terms, everything you can load by typing \usepackage exists with the file-ending sty.

With the filecontents-environment, LaTeX gives us a tool that writes its contents to a new file, specified by the name in the curly brackets. In my example, it was chamPlanDeCours.sty mainly because i couldn't think of a better name. This package pretty much works like any other package, or does what the article class does as well when you are using author or title. Those commands are pretty easy to remember. They work pretty much the same, you say \author{cham}. Now the code takes cham and saves this within macro \@author, an internal command.
All of these commands overwrite anything that might have previously been saved. That is useful, we can set default values, for example i used a default value for the phone number to reach the local administrative unit. If you should forget to set a number, there will be some number of a person who might be able to help.

Leter, we redefine the maketitle command. This is pretty much the same as you did in you titlepage-environment (which i use as well above). But when you say »place here {CHAM}« my code above is fixed to »set here {@author}«. The user (or you) just has to remember the keywords like author, competence, ponderation or whatever you want to call them. Of course, as any package, you should write some documentation that leads the user how to use the package. Here, this would just be a list of the available fields (name, poderation, etc.).
In other words, you are giving the user (yourself) some sort of form to fill out. The order in which you type in the fields is unimportant, as the package that defines the titlepage defines the position on the page.

You used mdframed, i used tcolorbox. To be honest, you could use a primitive fbox if you just want to have a frame. Feel free to choose what you want. :-)

For the contents of the field, like 3-2-3- oder Hiver 2015 you tried to use bold-face small caps, which are not available. LateX at this points decides to do a workaround just to use bold face and omit the sc and issues a warning to inform you about this. You could use KOMA-scripts labeling environment as well.


I'll take another look at the titlepage merging the things by you and me. But one thing is important, which error message did you get?
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: 937
Joined: Sat Apr 02, 2011 4:06 pm

Re: Difficulty with title page and logo

Post by Cham »

In my previous code, the logo appears a bit too low on the title page.

How to make it on top of the page (just under the top margin) ?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Difficulty with title page and logo

Post by Johannes_B »

I'll address this in the next post, but please see my post above :-)

you just missed it
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: 937
Joined: Sat Apr 02, 2011 4:06 pm

Difficulty with title page and logo

Post by Cham »

Johannes_B wrote:But one thing is important, which error message did you get?
After pasting your .sty code to a file named chamPlanDeCours.sty (which sits in the same directory than the main .tex file), I'm getting several compiling errors. Most of them are like this :

"Undefined control sequence \name"

and almost each line in the following code has a similar error message (this code is in my main .tex file) :

Code: Select all

\documentclass{article}
\usepackage{chamPlanDeCours}%Load the titlepage
\name{Ondes et physique moderne}
\session{Summer 2015}
\teacher{Cham}
\ponderation{3-2-3}
%\telephone{chams number}
%\competence{A kind of common sense}
\local{Central building\\Room 101\\Northeast Avenue\\Not Paris}

\addcomment{There is a lot to learn in \thiscourse, there are
        \numberone{} points available for the written test.
}

\begin{document}
\maketitle
\end{document}
All the rest of your code were pasted inside the .sty file.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: Difficulty with title page and logo

Post by Johannes_B »

Have you selected my first example (simply click the button to mark it all) and copied it to you favourite LaTeX editor and run it?

I think what might have happened here is copying it, savin it and Windows added some other extension to it. Can you show the log file of the code you just showed us?

btw: it works perfectly for me ;-)
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: 937
Joined: Sat Apr 02, 2011 4:06 pm

Difficulty with title page and logo

Post by Cham »

Johannes_B wrote:Have you selected my first example (simply click the button to mark it all) and copied it to you favourite LaTeX editor and run it?

I think what might have happened here is copying it, savin it and Windows added some other extension to it. Can you show the log file of the code you just showed us?
I'm working on OS X. The file extensions should be okay (.tex for the main file, and .sty for the package). I used the complete code you gave on page 1, and saved the large block to the .sty file, and the small code shown above to the main .tex file.

I think I prefer to not use any .sty file. My code above is giving a good result, and it's very easy to edit and adjust. And I do understand that code ! (which is very important to me !)

Now, I need to adjust two things and I don't know how :

1. The logo picture is too low, and should be right on top-left of the page (just under the margin).

2. The teachers part at the bottom is ugly : the "local" number should be centered (or better ?) and the phone numbers should be flushed to the right, as shown on the picture below :
pict.jpg
pict.jpg (35.75 KiB) Viewed 5769 times
I'm currently using the tabto package, which may not be ideal.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Difficulty with title page and logo

Post by Johannes_B »

I am a bit confused, so far you have been presenting quite complex (at least for me) mathematical stuff, so i thought you could figure out something as simple as a title page.

You can change the position of the logo using vspace and hspace, meaning vertical space and horizontal space. As in real life you can have negative spaces.

Concerning the information at the bottom, simply use a table, like i did in my example.
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: 937
Joined: Sat Apr 02, 2011 4:06 pm

Difficulty with title page and logo

Post by Cham »

Johannes_B wrote:I am a bit confused, so far you have been presenting quite complex (at least for me) mathematical stuff, so i thought you could figure out something as simple as a title page.

You can change the position of the logo using vspace and hspace, meaning vertical space and horizontal space. As in real life you can have negative spaces.

Concerning the information at the bottom, simply use a table, like i did in my example.
Well, maths is very natural to me. I find it much simpler and logical (even in general relativity !) than arbitrary looking syntax and commands for a computer software. I'm not a programmer nor a computer engineer. But that is irrelevent here.

About the logo, I knew that I could use a negative value with the \vspace command, but it doesn't look like the right thing to do, since I couldn't tell if the logo reaches the top of the page. I don't want it to cross the margin.

How could I place the top side of the logo right on the margin border ?

In other words : where is the following command places the logo, on the vertical axis ?

Code: Select all

\flushleft{\includegraphics[height=0.6in]{logo.jpg}}

(sorry if I sound dumb ! My avatar represents me very well ! :oops: )
Post Reply