Text FormattingModify already modified \part-head

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Modify already modified \part-head

Post by svend_tveskaeg »

Hi all.

consider the following MWE:

Code: Select all

\documentclass{article}

\makeatletter
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \Large\bfseries\hfil\partname~\thepart\hfil
       \par\nobreak
     \fi
     \huge \bfseries #2%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\makeatother

\begin{document}

\part{Test}

\end{document}
How do I add to the code above so that the header, i.e. `Test' in this case, gets flushed right instead of left, as it is now? (The `Part 1' part of the header still has to be centred.)

Thank you in advance!

P.S. The code is taken from this post where I asked a similar question some time ago.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Modify already modified \part-head

Post by Stefan Kottwitz »

Hi,

you could write \raggedleft before #2 in the definition. Even \hfill before #2 would be enough if you would know that you would just have single-line titles like this one.

Stefan
LaTeX.org admin
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Re: Modify already modified \part-head

Post by svend_tveskaeg »

So simple, yet I cannot see it. :oops:

Thank you very much!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply