I need to check where the text (from package .sty), if it is in the mainmatter section, then include some headers \pagestyle{LL}, if the other then \pagestyle{plain} or some other. Construction \ifx\@mainmattertrue\pagestyle{LL}\else\pagestyle{plain}\fi in:





     {\raisebox{0pt}[\headheight][0pt]{% начало блока
            \vbox{\hbox to\textwidth{\strut
                    \small{\thepage\hfil\MakeUppercase{BlaBla}\hfil{GL}. \thechapter}}\hrule}}% конец блока
     }% конец макроопределения

     {\raisebox{0pt}[\headheight][0pt]{% начало блока
            \vbox{\hbox to\textwidth{\strut
                    \small{{\S\hspace{1ex}}\thesection\hfil\MakeUppercase{Bla1}\hfil\thepage}}\hrule}}% конец блока
     }% конец макроопределения





does not work in







  • The standard book class makes that test for chapters, you can have a look at it. – Johannes_B Dec 18 '14 at 8:25
  • Please add a little detail so we have something to test. – Johannes_B Dec 18 '14 at 8:25
  • @Johannes_B I have done MWE in my post – sergiokapone Dec 18 '14 at 9:04
  • If you want to activate the pagestyle with the start of mainmatter, redefine or patch mainmatter. When the package is executed, you cannot be in mainmatter. Next topic: Difference between \if and \ifx – Johannes_B Dec 18 '14 at 9:15

The book class defines the \if@mainmatter conditional. So

   <we are in the main matter>
   <we aren't in the main matter>

is the scheme for the code you need. For instance


This indentation style is not mandatory, but I find it convenient. With your style it could be


(the % at the end of the first line is needed).

Note that \if@mainmatter is initially set to true. The commands \frontmatter and \backmatter set it to false, while \mainmatter resets it to true.

The \@mainmattertrue command is used for setting the conditional to return true, and there's the similar \@mainmatterfalse.

  • I try for code pointed in topic above. But again it does not work. \pagestyle{LL} is applied for \chapter{Intro} which is in frontmatter too. – sergiokapone Dec 18 '14 at 16:01
  • @sergiokapone Of course: you just execute the command \@LLview once. It's probably better adding the page style declaration directly to the code for \frontmatter and \mainmatter. – egreg Dec 18 '14 at 16:05
  • @egref Yes, you right. It is bertter to redefine \mainmatter – sergiokapone Dec 18 '14 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.