%20%E9%83%A8%E5%88%86%E7%9A%84%E7%9F%AD%E6%A8%99%E9%A1%8C%EF%BC%9F.png)
我正在編寫一本遊戲規則手冊,其中各部分的標題以兩行顯示。第一行與短標題相同(例如\part[introduction]{introduction\\PARTIE PREMIÈRE}\label{\thepart}
),我只想將上面的行/短標題新增到標題中。我已經設法使它與此程式碼一起工作:\fancyhead[CE]{\textsc{\nameref{\thepart}}}
但是當我\part
使用 titlesec 套件自訂時,它會從標題中消失。不 ”??”或錯誤,只是一個空標題。 (奇數頁的標題顯示章節的短名稱,即使我自訂了其樣式,也可以正常工作。)
這是整個程式碼:
\documentclass[a4paper,twocolumn,openright,14pt]{memoir}
\usepackage[french]{babel}
\usepackage{blindtext}
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{titling}
\usepackage{nameref}
\usepackage{pdfpages}
\usepackage{pifont}
\usepackage[explicit]{titlesec}
\titleformat{\part}[display]
{\fontsize{21pt}{15pt}\scshape\centering}
{#1}
{1em}
{}
\titleformat{\chapter}[display]
{\fontsize{18pt}{15pt}\scshape\centering}
{#1\\\ligne}
{1em}
{}
\titlespacing{\chapter}{0pt}{0pt}{-40pt}
\newcommand{\chry}
{\ding{97}}
\newcommand{\ligne}
{\vspace{0.5cm}\fancybreak{
\begin{tikzpicture}\draw[line width=0.45mm](0,0)--(3.75,0);\end{tikzpicture}
}\vspace{0.5cm}}
\newcommand{\petiteligne}
{\vspace{0.5cm}\fancybreak{
\begin{tikzpicture}\draw[line width=0.45mm](0,0)--(1.875,0);\end{tikzpicture}
}\vspace{0.5cm}}
\renewcommand{\headrulewidth}
{0.45mm}
\fancyhf{}
\fancypagestyle{plain}
{\renewcommand{\headrulewidth}
{0pt}\fancyhf{}}
\begin{document}
%Titre
\begin{titlingpage}
\includepdf{titre}
\end{titlingpage}
%/Titre
\cleardoublepage
%Préface
\blindtext[5]
\thispagestyle{empty}
\pagestyle{fancy}
\fancyhead[CE,CO]{\textsc{préface}}
\fancyhead[LE,RO]{\thepage}
\pagenumbering{Roman}
%/Préface
\cleardoublepage
%Contenu
\fancyhead[CE]{\textsc{\nameref{\thepart}}}
\fancyhead[CO]{\textsc{\nameref{\thepart.\thechapter}}}
\pagenumbering{arabic}
\part[introduction]{introduction\\PARTIE PREMIÈRE}\label{\thepart}
\chapter[univers]{univers\\CHAPITRE PREMIER}\label{\thepart.\thechapter}
\blindtext[2]
\petiteligne
\blindtext[2]
%/Contenu
\end{document}
答案1
我發現如何感謝@馬丁沙勒!這是沒有標籤的程式碼:
\newcommand*\parttitle{}
\let\origpart\part
\renewcommand*{\part}[2][]{%
\ifx\\#1\\% optional argument not present?
\origpart{#2}%
\renewcommand*\parttitle{#2}%
\else
\origpart[#1]{#2}%
\renewcommand*\parttitle{#1}%
\fi
}