Text FormattingCenter 'Page' over page number in TOC.

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
rjkern
Posts: 4
Joined: Fri Sep 21, 2012 7:04 am

Center 'Page' over page number in TOC.

Post by rjkern »

Hi, I know how to get the word 'Page' over my page numbers in my toc, but I want to center it over the page numbers. Right now the word 'Page' is flush on the right margin.

Also, how can I get the word 'Figure' to appear above my figure numbers in my table of figures?

Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Center 'Page' over page number in TOC.

Post by cgnieder »

Hi rjkern,

Welcome to the LaTeX community!

Would you please add a Infominimal working example (please follow the link if you don't know what it is) so we can show the correct solution for your case. Often there is more than one way and which one very often depends on the actual document and its settings.

Regards
site moderator & package author
rjkern
Posts: 4
Joined: Fri Sep 21, 2012 7:04 am

Center 'Page' over page number in TOC.

Post by rjkern »

I'll be honest, I don't know a lot of LaTeX. Most of my document is built in a template file that was provided to me by the graduate office of my school. Here is how I'm generating the ToC and ToF.

Code: Select all

\addtocontents{toc}{~\hfill\textbf{Page}\par}
\addtotoc{Title Page}{\maketitle}          % Generate the title page
\doublespacing                             % Text should be double spaced
\setcounter{page}{2}                       % Abstract begins on page 2
\addtotoc{Abstract}{\input{abstract.tex}}  % Generate the abstract

\singlespacing                             % Single space the lists
\tableofcontents \clearpage                % Generate the Table of Contents

\addtocontents{lof}{~\hfill\textbf{Page}\par}
\addtotoc{List of Figures}{\listoffigures} % Generate the List of Figures
Here is what it produces.
ToC.png
ToC.png (25.35 KiB) Viewed 4512 times
LoF.png
LoF.png (24.47 KiB) Viewed 4512 times
I want the word 'Page' to be centered over the page numbers and For the table of figures, I want the word 'Figure' to be left aligned above my figure numbers.
Last edited by localghost on Sat Sep 22, 2012 6:47 pm, edited 1 time in total.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Re: Center 'Page' over page number in TOC.

Post by Stefan Kottwitz »

Hi rjkern,

welcome to the board!

Did you see this in good books? Centering "Page" over page numbers of variable width? You have arabic numbers with a single digit and I guess probably also larger numbers, and roman numbers of varying width, such as i and iv which we can see. So, do you want a centered position in relation to some single digit (even i is thinner than 2), or regarding two or three digits or numbers such as viii?

Consequently, all numbers should be centered below "Page", but it results in a ragged right margin.

The simple solution is, to keep it flush right. This is consistent with the full justification of LaTeX in general: a straight left text edge, a straight right edge.

Do you agree, or how exactly do you desire the centering then?

Stefan
LaTeX.org admin
rjkern
Posts: 4
Joined: Fri Sep 21, 2012 7:04 am

Re: Center 'Page' over page number in TOC.

Post by rjkern »

The Manuscript Review Office at my University requires the word 'Page' to be centered over the page numbers. Otherwise I'd just leave it as is. I think as long as it is relatively centered over that column it should be fine.
rjkern
Posts: 4
Joined: Fri Sep 21, 2012 7:04 am

Re: Center 'Page' over page number in TOC.

Post by rjkern »

Please, does anyone have a suggestion I can try? I really need to get this in and I can't seem to find how to do this anywhere.
bebelher
Posts: 2
Joined: Wed Sep 26, 2012 9:16 am

Center 'Page' over page number in TOC.

Post by bebelher »

Hi,

You can try this, it does the trick :

Code: Select all

\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{blindtext}


\def\clap#1{\hbox to 0pt{\hss #1\hss}}% like \rlap or \llap, but centered
\newcommand{\mypage}{\clap{Page~~}}% unbreakable spaces are needed to adjust centering of the "Page" word

\addtocontents{toc}{\hfill{\bfseries\mypage}\par\nobreak}

\begin{document}

\tableofcontents

\blinddocument

\end{document}
Post Reply