Anzeige:
Ergebnis 1 bis 9 von 9

Thema: Fancy headings

  1. #1
    Registrierter Benutzer
    Registriert seit
    28.09.2007
    Beiträge
    14

    Fancy headings

    I want to create a document using book class. It should include several chapters and I desire to use a fancy style for it as I have seen some time ago in a book.
    It had a special header printed on each page consisting on a continuous line which was interrupted some 1cm from the margin of the page by a box containing the page number.
    Underneath this line the chapter number and the chapter title were displayed.
    I think it was made using fancyhdr package and I have tried to make a *.tex file to reproduce this. I am no expert in LaTeX and I have managed only to create a box containing the pagenumber. I have tried to use \vspace in the header to lower this box and also the chapter name but with no results.
    Does anybody know how it is possible to do it or has seen such a template?

    Thank you so much.
    Razvan

  2. #2
    Registrierter Benutzer
    Registriert seit
    09.07.2004
    Beiträge
    2.365
    This is a german speaking desktop, see http://groups.google.de/group/comp.t...pics?hl=de&lr=

    In my opinion you can try fancyhdr with standard classes or scrpage/scrheadings etc with KOMA class, s. scrguide.pdf

    Perhaps the minimalexample works for you

    \documentclass[a5paper]{book}
    \usepackage{german}
    \usepackage[latin1]{inputenc}
    \usepackage[T1]{fontenc}

    %%%---------------------------------------------------------------------------
    %%% Just_4_demo
    %%%---------------------------------------------------------------------------
    \usepackage{charter,helvet,courier}
    \usepackage{graphicx,xcolor}
    \unitlength=1cm
    \usepackage{showframe}% <<<<<<<<<<<<<<<<<<<< comment out for final output
    \usepackage{blindtext}

    %%%---------------------------------------------------------------------------
    %%% All my fancyhdr specifications
    %%%---------------------------------------------------------------------------
    %\RequirePackage{fancyhdr} % <<<< you can put all spec into a style file
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{}
    \renewcommand{\chaptermark}[1]{\markboth{\thechapter\ #1}{}}
    \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}{}}

    \headheight=25.26106pt% as is Package Fancyhdr Warning
    \lhead[\fancyplain{}{\rule{10mm}{.4pt}\,\fbox{\thepage}\, \hrulefill}]
    {\fancyplain{}{\raisebox{-3ex}\leftmark}}
    \rhead[\fancyplain{}{\raisebox{-3ex}\rightmark}]
    {\fancyplain{}{\hrulefill\,\fbox{\thepage}\,\rule{ 10mm}{.4pt}}}

    \fancyfoot{}%
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}



    \begin{document}
    \frontmatter

    %%%---------------------------------------------------------------------------
    %%% Titelseite
    %%%---------------------------------------------------------------------------
    \begin{titlepage}
    \noindent% unbedingt notwendig <<<<<<<<<<<<<<
    \put(4.35,-3){\color{blue!50!black!100!}\scalebox{4}{fancyhdr }}
    \begin{flushright}
    \vspace*{12pt}\bfseries\Large
    To make an eXtended fancyheader\par\vspace{12pt}
    Edico\par\vfill
    \normalfont\normalsize
    This page is a simple holding-ground\par
    for \LaTeX{}-related tips and tricks.
    \end{flushright}
    \end{titlepage}

    %%%---------------------------------------------------------------------------
    %%% Inhaltsverzeichnis
    %%%---------------------------------------------------------------------------
    \tableofcontents
    \vfill\hfill
    Caution!Put headheight to \the\headheight

    \mainmatter
    %%%---------------------------------------------------------------------------
    %%% Inhalt_Dokument
    %%%---------------------------------------------------------------------------
    \Blinddocument
    \end{document}

    %%% Local Variables:
    %%% mode: latex
    %%% TeX-master: "test"
    %%% End:

    edico
    Geändert von edico (28-09-2007 um 14:58 Uhr) Grund: Deleting spaces in the code :-)

  3. #3
    Registrierter Benutzer
    Registriert seit
    28.09.2007
    Beiträge
    14
    I have seen it is a German forum, but I know only basic german
    Tut mir leid.

    Anyway, thank you for your help. It is exactly what I needed.
    I have made some small changes to make the box containing page number on the middle of the line and also to have constant width through the hole document. It goes like this:


    %%%---------------------------------------------------------------------------
    %%% All my fancyhdr specifications
    %%%---------------------------------------------------------------------------
    %\RequirePackage{fancyhdr} % <<<< you can put all spec into a style file
    \usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{}
    \renewcommand{\chaptermark}[1]{\markboth{\thechapter\ #1}{}}
    \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}{}}

    \headheight=25.62106pt% as is Package Fancyhdr Warning =25.26106pt
    \lhead[\fancyplain{}{\rule{10mm}{.4pt}\,\framebox[30pt]{\raisebox{-0.5ex}\thepage}\,\hrulefill}]
    {\fancyplain{}{\raisebox{-3ex}\leftmark}}
    \rhead[\fancyplain{}{\raisebox{-3ex}\rightmark}]{\fancyplain{}{\hrulefill\,\framebox[30pt]{\raisebox{-0.5ex}\thepage}\,\rule{10mm}{.4pt}}}

    For now I have problems in understanding how the \hrulefill operates. I have thought if I make \rule{10mm}{.4pt} thicker, after the rectangular box, \hrulefill would keep the same thickness. But then I see for the odd pages, \hrulefill command is in front of the \rule one so it cannot take its thikness from there.
    And another question: is it possible to change the color of this line?

    vielen Dank,
    roescu

  4. #4
    Registrierter Benutzer
    Registriert seit
    09.07.2004
    Beiträge
    2.365
    Tut mir leid.
    Ok I'm not bothered ;-)

    Now for transparancy I put all the code into a style file with all my simple ideas to the code. You can suit it as you like.

    In the preamble you declare.
    ....
    \usepackage{fancyrule}
    ...

    %%%
    %%% This is file 'fancyrule.sty',
    %%% generating colored and thick rules and framed page number to the header
    %%%
    %%% Last modified Die Okt 2 09:00:00 CEST 2007
    %%%

    %%% Beginning from the hrulefill definition
    %%% \def\hrulefill{\leavevmode\leaders\hrule\hfill\ker n\z@}
    %%% and the default thickness of rules of 0.4pt
    %%% we define the thickness as difference of |height| and |depth|
    %%% whereas |height| is the key value (|depth| changes vertical alignment)
    %%% (example: |0.8pt| - |0pt| => 8pt thickness)
    \makeatletter
    \newcommand*{\Hrulefill}{%
    \leavevmode\leaders\hrule\@height0.8pt\@depth0pt\h fill\kern\z@}
    \makeatother

    %%% Going on and putting a color of your choice to Hrulefill
    %%% if it's not capsuled, page and frame will be colored too
    \newcommand{\HRuleFCol}{{\color{red}\Hrulefill}}
    \newcommand{\Rule}{{\color{red}\rule{10mm}{.8pt}}}

    \RequirePackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{}
    \renewcommand{\chaptermark}[1]{\markboth{\thechapter\ #1}{}}
    \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}{}}

    \headheight=25.26106pt% as is Package Fancyhdr Warning

    \lhead[\fancyplain{}{\Rule\,
    \framebox[30pt]{\raisebox{-0.5ex}\thepage}\,\HRuleFCol}]
    {\fancyplain{}{\raisebox{-3ex}\leftmark}}
    \rhead[\fancyplain{}{\raisebox{-3ex}\rightmark}]
    {\fancyplain{}{\HRuleFCol\,
    \framebox[30pt]{\raisebox{-0.5ex}\thepage}\,\Rule}}

    \fancyfoot{}%
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}

    \endinput
    %%
    %% End of file `fancyrule.sty'.

    Trara
    edico

  5. #5
    Registrierter Benutzer
    Registriert seit
    28.09.2007
    Beiträge
    14
    It is a good thing to create a style file. I have done it and put in a new folder in the MikTeX folder (I am using this on Windows). After this I have run TEXHASH from command prompt to update the paths.
    When I try to compile :

    \documentclass[12pt, a4paper]{book}
    \usepackage[english]{babel}
    %\usepackage{showframe}
    \usepackage{blindtext}
    \usepackage[inner=3.0cm]{geometry}
    \usepackage{fancyrule}
    % SHOULD I INCLUDE HERE ALSO \usepackage{fancyhdr} ???%%%%%%%%

    % Set equal margins on book style
    \setlength{\oddsidemargin}{53pt} \setlength{\evensidemargin}{53pt}
    \setlength{\marginparwidth}{57pt} \setlength{\footskip}{30pt}
    %--------------------------------------------------------------------------------------------------------

    \begin{document}
    \frontmatter
    %%%---------------------------------------------------------------------------
    %%% Title
    %%%---------------------------------------------------------------------------
    \begin{titlepage}
    \noindent% unbedingt notwendig <<<<<<<<<<<<<<
    %\put(4.35,-3){\color{blue!50!black!100!}\scalebox{4}{fancyhdr }}
    \begin{flushright}
    \vspace*{12pt}\bfseries\Large To make an eXtended
    fancyheader\par\vspace{12pt} Edico\par\vfill \normalfont\normalsize
    This page is a simple holding-ground\par for \LaTeX{}-related tips
    and tricks.
    \end{flushright}
    \end{titlepage}
    %%%


    %%%---------------------------------------------------------------------------
    %%% Inhaltsverzeichnis
    %%%---------------------------------------------------------------------------
    \tableofcontents \vfill\hfill Caution!Put headheight to
    \the\headheight

    \mainmatter
    %%%---------------------------------------------------------------------------
    %%% Inhalt_Dokument
    %%%---------------------------------------------------------------------------
    \chapter{First Chapter}
    \section{First section}\Blindtext
    \section{Second section} \Blindtext
    \section{Third section} \Blindtext
    \chapter{Second Chapter}
    \section{First section}\Blindtext
    \section{Second section} \Blindtext
    \section{Third section} \Blindtext
    \chapter{Third Chapter}
    \section{First section}\Blindtext
    \section{Second section} \Blindtext
    \section{Third section} \Blindtext

    \backmatter

    \end{document}

    I get an error that the *.sty file is not found
    Is there a designed location where fancyrule.sty should be found or can I put it anywhere I want and then use TEXHASH?

    I have attached also the saved fancyrule.sty, maybe I made an error when making it.

    thnx,
    roescu

  6. #6
    Registrierter Benutzer
    Registriert seit
    09.07.2004
    Beiträge
    2.365
    SHOULD I INCLUDE HERE ALSO...
    No -- it's already activated in the stylefile

    \newcommand*{\Hrulefill}{\leavevmode\leaders\hrule \@height0.8pt\@depth0pt\h fill\kern\z@}
    ... line 15, stylefile -- caution! copy&paste (MRUNIX is horrrrrrrrible) produced space! MUST BE 'hfill'
    (perhaps there're still more mistakes ...)

    Texhashing should be ok although I'm not familiar to WIN ...
    But try to put the stylefile into the working directory and compile that should work for you for now ...

    edico

  7. #7
    Registrierter Benutzer Avatar von rais
    Registriert seit
    18.07.2005
    Beiträge
    5.859
    ...and you might want to add
    Code:
    \RequirePackage{xcolor}
    in your fancyrule.sty---somewhere before the definition of \HRuleFCol, i. e., prior to the first call of the \color command.
    Regards,
    Rainer
    There's nothing a good whack with a hammer won't fix!

  8. #8
    Registrierter Benutzer Avatar von countbela666
    Registriert seit
    15.04.2005
    Ort
    Berlin
    Beiträge
    2.317
    Zitat Zitat von edico Beitrag anzeigen
    caution! copy&paste (MRUNIX is horrrrrrrrible) produced space!
    Would not have happened if you'd used the code environment...

    Regards,
    Marcel

    Listen to me children of the night, beyond the doors of darkness you will find
    a thousand worlds for you to see here, take my hand and follow me...

  9. #9
    Registrierter Benutzer
    Registriert seit
    09.07.2004
    Beiträge
    2.365
    @Marcel
    Danke für den Tip

    edico

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •