# Use pagestyle within bibheading definition in biblatex

The following MWE prints a cumulative bibliography, subdivided by chapter, using biblatex. I would like to use the pagestyle called special within the bibheading definition rather than invoking it explicitly at the end of my document. I would also like that once the bibliography is printed the 'main' pagestyle is reestablished. So, is it possible to use a pagestyle (defined with titlesec) within a bibheading definition in biblatex? And can that pagestyle scope be limited to just the bibliography?

\documentclass{book}
\usepackage[english]{babel}

\usepackage[pagestyles,outermarks]{titlesec}

\newpagestyle{main}[\scshape]{%
[\thepage][][\chaptertitlename\space\thechapter. \chaptertitle]
{\ifthesection{\thesection\space\,\sectiontitle}
{\chaptertitlename\space\thechapter. \chaptertitle}}{}{\thepage}
}
\newpagestyle{special}[\scshape]{%
[\thepage][][\chaptertitle]
{\sectiontitle}{}{\thepage}
}
\pagestyle{main}

\usepackage[style=american]{csquotes}
\usepackage[style=authoryear-comp,refsegment=chapter,backend=bibtex]{biblatex}

% Bibliography at the end:
\chapter*{#1}%
\chaptermark{#1}%
}
\ref{refsegment:\therefsection\therefsegment}}
% \thispagestyle{plain}
% \pagestyle{special} % I WANT TO PLACE IT HERE
}

\usepackage{lipsum}

\begin{document}

\chapter{First}
\lipsum
\section{First Section}
\lipsum[1-5]
\nocite{*}

\chapter{Second}
\nocite{*}

\pagestyle{special}  % I DON"T WANT TO PLACE IT HERE

\end{document}


Where bar.bib is

@Book{Jac08,
author={M. O. Jackson},
title={Social and Economic Networks},
publisher={Princeton University Press},
edition={2},
year={2008}}

@InBook{NeuNas54,
author={Von Neumann, John and John Nash},
title={Game Theory},
booktitle={Microeconomic Theory},
bookauthor={Andreu Mas Collel},
publisher={Mit Press},
year={1954}}

@InCollection{Sha53,
author={Lloyd Shapley},
title={A value for n-person games},
booktitle={Contributions to the Theory of Games},
editor={Harold Kuhn and Albert Tucker},
volume={2},
translator={Jurgen Pollock},
origlanguage={german},
publisher={Princeton Press},
year={1953}}

@Book{Dur05,
author={Rick Durret},
title={Probability Theory},
edition={3},
publisher={Duxburry Press},
year={2005}}

@InCollection{Tho95,
author={Walter Thomson},
title={Cooperative models of bargaining},
booktitle={Handbook of Game Theory},
volume={2},
editor={Robert Aumman and I. Hart},
publisher={North Holland},
year={1995}}

@Report{Car10,
author={Xavier Carvalho},
title={The Great Diversification},
type={Working Paper 1624},
institution={National Bureau of Economic Research},
year={2010}}

@InCollection{LopInd83,
author    = {Juan Lopez and Ignacio Indigo},
title     = {Checking whether smartand work},
editor    = {Domingo Peron},
publisher = {Latex},
year      = {1983}
}

-
What about using \preto{\bibbysegment}{\pagestyle{special}}? –  Guido Apr 5 '13 at 23:58
@Guido That is perfect for the bibliography segment, but I also want to restablish the main style afterwards. I tried using \appto{\bibbysegment}{\pagestyle{main}} but that obviously didn't work. Any idea on how to restablish the main style for subsequent pages? –  petobens Apr 8 '13 at 5:08
I did some tests and, for some reason, the settings I suggested in my answer don't work in your MWE; unfortunately, I couldn't find a way to automatically restore the page style after the bibliography, so I am deleting my answer. –  Gonzalo Medina Apr 9 '13 at 23:50
@GonzaloMedina Thanks for the attempted solution. I edited my question accordingly. –  petobens Apr 10 '13 at 4:13
Would \preto{\chapter}{\cleardoublepage\pagestyle{main} be an acceptable solution for restoring the main style after the bibliography? –  Guido Apr 25 '13 at 10:56

You can use the following code whereby the new hook \AfterRefsegments is defined:

\makeatletter
\newrobustcmd\AfterRefsegments[1]{\def\@AfterRefsegments{#1}}
\def\blx@bibbysegment[#1]{%
\def\blx@theenv{bibliography}%
\let\blx@theprenote\@empty
\let\blx@thepostnote\@empty
\let\blx@thetitle\@empty
\c@refsegment\@ne
\blx@safe@actives
\setkeys{blx@bbg}{#1}%
\blx@rest@actives
\togglefalse{blx@tempa}%
\blx@refsegments\@AfterRefsegments}
\makeatother