LaTeX 板


LINE

试了很久,实在不理解\def的展开时机。 \def\cmd{define} 之後,若将\cmd传入其他指令, 是会在使用到当下展开(进行运算)其定义, 还是说只有定义当下的值呢?(这好像不太合理) 我想要让目录中,一般章节的条目显示为:「一、 目录名」 但附录要维持「A、 附录名」 所以我在.cls中首先改写\thecontentslabel 设定 \gdef\thecontentslabel@chapter{ \ifx\@chapapp\appendixname % 判断 \appendix \appendixname\thecontentslabel、 \else \zhnumber{\thecontentslabel}、 \fi} 然後用titlesec套件的\titlecontents 改写目录的 chapter 条目格式 (下面的\tocStyle* 只是一些设定变数而已) \titlecontents{chapter}[\tocNumSpaceC@Before] {\tocStyleCheapterAbove} {\tocStyleCheapterFont \makebox[\tocNumSpaceC@Total][l] {\thecontentslabel@chapter}} {\tocStyleCheapterFont} {\tocStyleCheapterFiller} 由於 \appendix 有这行 \gdef\@chapapp{\appendixname} 所以照预想,使用\appendix後,\thecontentslabel@chapter 应该要输出「\appendixname\thecontentslabel、」 但实际上它总是输出「\zhnumber{\thecontentslabel}、」 为什麽呢? 我也试了\renewcommand\appendix ,并包含 \gdef\thecontentslabel@chapter{\appendixname\thecontentslabel} (\def \gdef均试过) 但这不会影响到已定义过的\titlecontents{chapter} 即使在重定义 \thecontentslabel@chapter 後, 再次使用完全一样的 \titlecontents{chapter} 进行设定也一样不会有任何效果。 但假若在 \titlecontents{chapter} 中直接使用 \appendixname\thecontentslabel 来取代 \thecontentslabel@chapter ,这样就可以了。 \titlecontents{chapter}[\tocNumSpaceC@Before] {\tocStyleCheapterAbove} {\tocStyleCheapterFont \makebox[\tocNumSpaceC@Total][l] {\appendixname\thecontentslabel}} {\tocStyleCheapterFont} {\tocStyleCheapterFiller} --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.32.188.151
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/LaTeX/M.1479825099.A.E11.html 咦!刚刚单独测试了下面这段 \makeatletter \ifx\@chapapp\appendixname {\Huge in appendix} \else {\Huge in normal} \fi \makeatother 竟然都是 in normal 。为什麽呢? (这段是从 https://goo.gl/GKnuJU 来的) ※ 编辑: sppmg (114.32.188.151), 11/22/2016 23:09:25
1F:→ kerwinhui: 反过来用\chaptername好像可以? 11/23 12:24
2F:→ kerwinhui: 请无视上面的,已回了 11/23 13:50
感谢 kerwinhui 大,判断 \appendix 的解决了。 而\titlecontents 仍然无法使用的原因可能是因为 titletoc 中使用了 \edef 之类会定义期展开的指令。 我举个例子,参数我就用\titlecontents 内的,这样比较短。 \titlecontents{chapter} [\Before] % TOC 条目左边界距(数字左方空白) {\Above} % TOC 条目上方指令(添加空格) {\withLabal} % TOC 中 \cheapter 的格式 {\withoutLabal} % TOC 中 \cheapter* 的格式 {\Filler} % 填充点线以及页码 假使我在首次使用时定义 \def\Above{} ,那之後我重定义 \def\Above{\addvspace{1em}} 这样不会影响到 \titlecontents ,但确实会影响上层指令。 如: \def\a{1} \def\b{\a} \appto{\mainmatter}{ % etoolbox pkg. mainmatter: \def\a{2} } 内文处 \b \mainmatter \b 将显示出 1 mainmatter:2 由此可知改指令定义是可以影响到上层。 加上若在\titlecontents 参数中包含判断式亦无效, 所以我猜它应该只有使用定义当下的值。(eg, \edef) 比较奇怪的是若我重定义(譬如\def\Above{...})後, 再使用完全一样的\titlecontents{...}{\Above}... 这样也是无效的。难道说 LaTeX 有判断形式一样就不执行的功能? 看了titletoc.sty % \titlecontents deals with concepts, not commands \newcommand\titlecontents{% \@ifstar{\ttl@contents{\z@}}% {\ttl@contents{\@ne}}} 完全没有输入参数.... 请问这要怎麽追踪.... ※ 编辑: sppmg (114.32.188.151), 11/24/2016 12:18:07







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BuyTogether站内搜寻

TOP