4

I wrote a custom class where I have the command \myTitlepage to display a custom titlepage. It takes five arguments. Among them is the title. I would like to pass this argument to the command \fancyfoot (fancyhdr package).

How can I pass one argument of \myTitlepage to \fancyfoot ?

EDIT - MWE

%% Start of the file 'bristol.cls'.
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.
% #################################################
% IDENTIFICATION
% #################################################
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{minimalb}[2021/12/29 V1 Cheatsheet Class]
% #################################################
% CLASS CONSTRUCTION
% #################################################
\LoadClassWithOptions{article} % The bristol class is based upon the original 'article class'
% Option declaration :
\DeclareOption{10pt}{\def\@@ptsize{10pt}}
\DeclareOption{11pt}{\def\@@ptsize{11pt}}
\DeclareOption{12pt}{\def\@@ptsize{12pt}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
% -------------------------------------------------
% LOADING NEEDED PACKAGES :
% -------------------------------------------------
% MATH :
\RequirePackage{amsthm}
\RequirePackage{amsmath}
\RequirePackage{amssymb}
\RequirePackage{mathrsfs}
\RequirePackage{mathtools}
% LAYOUT:
\RequirePackage{enumitem}
\RequirePackage{hyperref} % For hyperlinks inside the document
\RequirePackage{tikz}
\RequirePackage[most]{tcolorbox} % For better boxes
\RequirePackage{xcolor}
\RequirePackage{pagecolor}
\RequirePackage{tocloft} % to modify the standard TOC
\RequirePackage[object=vectorian]{pgfornament} % For ornaments used on the titlepage
\RequirePackage{fancyhdr}
% FONT:
\RequirePackage{fontawesome} % For dingbats
\RequirePackage{adforn} % For more dingbats
% GEOMETRY SETTINGS:
\RequirePackage[paperheight=21cm,paperwidth=14.85cm,textheight=16cm,textwidth=13.85cm,inner=0.5cm,outer=0.5cm,top=2cm,twoside]{geometry}

%% TITLEPAGE:
\newcommand{\thisornament}[1][68]{\pgfornament[width=0.5\textwidth]{#1}} % Producing the ornament
\newcommand{\myTitlepage}[5]
  {%
    \newpagecolor{#5}% Changing page color
    \newgeometry{top=2cm,left=1cm,right=1cm,bottom=0.5cm}%
    \begin{titlepage}%
      \centering
      \large
      #4 -- \today\par
      % Title
      \vspace{2cm}%
      \begingroup
        \Huge
        \sbox0{#1}%
        \ifdim\wd0>\linewidth
          \unhbox0
        \else
          \resizebox{\linewidth}{!}{\usebox0}%
        \fi
        \par
      \endgroup
      \vspace{0.5cm}
      \large \adforn{32}\quad#2\quad\adforn{60}\par
      \vspace{0.5cm}%
      \thisornament\par
      \vspace{1cm}%
      \begin{tcolorbox}
        [
           breakable
          ,enhanced
          ,title=\contentsname
          ,colframe=black
          ,colback=white
          ,colbacktitle=white
          ,fonttitle=\bfseries
          ,coltitle=black
          ,attach boxed title to top center=
            {%
               yshift=-0.25mm-\tcboxedtitleheight/2
              ,yshifttext=2mm-\tcboxedtitleheight/2
            }
          ,boxed title style=
            {%
               boxrule=0.5mm
              ,frame code=
                {%
                  \path[tcb fill frame] ([xshift=-4mm]frame.west)
                  -- (frame.north west) -- (frame.north east)
                  -- ([xshift=4mm]frame.east) -- (frame.south east)
                  -- (frame.south west) -- cycle;%
                }
              ,interior code=
                {%
                  \path[tcb fill interior] ([xshift=-2mm]interior.west)
                  -- (interior.north west) -- (interior.north east)
                  -- ([xshift=2mm]interior.east) -- (interior.south east)
                  -- (interior.south west) -- cycle;%
                }%
            }%
        ]%
        % TOC display
        \@starttoc{toc}%
      \end{tcolorbox}%
      \vfill
    \end{titlepage}%
    \restorepagecolor
    \restoregeometry
  }
\makeatother

%% FANCYHDR COMMANDS:
\pagestyle{fancy}
% % No HEADER
\fancyhead[L]{} 
\fancyhead[R]{}
\fancyhead[C]{}
\renewcommand\headrulewidth{0pt}
\fancyfoot[L]{Titre} % <- I WANT THIS ARG TO BE PASSED FROM MYTITLEPAGE
\fancyfoot[R]{\adforn{64}\;\textbf{\thepage}}
\fancyfoot[C]{} % Deletes centered page numbers
%% TOCLOFT COMMANDS:
% To have dotted lines in TOC
%\renewcommand\cftsecfont{\normalfont}
%\renewcommand\cftsecpagefont{\normalfont}
\renewcommand{\cftsecleader}{\cftdotfill{\cftsecdotsep}}
\renewcommand\cftsecdotsep{\cftdot}
\renewcommand\cftsubsecdotsep{\cftdot}
% end of the file

The \fancyfoot command is on line 123 of this file. When tested, it should be named minimalb.cls.

\documentclass[10pt]{minimalb}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
\myTitlepage{MWE}{For \TeX - \LaTeX Stackexchange}{Me}{Institution}{gray!25!white}
\end{document}

This is a .tex file to test the .cls file I provided.

2
  • It is an interesting question, but I think, a bit more code would be useful. I can not really imagine how your custom class looks like. Can you post a minimum working example?
    – Lepakk
    Aug 3, 2022 at 12:57
  • Done ! @Lepakk I added a minimal .cls file with a compatible .tex file to test everything.
    – Elyo
    Aug 3, 2022 at 13:07

1 Answer 1

4

Simply have your macro \myTitlepage store the content of the title in another macro and use the latter in the footer.

\documentclass[a5paper,landscape]{article} % options only for smaller snapshot

\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhead{} % clear header
\fancyfoot{} % clear footer
\renewcommand\headrulewidth{0pt}
\newcommand*{\mytitle}{}
\fancyfoot[L]{\mytitle}
\fancyfoot[R]{\textbf{\thepage}}

\newcommand{\myTitlepage}[5]{%
   \gdef\mytitle{#2}% or #1?
   Something with #1, #2, #3, #4, and #5.%
}

\begin{document}

\myTitlepage{MWE}{For \TeX - \LaTeX Stackexchange}{Me}{Institution}{gray!25!white}

\end{document}

enter image description here

In fact, since you are writing a class you could use \@title instead of \mytitle.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .