Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have been trying to right align the \part in latex, but without any success

Please also take into account the TOC input and the text formatting (fonts, etc. from the whole document). Basically I don't wanna change anything else in the basic part declaration of latex, except right justifying it and use a ":" or "-" instead of the "." at the end of the Part number.

I would also like the page number to be hidden.

Thank you guys!

PS: Unfortunately I can't post a picture of what I have right now.

I have found this code while searching the web:

\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
  \refstepcounter{part}%
  %  add to TOC, but without page number (since this page is not counted)
   \addtocontents{toc}{\protect
      \nonumcontentsline{\numberline{\partname\space\thepart}#1}}
\else
  %  add to TOC, but without page number
  \addtocontents{toc}{\protect\nonumcontentsline{#1}}
\fi
\markboth{}{}%
{\centering
 \interlinepenalty \@M
 \normalfont
 \ifnum \c@secnumdepth >-2\relax
   % part number - UPPERCASE, and make it slightly larger
   \large \bfseries \MakeUppercase{\partname\nobreakspace\thepart}
   \par
   \vskip 20\p@
 \fi
 % part title - make it slightly larger
 \large \bfseries #2\par}%
\@endpart}

But whatever I do, I can't right align it. Tried the flushright environment. My other idea was to put it in a makebox to be aligned.. But that's not possible :(

UPDATE

Using the minipage environment, I was able to right align the \part :-D yuhuu

I have just put the \part inside the minipage environment and played a bit its attributes. It works fine. But the remaining problem is how to get the part number and the title on the same line:

Part I: Title of the first part

share|improve this question
1  
Haven't you forgotten to add your code? To remove the page number try this command \pagestyle{empty}, or this command if you want to remove the number only on one page \thispagestyle{empty} –  Ludovic C. Jun 19 '13 at 12:46
    
Thanks Ludovic! Sorry.. code added –  pro Jun 19 '13 at 12:52

1 Answer 1

Using \raggedleft is sufficient.

\documentclass{book}

\makeatletter
\def\@part[#1]#2{%
  \ifnum \c@secnumdepth >-2\relax
    \refstepcounter{part}%
    %  add to TOC, but without page number (since this page is not counted)
    \addtocontents{toc}{\protect
      \nonumcontentsline{\numberline{\partname\space\thepart}#1}}%
  \else
    %  add to TOC, but without page number
    \addtocontents{toc}{\protect\nonumcontentsline{#1}}%
  \fi
  \markboth{}{}%
  {\raggedleft
   \interlinepenalty \@M
   \normalfont\large\bfseries % <-- Adjust here
   \ifnum \c@secnumdepth >-2\relax
     \large\bfseries\partname\nobreakspace\thepart: %
   \fi
   #2\par}%
  \thispagestyle{empty}% <-- remove the page number
  \@endpart}
\makeatother

\begin{document}
\mainmatter
\part{Title of the first part}
\end{document}

If \large\bfseries is not what you want, change it to suit.

share|improve this answer
    
Thank egreg for the suggestion. However, how can i have the part name, number and title on the same line? thanks –  pro Jun 20 '13 at 8:45
    
@pro They are on the same line. –  egreg Jun 20 '13 at 8:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.