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 change the \chapter section definition but in some chapters of the book I don't want to apply it. For example, in the code below I don't want to apply in \EjerPro. How can I do it?

\documentclass[openany]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[spanish,es-lcroman]{babel}
\usepackage[hmargin=2cm,tmargin=4cm,bmargin=2.5cm,centering]{geometry}
\usepackage[demo]{graphicx}
\usepackage{kpfonts}
\usepackage[pagestyles,explicit]{titlesec}
\usepackage{xcolor}
\usepackage{polynom}
\usepackage{enumitem}
\usepackage[absolute]{textpos}
\usepackage{lipsum}

\definecolor{seccolor}{RGB}{255,204,102}% para las secciones
\definecolor{ssseccolor}{RGB}{255,233,190}% para las subsubsecciones
\definecolor{probcolor}{RGB}{159,209,139}% para los problemas
\definecolor{rptacolor}{RGB}{214,234,204}% para las respuestas

\newcommand\EjerPro{%
\chapter*{\colorbox{probcolor}{\parbox{\dimexpr\linewidth-6pt}{\hfil \LARGE\strut EJERCICIOS Y PROBLEMAS\hfil}}}
}


\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}

\newcommand*\chapterlabel{}
\titleformat{\chapter}
  {\gdef\chapterlabel{}
   \normalfont\sffamily\Huge\bfseries\scshape}
  {\gdef\chapterlabel{\thechapter\ }}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=seccolor] (0,0) %rectangle
          (\paperwidth,3cm);
        \node[anchor=east,xshift=.9\paperwidth,rectangle,
            inner sep=11pt,
              fill=seccolor]
              {\color{black}\chapterlabel#1};
       \end{tikzpicture}
      };
   \end{tikzpicture}
 }
\titlespacing*{\chapter}{0pt}{50pt}{-60pt}

\begin{document}

\chapter{Expresiones algebraicas}
\lipsum[1-5]

\EjerPro
\lipsum[1-5]

\end{document}
share|improve this question
    
Welcome to TeX.sx! Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Kurt Oct 19 '12 at 11:11
add comment

2 Answers 2

One possibility is to locally apply the standard settings (which can be found on Section 9.2. Standard Classes of the titlesec documentation) to the desired chapters; this can be done directly or using a command, as in the example below:

\documentclass{book}
\usepackage[spanish,es-lcroman]{babel}
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usepackage{lipsum}

\definecolor{seccolor}{RGB}{255,204,102}% para las secciones
\definecolor{probcolor}{RGB}{159,209,139}% para los problemas

% Para capítulos con formato normal
\newcommand\regularchapter{%
\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}
  {20pt}{\Huge##1}
\titlespacing*{\chapter}
  {0pt}{50pt}{40pt}
}
% Para capítulos con formato modificado
\newcommand*\chapterlabel{}
\titleformat{\chapter}
  {\gdef\chapterlabel{}
   \normalfont\sffamily\Huge\bfseries\scshape}
  {\gdef\chapterlabel{\thechapter\ }}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=seccolor] (0,0) %rectangle
          (\paperwidth,3cm);
        \node[anchor=east,xshift=.9\paperwidth,rectangle,
            inner sep=11pt,
              fill=seccolor]
              {\color{black}\chapterlabel#1};
       \end{tikzpicture}
      };
   \end{tikzpicture}
 }
\titlespacing*{\chapter}{0pt}{50pt}{-60pt}

\newcommand\EjerPro{%
  \begingroup
  \regularchapter
  \chapter*{\colorbox{probcolor}{\parbox{\dimexpr\linewidth-6pt}{\hfil \LARGE\strut EJERCICIOS Y PROBLEMAS\hfil}}}
  \endgroup
}

\begin{document}

\chapter{A Modified Numbered Chapter}
\EjerPro
\lipsum[3]
\chapter{Another Modified Numbered Chapter}

\end{document}
share|improve this answer
add comment

In the case you are describing, with two different versions of chapters, I would likely define a new command \mychapter or \Chapter that does what your \titleformat call does, and leave the original \chapter alone.

Here is what I did when I had a similar problem:

\newcommand{\mychapter}[1]{
 \chapterimage{#1}
 \chapter*{#1}
 \stepcounter{chapter}
 \addcontentsline{toc}{chapter}{#1}
 \chaptermark{#1}
 \label{#1}}
share|improve this answer
add comment

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.