6

I'm trying to create a document that has labels on different sides on even and odd pages. I would like the labels were on the even-numbered pages on the right and on the odd-numbered pages on the left.

\documentclass[12pt,a4paper]{report}


\usepackage[cp1250]{inputenc}   
\usepackage[T1,plmath]{polski}        

\usepackage{indentfirst}        
\usepackage{amsfonts} 
\usepackage{amssymb}  
\usepackage{amsmath}  
\usepackage{mathrsfs} 
\usepackage{graphicx}
\linespread{1.5} 
%%%%%%%%%%%%%%%%%%%%%%%%%%

%stare wartości: \textheight 26cm \textwidth 17cm \topmargin -2cm \oddsidemargin -0.5cm

\textwidth 15.5cm 
\textheight 23.5cm 
\topmargin -1cm 
\oddsidemargin 0cm 
\evensidemargin 0cm 


\def\dowod{D\,o\,w\,ó\,d.\,}
\newtheorem{twi}{Twierdzenie}[chapter]
\newtheorem{tw}{Twierdzenie}
\newtheorem{lem}{Lemat}
\newtheorem{dfn}{Definicja}
\newtheorem{wn}{Wniosek}
\newenvironment{dow}{\par\dowod}{}
\renewcommand{\thetw}{\Alph{tw}}



\begin{document}

\begin{equation}\label{lp2} 
H(0,t)=ue^{-t} \sum_{i=0}^{\infty} \frac{(tu)^i}{i!} = ue^{-t(1-u)}
\end{equation}

\begin{equation}\label{lp3}
  a(j)=1-(1-u)q^j
\end{equation}

\end{document}

Is it possible to do this?

3
4

A simple hack to achieve is as given below:

\makeatletter
\def\mathlabel#1{\@bsphack
  \protected@write\@auxout{}%
         {\string\newlabel{#1}{{\@currentlabel}{\thepage}}}%
  \@esphack}
\def\eqnWrite{\@bsphack
  \protected@write\@auxout{}%
         {\string\EqnStat{\theequation}{\thepage}}%
  \@esphack}%
\def\EqnStat#1#2{%
  \expandafter\gdef\csname eqn@#1\endcsname{#2}%
}
\newcommand\@reqnnum{\hb@xt@.01\p@{}%
                      \rlap{\normalfont\normalcolor%
                        \hskip -\displaywidth(\theequation)}}
\def\equation{\let\mathlabel\label$$\refstepcounter{equation}}
\def\endequation{\eqno\eqnWrite\@ifundefined{eqn@\theequation}{\hbox{\@eqnnum}}%%
     {\expandafter\ifodd\csname eqn@\theequation\endcsname\hbox{\@reqnnum}%
     \else\hbox{\@eqnnum}\fi}$$\@ignoretrue}
\def\@@eqncr{\let\reserved@a\relax%
    \ifcase\@eqcnt \def\reserved@a{& & &}\or \def\reserved@a{& &}%
     \or \def\reserved@a{&}\else%
       \let\reserved@a\@empty%
       \@latex@error{Too many columns in eqnarray environment}\@ehc\fi%
     \reserved@a \if@eqnsw\eqnWrite%
     \@ifundefined{eqn@\theequation}{\@eqnnum}%
     {\expandafter\ifodd\csname eqn@\theequation\endcsname\@reqnnum%
     \else\@eqnnum\fi}\stepcounter{equation}\fi%
     \global\@eqnswtrue\global\@eqcnt\z@\cr}
\makeatother

Place this code just before \begin{document}.

3
  • Now on the pages where the equation is at the top of the page (before the equation on the site is max one line of text), label for this equation is on the opposite side. The program does not recognize the reference to the labels \eqref{} inserts instead "(??)".
    – Agnieszka
    Jul 7 '13 at 11:18
  • Pardon me, but where is makeatother? ;) Pretty cool TeXhack! Jul 7 '13 at 12:28
  • @Agnieszka I have updated the code, now cross-reference and equation appearing after pagebreak will appear correctly. Please note that you need to run twice to get the equation number appear correctly in the margins. @SeanAllred \makeatother is not a must :-)
    – Jagath
    Jul 7 '13 at 16:20

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.