爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 8120|回复: 2

整理LaTeX label/ref 技巧

[复制链接]

新浪微博达人勋

发表于 2021-3-14 21:10:57 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 dragonphy 于 2021-3-14 21:18 编辑

整理LaTeX label/ref 技巧
在文章中建立各種 ”超連結”指向圖、表、公式或其他段落等等,方便讀者跳去查看相關內容 (但無法像網頁般可以返回)。
Let’s get started!
引用宏包:
\usepackage[breaklinks,colorlinks]{hyperref}  %基礎必要的宏包,其中breaklinks是允許超連結的字換行
\hypersetup{
       linkcolor=blue,        % color of internal links
       citecolor=blue,        % color of links to bibliography
       filecolor=blue,        % color of file links
       urlcolor=blue          % color of external links
    }
\usepackage{xr-hyper}  %引用外部文件時
\externaldocument[supp-]{../work/XXX}%外部文件的檔案位置 (注意勿寫成XXX.tex)
\makeatletter
\newcommand\sfcodefork{%
\ifnum\the\spacefactor=1000\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
}%
\renewcommand\figureautorefname{\sfcodefork{Fig.\texorpdfstring{\null}{}}{Figure}} %期刊規定的表達
\renewcommand\sectionautorefname{\sfcodefork{Sect.\texorpdfstring{\null}{}}{section}}
\renewcommand\subsectionautorefname{\sfcodefork{Sect.\texorpdfstring{\null}{}}{subsection}}
\makeatother
用法:

  
預先做標籤
  
引用時…
視覺效果
\section{Data and  Methods}\label{sec:2}
as presented in  Sect. \ref{sec:2}.
as presented in Sect. 2.
同上
as presented in \autoref{sec:2}.
as presented in Sect. 2.
\section*{Appendix  1: xxx}\label{ App:1}
\hyperref[App:1]{Appendix  1}
Appendix  1
在另一個tex中,\label{fig:2}
\autoref{supp-fig:2}
Fig. 2
略 (多章節須加s)
\hyperref[sec:2]{Sects.  2}, \ref{sec:3.1} and \ref{sec:3.3}
Sects. 2,  3.1 and 3.3
略(網站)
\url{http://xxx}
http://xxx
把文獻放入Jabref 的BibTeX中,正確使用 \usepackage{natbib}一番操作
  
[註]: 引用參考文獻涉及BibTeX等等暫不討論。
\cite{Stull1988}
Stull (1988)
  
在Reference中:
  
Stull RB (1988) An  Introduction to Boundary Layer Meteorology. 978 Springer  Netherlands, DOI 10.1007/978-94-009-3027-8

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2021-3-14 21:37:43 | 显示全部楼层
本帖最后由 dragonphy 于 2021-3-14 21:41 编辑

引用宏包在\makeatletter\makeatother之間添加:
\newcommand{\setword}[2]{%
       \phantomsection
       #1\def\@currentlabel{\unexpanded{#1}}\label{#2}%
}
用法:
  
\setword{ Cogito, ergo sum.}{w:dcar}
  
\hyperref[w:dcar]{vide  supra}
vide  supra
補充一個技巧: 某段落中比如提到”我思故我在”的討論,後面段落”參見上文”想搞個超連結時可使用。

密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2021-3-15 23:29:10 | 显示全部楼层
更正一下,pdf 檔的"超連結" 點擊之後是可以跳回原本在看的地方。按"Alt+<-"即可。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表