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

Difficulty with title page and logo

Post by Cham »

I'm creating a document for a lesson plan, and I'm having some difficulties in setting up the title page. Here's a working example of the code with the problem :

Code: Select all

\documentclass[12pt,letterpaper,twoside]{article}
\usepackage[T1]{fontenc}
\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[pagestyles,medium]{titlesec}

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

\begin{document}

\begin{titlepage}
\includegraphics[height=0.76666in]{logo.jpg}
\title{\flushleft{\textbf{\textsf{Title of the document}}}}
\maketitle
\date{Winter 2015}
Test
\end{titlepage}

\newpage

\pagestyle{principal}

\section{Titre de section}
Test
\newpage
Test...
\end{document}

Use the logo below (any picture will do for this example) :
logo.jpg
logo.jpg (14.32 KiB) Viewed 11231 times
The logo appears at the right place on the page, but the title is on a second page. How can I make it appearing on the same page as the logo ?

I tried using the package fancyhdr, but then the header is all messed up for the rest of the document. I don't think I really need that package anyway.
Last edited by Cham on Thu Jan 29, 2015 12:00 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
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 »

Hi,

using \maketitle in the titlepage environment is wrong. \maketitle will use the environment on its own, starting a new age, this is what you encounter.

If you want, you can use package titling to hook into the usual macro that defines the titlepage. But it seems to me, that you could be just as satisfied with a custom title page. A while back, i wrote something about it: Customizing a titlepage. The content of that link gives some examples, especially considering KOMA-script and classicthesis, but the overall points are relevant for titlepages in general.

If you want to reuse this titlepage, defining you own \maketitle would be the way to go. So, instead of just using spaces and skips, take the How to make a solid titlepage? approach.

btw: Take a look at package mwe, it comes with some example pictures. Makes minimal example more effective for all of us.
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 »

Ow, thanks for the ultra-fast reply :shock: . I'll look out your suggestion.
User avatar
Cham
Posts: 937
Joined: Sat Apr 02, 2011 4:06 pm

Difficulty with title page and logo

Post by Cham »

Hmmm, there's a code which appears to do what I'm looking for. But it doesn't compile (emergency stop error) ! It's called the The Rock Solid Method, and here's the code for reference :

Code: Select all

%% Copyright (c) 2011 by Markus Kohm <komascript(at)gmx.info>
\documentclass[a4paper,pagesize]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[demo]{graphicx}% remove option demo if you have the logo
\usepackage{xcolor}
\usepackage{titlepage}
\begin{document}
\TitlePageStyle{KIT}
\maketitle[%
  mainlogo={\textcolor{red}{%
      \includegraphics[width=40mm,height=18.5mm]{KITLogo_RGB}}},%
  % You may additionally change titlehead. Original definition of titlehead
  % is:
  titlehead={\usetitleelement{mainlogo}\hspace*{\fill}},%
  title=\textcolor{red}{Titel der Arbeit\\im Stil \texttt{KIT}},%
  subject=\textcolor{red}{Klassifizierung der Arbeit},%
  author=\textcolor{red}{Markus~Kohm},%
  faculty=\textcolor{red}{Fakultät für Informatik},%
  chair=\textcolor{red}{%
    Institute for Program Structures\\and Data Organization (IPA)},%
  advisor={\textcolor{red}{Titel Vorname Nachname}\and
    \textcolor{red}{Titel Vorname Nachname}},%
  referee={\textcolor{red}{Titel Vorname Nachname}\and
    \textcolor{red}{Titel Vorname Nachname}},%
  duration=\textcolor{red}{XX. Monat 20XX -- XX. Monat 20XX},%
  university=\textcolor{red}{\KITlongname},%
  homepage=\textcolor{red}{\KITurl}%
]
\end{document}
What's wrong with it ?

I also looked for the web site which gives a zip file of several examples, but it's all in German !
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 »

If you really want to use that, i can give you some explanations maybe on friday.
But to be honest, this method is useful, if you want to set the titlepage for a whole university or firm. In other words many people using the same style.
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 »

The problem I have is to try to reproduce a document made with Word/Office. I don't want to use Word again, since it's always a pain in the butt to edit its files, each semester.

Here's a typical title-page made with Word, for the departement where I'm working.
title-page.jpg
title-page.jpg (76.08 KiB) Viewed 11189 times
The rest of the document is pretty standard
How should I recreate this title-page in LaTeX ?
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 didn't do the whole titlepage, mainly because the main idea is th same over and over again, on the other hand ... The titlepage you are showing is as ugly as one would suggest do see university course material puked down on paper. Sorry, but that is the main idea, getting some information out, no matter how ugly it looks. If you would provide free typesetters, some people would use those instead of a computer.

Code: Select all

%\RequirePackage{filecontents}
\begin{filecontents}{chamPlanDeCours.sty}
	\NeedsTeXFormat{LaTeX2e}[2012/01/01]
	\ProvidesPackage{chamPlanDeCours}
	\RequirePackage{tcolorbox}
	\RequirePackage{textcase}
	\RequirePackage{xparse}
	\RequirePackage{graphicx}
	\newcommand{\name}[1]{\gdef\@name{#1}\def\thiscourse{{\itshape#1}}}
	\newcommand{\session}[1]{\gdef\@session{#1}}
	\newcommand{\courseplanname}[1]{\gdef\@courseplanname{#1}}
	\newcommand{\@courseplanname}{Plan de Cours}
	\newcommand{\telephone}[1]{\gdef\@telephone{#1}}
	\newcommand{\@telephone}{\raggedright 012 3145 78\\(general advisor)}
	\newcommand{\@competence}{}
	\newcommand{\competence}[1]{\gdef\@competence{#1}}
	\newcommand{\local}[1]{\gdef\@local{#1}}
	\newcommand{\teacher}[1]{\gdef\@teacher{#1}}
	\newcommand{\addcomment}[1]{\gdef\@comment{#1}}
		\newcommand{\numbers}[3]{
		\def\numberone{#1}
		\def\numbertwo{#2}
		\def\numberthree{#3}}
	\NewDocumentCommand{\ponderation}{
		>{\SplitArgument{2}{-}}m}
		{\numbers#1}


	\renewcommand{\maketitle}{%
		\begin{titlepage}
			\sffamily
			\setlength{\parskip}{0pt}\setlength{\parindent}{0pt}\setlength{\parfillskip}{0pt plus 1fil}
			\vspace*{-5\baselineskip}
			\includegraphics[width=.4\textwidth]{example-image-a.pdf}%explicitly
%		use the pdf here
			\par\vspace{2cm}
			\begin{tcolorbox}
				\centering
				\huge \MakeTextUppercase{\@courseplanname}
				\par
				\@name
			\end{tcolorbox}
			\vspace{3ex}
			\begin{description}
				\item [Session:] \@session 
					\vspace{1cm}
			\item [Pond\'eration:]
				\numberone--\numbertwo--\numberthree
				\ifdefempty{\@competence}{}{\item [Competence:] \@competence}
			\end{description}
			\begin{tcolorbox}
				\begin{tabular}{c@{\hspace{3em}}p{0.3\textwidth}@{\hspace{3em}}p{0.3\textwidth}}
					Professor & Telephone & Local \\[1ex]
					\@teacher & \@telephone &
					\raggedright\@local
				\end{tabular}
			\end{tcolorbox}
			\addvspace{4ex}
			\begin{minipage}{\linewidth}
				\@comment
			\end{minipage}
		\end{titlepage}
	}
	\renewcommand*\descriptionlabel[1]{\hspace\labelsep
	\sffamily\bfseries #1}
\endinput
\end{filecontents}


%Now the document starts
\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}

This makes a quite simple titlepage. To be honest, i would even omit the grey boxes. If a student cannot find relevant information on one simple piece of paper, he should consider his decision to study.

Some fields are mandatory, you cannot compile without error if you haven't set them. you could set a warning like in the standard classes.
Some fields can be left empty, and a default replacement text is printed.

Some fields can be left out and if so, the whole line isn't printed using a conditional.


One thing i did out of pure i am used to it and laziness: Mixing up TeX (\def), LaTeX2e (\newcommand) and the user interface of LaTeX3 (\NewDocumentCommand). A titlepage is so simple, that i won't suspect any stuff breaking, but nevertheless, the style is bad.

Please play around a little bit. You can show the final result and i'll take a look at it. I might have improvements to make.


Depending on how static the titlepage appearance should be, you should consider placing hooks for the fonts. Either for the convenience of the end user (which i guess won't have acces to them ;-)) or for your convenience as the maintainer/developer of the titlepage stuff.

When develooping code for yourself and especially for others, there is one question that should ever be in your head: How flexible do i want to be? Or What crazy stuff could the user put here? If you ask a user to say »left« or »right«, you can be sure that at least one out of one hundred says »garden hose« and breaks everything.
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 »

Thanks a LOT for all the efforts ! :shock:

I'll study what you have shown here.

And yes, I fully agree that the original title-page that I've shown is terribly ugly !
(It's a work from Word, heh !)

My whole idea is to create a nicely looking plan to give to the students (not that horrible default stuff from all the other teachers ! :oops:), that I could also edit and update easily on each semester. LaTeX is a must, here.

I really hate the use of Word in Sciences ! :evil:
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 »

It is the same in every field, you cannot expect to work with LaTeX out of the box, you cannot build bridges just because you can read, you cannot run a nuclear power plant because you can add 2 and 2 and don't make mistake. It is the same with Word, i think.

I have seen documents written in Word, and I tought, Well, that's absolutely fine for this kind of document. There were minor things that my LaTeX-eye caught, but the casual reader would never notice that.

What i want to say with that is, you need to know your tool to achieve good results. If you just start hammering in a hurry, you will hit your thumb.
Seems to be a good advice for life in general ;-)
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 »

Hmm, the code you gave above doesn't compile on my computer. It does give a very nice output when I click "OPEN IN WRITELATEX" in the browser, but when I try to compile it with PDFLaTeX on my machine, it gives immediately an error ! :cry:

And to be honest, I don't understand much of the code to be able to fix it myself. :oops:

As I understand it, this code isn't a standard LaTeX code. How could we define the same output using the "usual" LaTeX coding style ?
Last edited by Cham on Sat Jan 31, 2015 7:47 pm, edited 1 time in total.
Post Reply