加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

LaTeX技巧290:如何设置图表编号和章节相关联

(2010-02-08 23:22:49)
标签:

latex

标题

章节

关联

图表

分类: 插图技巧

QQ群:91940767/145316219/141877998/80300084/194770436
淘宝店:http://latexstudio.taobao.com
技巧续篇:http://latexstudio.net/
常见数学公式问题集下载

前面博客,有关于编号与章节关联的文章,主要是:公式编号与章节关联的标准方法。主要是纠正一些我们在公式编号设置中的错误方法。
这里我们讲如何让图表的标题编号与章节编号相关联。
LaTeX技巧290:如何设置图表编号和章节相关联
演示代码:
    \documentclass[11pt,a4paper]{report}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage[font=small,labelfont={bf,sf},tableposition=top]{caption}

    \makeatletter
    \renewcommand{\thefigure}{\ifnum \c@chapter>\z@ \thechapter-\fi \@arabic\c@figure}
    \renewcommand{\thetable}{\ifnum \c@chapter>\z@ \thechapter-\fi \@arabic\c@table}
    \makeatother

    \begin{document}
      \chapter{One}
        \begin{figure}[!ht]
          \centering
          \rule{6.4cm}{3.6cm}
          \caption{Dummy figure}\label{fig:dummy}
        \end{figure}

        \begin{table}[!ht]
          \caption{Dummy table}\label{tab:dummy}
          \centering
          \rule{6.4cm}{3.6cm}
        \end{table}
    \end{document}

注:
\renewcommand{\thefigure}{\ifnum \c@chapter>\z@ \thechapter-\fi \@arabic\c@figure}
等价于:
\renewcommand{\thefigure}{\thechapter-\arabic{figure}}

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有