\myTitlepage
我编写了一个自定义类,其中有显示自定义标题页的命令。它需要五个参数。其中包括标题。我想将此参数传递给命令\fancyfoot
(fancyhdr
包裹)。
我怎样才能将一个参数传递\myTitlepage
给\fancyfoot
?
编辑-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
该\fancyfoot
命令位于该文件的第 123 行。测试时,它应该被命名为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}
这是一个.tex
用于测试.cls
我提供的文件的文件。
答案1
只需让您的宏\myTitlepage
将标题的内容存储在另一个宏中,并在页脚中使用后者。
\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}
事实上,由于您正在编写一个类,因此您可以使用\@title
而不是\mytitle
。