在LaTeX中使用单个计数表和数字表

时间:2010-10-05 15:12:46

标签: latex

我已经获得了一个LaTeX文档,可以使用以下代码进行编辑,以便对数字和表格使用单个计数。

 \makeatletter
 \newcounter{unisequence}
 \def\ucaption{
    \ifx\@captype\@undefined
        \@latex@error{\noexpand\ucaption outside float}\@ehd
        \expandafter\@gobble
    \else
        \refstepcounter{unisequence} 
        \expandafter\@firstofone
    \fi
    {\@dblarg{\@caption\@captype}}
  }
 \def\thetable{\@arabic\c@unisequence}
 \def\thefigure{\@arabic\c@unisequence}
 \makeatother

这适用于为表格和图形的字幕提供单个计数器但是,我发现如果我点击.pdf中生成的任何字幕编号,我总是返回到第一个数字或表格中文件而不是我想要的文件,例如点击表[3]将会转到表1。

有谁知道如何解决这个问题?或者任何人都可以建议替代方案吗?

我是一名乳头新手。

由于

摩根先生。

4 个答案:

答案 0 :(得分:3)

如果对任何人都有用,请使用:

\makeatletter
\renewcommand*{\thetable}{\arabic{table}}
\renewcommand*{\thefigure}{\arabic{figure}}
\let\c@table\c@figure
\makeatother 

在您的文件的序言中。

答案 1 :(得分:2)

基于https://stackoverflow.com/a/3866061/53974https://tex.stackexchange.com/a/127744/1340,我们可以只(1)使表计数器与数字计数器相同,并且(2)使表浮点类型与图相同float类型,以确保排序与编号一致,因为:

  

LaTeX按顺序保留所有相同类型的浮动

代码:

\makeatletter
\let\c@table\c@figure % for (1)
\let\ftype@table\ftype@figure % for (2)
\makeatother

https://stackoverflow.com/a/3866061/53974相比,这会使\thetable\thefigure保持不变,因此表格和图号会按原样保持格式。这与每章/节编号有关,在160页的文档中,它可以与超链接,subcaptionfloatrotating包以及更多内容一起使用。

答案 2 :(得分:0)

在我的头顶,这是你在那里没有生成正确引用的片段的问题。例如,请参见此处:http://en.wikibooks.org/wiki/LaTeX/Hyperlinks

答案 3 :(得分:0)

将查询中的代码与之前的答案相结合,对我来说非常有用 - 谢谢。

要获得章节编号中连续编号的数字和表格,我在答案片段中替换了两行

\renewcommand*{\thetable}{\arabic{chapter}.\arabic{table}}
\renewcommand*{\thefigure}{\arabic{chapter}.\arabic{figure}}