最近发现了一个非常好用的包hyperref,设置方法如下:使用autoref 引用子图,如何更改引用样式。但是默认的会带上红框,想要去掉的话需要加上hypersetup{hidelinks}命令。
最近在用latex写论文,在引用subfloat生成的图中的子图时,用ref命令不显示括号。查了一下后发现都是用的subfigure包,只有一篇讲的是subfig:
LaTeX中使用包subfig引用子图标号_陈广智的专栏-CSDN博客_latexsubfigblog.csdn.net![5a1ad2d1aa83105a88901ef13bf27f3e.png](https://i-blog.csdnimg.cn/blog_migrate/e9d5f5353640974435bce7d24ecf1866.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*{}即可。