Featured Book

LaTeX Beginners Guide

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: No registered users and 3 guests

Partner Sites

TeXwelt - Fragen und Antworten goLaTeX
TeXblog
TeXnicCenter
TeXample

Add a period after a heading's numbering in the memoir class

Add tags Information and discussion about specific document classes and how to create your own document classes.

Add a period after a heading's numbering in the memoir class

Postby charlax on Mon Apr 20th, 2009

Hi everybody,

I am using the memoir class, I don't know if this is right so I can change if your solution requires it. I want to add a period after a heading's numbering. Instead of:

A Chapter one

I would like to get:

A. Chapter one

I tried:

Code: Select all  •  Open in writeLaTeX
\chapterstyle{section}
\renewcommand{\afterchapternum}{.\space
}


But I get an extra space after the heading numbering:

A . Chapter one

Do you have an idea?

In the mean time, I would the same appearance in the TOC. Even with my modification, I still get the following line in the TOC:

A Chapter one........................................... 1

Thank you very much,

Charles
charlax
 
Posts: 11
Joined: Mon Apr 20th, 2009

Re: Add a period after a heading's numbering in the memoir class

Postby Stefan_K on Mon Apr 20th, 2009

Hi Charles,

welcome to the board!
Instead of redefining \afterchapnum you could redefine \thechapter:
Code: Select all  •  Open in writeLaTeX
\renewcommand*\thechapter{\Alph{chapter}.}

Stefan
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6377
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Add a period after a heading's numbering in the memoir class

Postby charlax on Mon Apr 20th, 2009

Hi Stefan,

Thank you for your answer, but now I get this in the header:

A.. Chapter one

Isn't there way to set the period after the number only in headings (and TOC)?
charlax
 
Posts: 11
Joined: Mon Apr 20th, 2009

Re: Add a period after a heading's numbering in the memoir class

Postby Stefan_K on Mon Apr 20th, 2009

charlax wrote:Isn't there way to set the period after the number only in headings (and TOC)?


For sure there is, but because there are many possible settings with the memoir class just show us your settings (preamble or minimal working example), the behavior above is not default.

Stefan
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6377
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Add a period after a heading's numbering in the memoir class

Postby charlax on Mon Apr 20th, 2009

Here is my preamble :
Code: Select all  •  Open in writeLaTeX
\documentclass[10pt,a4paper,extrafontsizes,twoside]{memoir}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}

\usepackage{calayout
}


Here is my calayout.sty:
Code: Select all  •  Open in writeLaTeX
%% calayout.sty         \copyright Charles-Axel Dein 2009
%% Licensed under CC BY-SA
\ProvidesPackage{calayout}[2009/04/20]

% PACKAGES
\usepackage{cacommands}
\usepackage{indentfirst
} % ident on first line of par, even after headings
\usepackage{url}
\usepackage{hyperref
} % create links in the document
\usepackage{textcomp}
\usepackage[T1]{fontenc}
\usepackage{graphicx
} % to insert images


% LAYOUT

\settrimmedsize{297mm}{210mm}{*}
\setlength{\trimtop}{0pt}
\setlength{\trimedge}{\stockwidth}
\addtolength{\trimedge}{-\paperwidth}
\settypeblocksize{634pt}{448.13pt}{*}
\setulmargins{4cm}{*}{*}
\setlrmargins{*}{*}{1.5}
\setmarginnotes{17pt}{51pt}{\onelineskip}
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{*}{2\onelineskip}{*}
\checkandfixthelayout

\renewcommand{\rmdefault}{bch}

\setsecnumdepth{paragraph
} % Numbering down to...

%%% HEADERS & FOOTERS
\pagestyle{ruled} % try also: empty , plain , headings , ruled , Ruled , companion

\chapterstyle{section}
\renewcommand*\thechapter{\Alph{chapter}.}
\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\arabic{subsection}}
\renewcommand{\thesubsubsection}{\arabic{subsection}.\arabic{subsubsection}}
\renewcommand{\theparagraph}{\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}
}

% TOC
\setcounter{tocdepth}{3} % TOC down to...
\setlength{\cftbeforesectionskip}{5pt}

% Abstract
\renewcommand{\abstractnamefont}{\chaptitlefont}
\renewcommand{\abstractname}{Executive Summary
}


Here is my cacommands.sty:
Code: Select all  •  Open in writeLaTeX
%% cacommands.sty       copyright Charles-Axel Dein 2009
%% Licensed under CC BY-SA
\ProvidesPackage{cacommands}[2009/04/20]

\usepackage{hyperref}

\newcommand{\email}[1]{\href{mailto:#1}{\nolinkurl{#1}}
}

% Une commande sembleble à \rlap ou \llap, mais centrant son argument
\def\clap#1{\hbox to 0pt{\hss #1\hss}}%
% Une commande centrant son contenu (à utiliser en mode vertical)
\def\ligne#1{%
  \hbox to \hsize{%
    \vbox{\centering #1}}}%
% Une comande qui met son premier argument à gauche, le second au
% milieu et le dernier à droite, la première ligne ce chacune de ces
% trois boites coïncidant
\def\haut#1#2#3{%
  \hbox to \hsize{%
    \rlap{\vtop{\raggedright #1}}%
    \hss
    \clap{\vtop{\centering #2}}%
    \hss
    \llap{\vtop{\raggedleft #3}}}}%
% Idem, mais cette fois-ci, c'est la dernière ligne
\def\bas#1#2#3{%
  \hbox to \hsize{%
    \rlap{\vbox{\raggedright #1}}%
    \hss
    \clap{\vbox{\centering #2}}%
    \hss
    \llap{\vbox{\raggedleft #3}}}}%
% La commande \maketitle
\def\maketitlememoire{%

\calccentering{\unitlength}
\begin{adjustwidth*}{\unitlength}{-\unitlength
}
  %\thispagestyle{empty}\vbox to \vsize{%
    \haut{}{\@blurb}{}
    \vfill
    \ligne{\Huge \@title}
    \vspace{10mm}
    \ligne{\Large \@author}
    \vspace{1mm}\ligne{\small \email{\@emailaddress}}
    \vspace{1cm}
    \vfill
    \vfill
    \bas{}{\@location, \@date}{
}
  %  }%
    \end{adjustwidth*}

  \cleardoublepage
 
}
% Les commandes permettant de définir la date, le lieu, etc.
\def\date#1{\def\@date{#1}}
\def\author#1{\def\@author{#1}}
\def\title#1{\def\@title{#1}}
\def\location#1{\def\@location{#1}}
\def\blurb#1{\def\@blurb{#1}}
\def\emailaddress#1{\def\@emailaddress{#1}
}
% Valeurs par défaut
\date{\today}
\author{}
\title{}
\location{}
\blurb{}
\emailaddress{no email address
}


I'm looking at what could change the default behaviour...
charlax
 
Posts: 11
Joined: Mon Apr 20th, 2009

Re: Add a period after a heading's numbering in the memoir class

Postby Stefan_K on Mon Apr 20th, 2009

With this minimal example I'm getting the period correctly without changes:
Code: Select all  •  Open in writeLaTeX
\documentclass[10pt,a4paper,extrafontsizes,twoside]{memoir}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}

\usepackage{calayout}

\begin{document}
\tableofcontents
\chapter{Test}
text
\end{document
}

Perhaps you don't need to change anything, because it's done in those style files?

Stefan
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6377
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Add a period after a heading's numbering in the memoir class

Postby charlax on Mon Apr 20th, 2009

Yes, but then when you begin a new odd page:
Code: Select all  •  Open in writeLaTeX
\documentclass[10pt,a4paper,extrafontsizes,twoside]{memoir}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}

\usepackage{calayout}

\begin{document}
\tableofcontents
\chapter{Test}
text
\clearpage

Test
\end{document
}


You get an extra period in the header.
charlax
 
Posts: 11
Joined: Mon Apr 20th, 2009

Re: Add a period after a heading's numbering in the memoir class

Postby Stefan_K on Mon Apr 20th, 2009

Ah, ok, in that case let's redefine the \chaptermark macro:
Code: Select all  •  Open in writeLaTeX
\makeatletter
\renewcommand*\chaptermark[1]{%
  \markboth{%
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \thechapter\ %
      \fi
    \fi
    #1}{}%
}
\makeatother

The original \chaptermark has a period after \thechapter inside its definition.

Stefan
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6377
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Re: Add a period after a heading's numbering in the memoir class

Postby charlax on Mon Apr 20th, 2009

Thanks Stefan, it's working now. I'm a beginner, but could we consider this behaviour a bug in the memoir class? Wouldn't it be more logical to have the numbering definition (including the period) in only one place?

I'm now trying to have the same with section, I try to replicate your code but I get nothing in the header where the section title should appear...

Here is what I tried:
Code: Select all  •  Open in writeLaTeX
\renewcommand*\chaptermark[1]{%
  \markboth{%
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \thechapter\ %
      \fi
    \fi
    #1}{}%
}
%%% THE SAME FOR SECTION
\renewcommand*\sectionmark[1]{%
  \markboth{%
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \thesection\ %
      \fi
    \fi
    #1}{}%
}
charlax
 
Posts: 11
Joined: Mon Apr 20th, 2009

Re: Add a period after a heading's numbering in the memoir class

Postby Stefan_K on Mon Apr 20th, 2009

I'm considering the period inside \chaptermark as bad code too. Regarding \sectionmark, its original definition with ruled pagestyle (inside \@ruledmarks of memoir.cls) is
Code: Select all  •  Open in writeLaTeX
\def\sectionmark##1{\markright{##1}}

and you could redefine it in your document this way:
Code: Select all  •  Open in writeLaTeX
\renewcommand*\sectionmark[1]{\markright{\thesection\ #1}}


Stefan
LaTeX Community Administrator
User avatar
Stefan_K
Site Admin
 
Posts: 6377
Joined: Mon Mar 10th, 2008
Location: Hamburg, Germany

Next

Return to Document Classes

Who is online

Users browsing this forum: No registered users and 3 guests