我正在用 LaTeX 写一本书,我想将部分标题放在奇数页的标题上,将章节标题放在偶数页的标题上,并将带有“版权”文本的页脚放在更靠近页码的位置。但我不明白。
我遇到的问题:
我不知道该命令如何写出该部分的标题
我的边距
\geometry
不会影响标题和页脚。章节第一页的页脚不遵循“$\copyright$版权页码”的结构。
这是我正在使用的代码。提前谢谢您
\documentclass{book}
\usepackage{graphicx}
\usepackage[spanish]{babel}
\usepackage{geometry}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO]{Name of the part}
\fancyhead[LE]{\leftmark}
\fancyfoot[LE]{ \thepage\qquad $\copyright$ Copyright}
\fancyfoot[RO]{ $\copyright$ Copyright\qquad \thepage}
\renewcommand{\chaptermark}[1]{%
\markboth{\chaptername
\ \thechapter.\ #1}{}}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{2}
\geometry{
paperwidth = 17cm,
paperheight = 24cm,
}
\usepackage[a4, center, cross, noinfo]{crop}
\begin{document}
\part[Short title of part]
{Long title of part}
\chapter[Title of chapter]
{Long title of chapter}
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\end{document}
答案1
该\part
命令发出\markboth{}{}
,但实际上很容易更改它\@part
,以便它发出\partmark{#1}
类似\chapter
问题\chaptermark{#1}
。
\documentclass{book}
\usepackage[T1]{fontenc} % necessary for Spanish
\usepackage[spanish]{babel}
\usepackage{fancyhdr}
\usepackage{etoolbox}
\usepackage{geometry}
\usepackage[a4, center, cross, noinfo]{crop}
\geometry{
paperwidth = 17cm,
paperheight = 24cm,
}
\usepackage{lipsum} % for mok text
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO]{\leftmark}
\fancyhead[LE]{\rightmark}
\fancyfoot[LE]{\thepage\qquad $\copyright$ Copyright}
\fancyfoot[RO]{$\copyright$ Copyright\qquad \thepage}
\fancypagestyle{plain}{%
\renewcommand{\headrulewidth}{0pt}%
\fancyhf{}%
\fancyfoot[RO]{$\copyright$ Copyright\qquad \thepage}%
}
\newcommand{\partmark}[1]{\markboth{}{}} % like the default
\makeatletter
\patchcmd{\@part}{\markboth{}{}}{\partmark{#1}}{}{}
\makeatother
\renewcommand{\partmark}[1]{\markboth{\partname\ \thepart.\ #1}{}}
\renewcommand{\chaptermark}[1]{\markright{\chaptername\ \thechapter.\ #1}}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{2}
\begin{document}
\part[Short title of part]
{Long title of part}
\chapter[Title of chapter]
{Long title of chapter}
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\lipsum[2-4]
\end{document}
不过,我相信您希望部分标题在偶数页上,章节标题在奇数页上。但这只是我的意见。
答案2
这里我使用了重新定义,\part
以便将可选参数中的短部分标题(如果没有可选参数,则为长部分标题)放入变量中,然后在标题中使用该变量。
编辑:我重新定义页面样式plain
以仅包含页脚。
\documentclass{book}
\usepackage{graphicx}
\usepackage[spanish]{babel}
\usepackage[paperwidth = 17cm,paperheight = 24cm]{geometry}
\usepackage{lipsum}
\usepackage{xparse}
\newcommand{\originalpart}{} % trigger an error if already defined
\newcommand{\parttitle}{}
\let\originalpart\part
\RenewDocumentCommand{\part}{som}{%
\IfBooleanTF{#1}
{% \part*
\IfNoValueTF{#2}
{\renewcommand\parttitle{#3}}
{\renewcommand\parttitle{#2}}%
\originalpart*{#3}
}%
{% normal \part
\IfNoValueTF{#2}
{\renewcommand\parttitle{#3}\originalpart{#3}}
{\renewcommand\parttitle{#2}\originalpart[#2]{#3}}%
}%
}
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RO]{\parttitle}
\fancyhead[LE]{\leftmark}
\fancyfoot[LE]{ \thepage~$\copyright$ Copyright}
\fancyfoot[RO]{ $\copyright$ Copyright\qquad \thepage}
\fancypagestyle{plain}{%
\fancyhead{}% no header
\renewcommand{\headrule}{}% no header rule
% footer is "inherited" from fancy
}
\renewcommand{\chaptermark}[1]{%
\markboth{\chaptername
\ \thechapter.\ #1}{}}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{2}
\usepackage[a4, center, cross, noinfo]{crop}
\begin{document}
\tableofcontents
\part[Short title of part1]
{Long title of part1}
\chapter[Title of chapter1]
{Long title of chapter} \lipsum[2-17]
\part[Short title of part2]
{Long title of part2}
\chapter[Title of chapter2]
{Long title of chapter} \lipsum[2-20]
\end{document}
答案3
这是一种操纵页码和版权之间距离的可能性:
\fancyfoot[RO]{ $\copyright$ Copyright\hspace{0.5cm}% instead of\qquad
\thepage}
或者
\fancyfoot[LE]{ \thepage~% ~instead of \qquad, you can use ~~ for a double space as well
$\copyright$ Copyright}
您不需要单独定义几何参数,而是必须将它们作为选项放在 \usepackage 之后:
\usepackage[paperwidth = 17cm,paperheight = 24cm]{geometry}