[LaTex] 在 section name 里自引用此 section 的 index

2015-10-19 00:18:49 +08:00
 lsmgeb89
Latex 新手,有个蛮特殊的需求, Google 了半天没查到。

我想在 section name 里自引用此 section 的 index ,例如这个效果:

1.1 This is Section 1.1

PS :我已经用了 titlesec 包改了些样式,希望 solution 能不影响现在的设定,谢谢。
\usepackage{titlesec}

\titleformat{\subsection}{\normalfont\normalsize\itshape}{\thesubsection}{1em}{}
\renewcommand\thesubsection{\thesection-\arabic{subsection}}
3968 次点击
所在节点    问与答
3 条回复
wsy2220
2015-10-19 01:43:38 +08:00
这种事情我一般都是硬编码....
或者用特殊标记, 编译前用别的工具批量替换
wsy2220
2015-10-19 01:57:06 +08:00
比如
\subsection{This is Section ___ref}
写个 python 脚本扫描一下这是第几个 section 和 subsection, 把___ref 替换成相应数字就好了.
canautumn
2015-10-19 06:29:08 +08:00
用 cross reference 就可以吧,
\subsection{This is Section \ref{subsec1}} \label{subsec1}

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/229062

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX