ctexart页眉如何引用标题

发布于 2023-11-01 16:07:45

ctexart的页眉右端想引用标题,怎么弄?@title不能用
代码片段如下:

\documentclass[a4paper,11pt]{ctexart}
 \usepackage[top=12ex, bottom=12ex, left=9ex, right=9ex,showframe=false]{geometry}
\usepackage{fancyhdr}
 \pagestyle{fancy}
 \fancyhf{}
\lhead{ \fancyplain{}{\includegraphics[width=0.5cm]{logo.png} \heiti 高数讲义}}
\rhead{ \fancyplain{}{\@title}}%这个语句有问题
\cfoot{ \fancyplain{}{\thepage} }

查看更多

关注者
0
被浏览
794
LaTeXStudio
LaTeXStudio 2023-11-01
这家伙很懒,什么也没写!

可以用,但是需要特殊处理下,一般可以定义一个命令,专门放在页眉的内容放在定义里面。
比如:

\makeatletter
\let\runauthor\@author
\let\runtitle\@title
\makeatother
\lhead{\runauthor}
\rhead{\runtitle}
3 个回答
拿了橘子跑啊
拿了橘子跑啊 2023-11-08
这家伙很懒,什么也没写!

@的命令是内部命令,需要在 \makeatletter\makeatother之间使用,即临时改变 @ 的类别码。但是即使这样,你直接用 \@title 也是不行的,因为在 \maketitle 的定义里,最后将 \@title\@author 甚至是 \maketitle 本身都清空了(你可以试试随便在正文中再 \maketitle 一下看看有没有用处)。所以要在 \maketitle 之前把他们的定义给到其他的cs,就像上面的答案里 \let\runtitle\@title

拿了橘子跑啊
拿了橘子跑啊 2024-01-28
这家伙很懒,什么也没写!

内部命令指的是?

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览