Page Layout[Help with legacy code] \spacefactor and vertical mode

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
robertoneto123
Posts: 13
Joined: Thu Sep 25, 2008 1:20 pm

[Help with legacy code] \spacefactor and vertical mode

Post by robertoneto123 »

Hello,

I'm trying to understand a piece of a legacy code of a style file that I should use on my document. But I'm getting the error You can't use `\spacefactor' in vertical mode \section. Since it should be working, I believe that is some stupid thing that I'm missing.

Does anyone had this problem? I believe that is a very quickly fix, but I have no clue of how to solve it...

Thanks!

Code: Select all

\renewcommand{\section}{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\fontsize{15}{12}\fontfamily{phv}\fontseries{bc}\selectfont}}
The full style file is:

Code: Select all

\let\footruleskip\undefined
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage[brazil]{babel}
\usepackage{color}
\usepackage{fancybox, epic, ifthen}
\usepackage[authoryear]{natbib}
\usepackage[font=small,format=hang,singlelinecheck=false,skip=12pt,labelsep=quad,labelfont=bf]{caption}
\usepackage{concrete}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[letterpaper]{geometry}
\addto\captionsbrazil{\renewcommand\indexname{Índice Remissivo}}
\addto\captionsbrazil{\renewcommand\chaptername{UNIDADE}}
\definecolor{cinzauab}{gray}{0.73}
\newcommand{\tracocima}{{\color{cinzauab}\rule[1cm]{\paperwidth}{1.5cm}}}
\newcommand{\tracobaixo}{{\color{cinzauab}\rule[-2cm]{\paperwidth}{1.5cm}}}
\def\@makechapterhead#1{%
  \thispagestyle{empty}%
  \vspace*{5.55cm}%
  \hspace*{-2.9cm}
  \tracocima
  \vspace*{0.5cm}
  \hspace*{0.4cm}{\fontsize{38}{12}\fontfamily{phv}\fontseries{bc}\selectfont \chaptername \space \thechapter}\par
  \vspace*{2.4cm}
  \noindent\hspace*{0.3cm}{\huge #1}\par
  \vspace*{1in}
  \hspace{-2.9cm}
  \tracobaixo
  \pagebreak
  \newpage \thispagestyle{empty}\null \newpage
}

\makeatletter
\fancyput(0cm,0cm){ 
		\ifthenelse{\c@section<1}%
%		\ifthenelse{2<1}%
           {}%
           {\ifthenelse{\isodd{\thepage}}%
           {{\dottedline{2}(383,70)(383,-691)(550,-691)}}%
           {{\dottedline{2}(87,70)(87,-691)(-70,-691)}}
           }}%
\makeatother
\fancyhead{}%
\fancyfoot{}%
\fancyfoot[RO]{\vspace*{-1cm}{\large\thepage}\hspace*{-4.7cm}}
\fancyfoot[LE]{\vspace*{-1cm}\hspace*{-4.8cm}{\large\thepage}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\section}{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\fontsize{15}{12}\fontfamily{phv}\fontseries{bc}\selectfont}}
The tex file calling it is:

Code: Select all

\documentclass[twoside, openright]{article}
\usepackage{tavares}

\author{NAME OF AUTHOR}
\author{NAME OF AUTHOR}
\title{TITLE OF BOOK}
\date{}


\begin{document}
\let\cleardoublepage\clearpage


\maketitle
%\chapter{teste}

f
gfgdfg

\chapter{test}

\section{aaaa}

\lipsum
%\input{Capitulo_1.tex\end{document}
\end{document}

Recommended reading 2024:

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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

[Help with legacy code] \spacefactor and vertical mode

Post by Stefan Kottwitz »

That's the same thing as in the previous post. There's an @ in the macro name.

Simply move the \makeatletter command upwards, so that it stands above def\@makechapterhead#1{% and the \makeatotherer command below that \renewcommand{\section}{\@startsection... redefinition.

\makeatletter must come before the first @ in the preamble, \makeatotherer after the last @, so in-between the undesirable meaning of @ would be changed.

Stefan
LaTeX.org admin
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

[Help with legacy code] \spacefactor and vertical mode

Post by rais »

Stefan_K wrote:That's the same thing as in the previous post. There's an @ in the macro name.
not quite, I think.
In his previous post, he had the redefinition in his preamble, here he's moved it into a style file, where `@' is interpreted as letter, anyway.
Of course, he's moved the \makeatletter/\makeatother there as well, so the following redefinitions with @ in the command name fail. I'd simply remove the \makeatletter and \makeatother from the style file...

KR
Rainer
User avatar
Stefan Kottwitz
Site Admin
Posts: 10321
Joined: Mon Mar 10, 2008 9:44 pm

Re: [Help with legacy code] \spacefactor and vertical mode

Post by Stefan Kottwitz »

Ah, yes, it was in a style file. I agree with Rainer, for earlier mentioned reasons those two commands should not be in a style file, only in a document file. Sorry for confusion.

Stefan
LaTeX.org admin
Post Reply