latex hyperref_Latex 用subfig引用子图显示括号

最近发现了一个非常好用的包hyperref,设置方法如下:使用autoref 引用子图,如何更改引用样式。但是默认的会带上红框,想要去掉的话需要加上hypersetup{hidelinks}命令。


最近在用latex写论文,在引用subfloat生成的图中的子图时,用ref命令不显示括号。查了一下后发现都是用的subfigure包,只有一篇讲的是subfig:

LaTeX中使用包subfig引用子图标号_陈广智的专栏-CSDN博客_latexsubfig​blog.csdn.net
5a1ad2d1aa83105a88901ef13bf27f3e.png

但是按照大佬的方法只能显示字母,不能显示数字+(字母)的形式。虽然可以手动添加数字,但这样和用word没区别了,没有用latex的意义了。。。

于是发扬了一下钻牛角尖的精神,顺着大佬的思路继续看subfig包的帮助文档,终于找到了解决办法:在帮助文档中,除了大佬提到的subref 命令,subfig包还提供了另一个subref*命令。个人理解为加星的相当于可以让用户自定义的一个subref命令:

By default, the starred form of the command simply returns the thesubfloat value, which, for sub-floats is usually something like “a”. However, this may be changed by setting ‘subrefformat’, similar to the above ‘listofformat’, to a predefined format (see table 3 or to a unique format defined with the DeclareSubrefFormat command (section 2.1.4).

但是使用前需要用DeclareSubrefFormat命令指定所需要的格式:

The DeclareSubrefFormat command allows the specification of how the subref* command generates its reference to a sub-caption label in the text.

然后帮助文档又给出了DeclareSubrefFormat命令的使用例子:

184DeclareSubrefFormat{empty}{}
185 DeclareSubrefFormat{simple}{#1#2}
186 DeclareSubrefFormat{parens}{#1(#2)}
187 DeclareSubrefFormat{subsimple}{#2}
188 DeclareSubrefFormat{subparens}{(#2)}

想要指定为数字+(字母)的形式,需要在导言区加上DeclareSubrefFormat{parens}{#1(#2)} ,然后将原来的ref{}命令换成subref*{}即可。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值