Page LayoutHow does the \tocenter package work?

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Sille
Posts: 6
Joined: Fri Mar 18, 2011 4:47 pm

How does the \tocenter package work?

Post by Sille »

Hi,

I am trying to center my titlepage with the command \tocenter. Untill now I have figure out that I should add

Code: Select all

\tocenter[hfm]{\textwidth}{\textheight}
to the preamble. But how to apply it on the titlepage?
I have read the documentation but it is not making my any wiser.
I hope that someone can help me, thanks.
Last edited by Sille on Sun Mar 27, 2011 1:46 pm, edited 1 time in total.

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Frits
Posts: 169
Joined: Wed Feb 02, 2011 6:02 pm

Re: How does the \tocenter package work?

Post by Frits »

Why don't you just use the \centering command?
howtoTeX.com - Your LaTeX resource site (Tips, Tricks, Templates and more!)
Follow howtoTeX on twitter
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

How does the \tocenter package work?

Post by torbjorn t. »

I think it applies only to entire documents, not a specific part of a document.

To put a title in the middle of the typearea, one option is to do like this:

Code: Select all

\documentclass{article}
\begin{document}
\begin{titlepage}
\centering
\vspace*{\fill}
THIS IS A TITLE
\vspace*{\fill}
\end{titlepage}
\end{document}
P.S. LaTeX commands are case sensitive, so \tocenter is not the same as \ToCenter. The package defines the latter.
Sille
Posts: 6
Joined: Fri Mar 18, 2011 4:47 pm

Re: How does the \tocenter package work?

Post by Sille »

Sorry, I think I forgot to tell you that the titlepage is already centered due to the margins. But since the margin is bigger in one of the sides, because I am using twoside I was wondering if it could be placed in the middle of the page without using the margins. Hope you understand.

I have tried with the geometry package but it mess up the entire document and then I read about the \ToCenter command, but can't figure out how it works.
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

How does the \tocenter package work?

Post by torbjorn t. »

I see. Again, I don't think the tocenter package works as you would like it to, but the following code should do the trick, I think. Use it instead of a titlepage environment.

Code: Select all

\newlength{\centeroffset}
\setlength{\centeroffset}{-0.5\oddsidemargin}
\addtolength{\centeroffset}{0.5\evensidemargin}
\thispagestyle{empty}
%\vspace*{\stretch{1}}
\noindent\hspace*{\centeroffset}\begin{minipage}{\textwidth}
  \begin{center}
%    Insert title stuff here.
  \end{center}
\end{minipage}
I didn't write this myself, it was copied from some page on the internet a long time ago. I can't remember where I found it though, or who wrote it.
Sille
Posts: 6
Joined: Fri Mar 18, 2011 4:47 pm

How does the \tocenter package work?

Post by Sille »

Thank you, that will give a nice result.
But when I try to insert some pictures, I get 4 errors.
Here is what I have tried

Code: Select all

\newlength{\centeroffset}
\setlength{\centeroffset}{-0.5\oddsidemargin}
\addtolength{\centeroffset}{0.5\evensidemargin}
\thispagestyle{empty}
%\vspace*{\stretch{1}}
\noindent\hspace*{\centeroffset}\begin{minipage}{\textwidth}
  \begin{center}
\Large Master's Thesis
\newcommand{\HRule}{\rule{\textwidth}{0.5mm}}
\vspace*{\stretch{1}} \HRule\\[1cm]\Huge\bfseries
 Title
\\[0.5cm]
\HRule\\[0.5cm]
\large name, number\\[0.8cm]
\begin{figure}
	\centering
		\includegraphics[width=\textwidth]{figurer/16bib.pdf}
\end{figure}
\vspace*{\stretch{2}} \normalsize %
\today 
\begin{figure}
	\centering
		\includegraphics{figurer/logo.JPG}
	\label{fig:logo}
\end{figure}
  \end{center}
\end{minipage}
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

How does the \tocenter package work?

Post by torbjorn t. »

You cannot have a float, e.g a figure environment, within a minipage. But you don't need it on a titlepage. You do not have a caption, and the image doesn't have to float. If you just remove the figure environment, \centering commands and \labels it will work fine. Just remember to add a linebreak after \today.

Code: Select all

\documentclass{report}
\usepackage[demo]{graphicx}
\newcommand{\HRule}{\rule{\textwidth}{0.5mm}}

\begin{document}
\newlength{\centeroffset}
\setlength{\centeroffset}{-0.5\oddsidemargin}
\addtolength{\centeroffset}{0.5\evensidemargin}
\thispagestyle{empty}
%\vspace*{\stretch{1}}
\noindent\hspace*{\centeroffset}\begin{minipage}{\textwidth}
  \begin{center}
\Large Master's Thesis
\vspace*{\stretch{1}} \HRule\\[1cm]\Huge\bfseries
Title
\\[0.5cm]
\HRule\\[0.5cm]
\large name, number\\[0.8cm]
      \includegraphics[width=\textwidth]{figurer/16bib.pdf}
\vspace*{\stretch{2}} \normalsize %
\today \\
      \includegraphics{figurer/logo.JPG}
  \end{center}
\end{minipage}
\end{document}
As I don't have the images, I added the demo option to the graphicx package, which replaces the images with black rectangles.
Sille
Posts: 6
Joined: Fri Mar 18, 2011 4:47 pm

Re: How does the \tocenter package work?

Post by Sille »

Thank you so much, you saved my day - it's working :)
Post Reply