%%
%% The LaTeX Companion, 3ed
%%
%% Example 2-2-17 on page I-49 in "Conditional heading layouts".
%%
%% Copyright (C) 2022 Frank Mittelbach
%%
%% It may be distributed and/or modified under the conditions
%% of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%%
%% See
https://www.latex-project.org/lppl.txt for details.
%%
\documentclass{tlc3exa}
\pagestyle{empty}
\setcounter{page}{6}
\setlength\textwidth{88.2009pt}
% For the book example:
\setlength\textheight{9\baselineskip}
\sloppy
%StartShownPreambleCommands
\usepackage{lipsum,titlesec}
\titleformat{name=\section,page=odd}[block]
{\normalfont\bfseries}{\thesection.}{6pt}
{\itshape\filleft}
\titleformat{name=\section,page=even}[block]
{\normalfont\bfseries}{\thesection.}{6pt}
{\itshape\filright}
%StopShownPreambleCommands
\begin{document}
\section{A Head} \lipsum[1][1-4]
\section{Another} \lipsum[1][1-4]
\end{document}