Generalreferences and indexing (eq and fig)

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
jezikk
Posts: 6
Joined: Sat Jun 28, 2008 8:31 pm

references and indexing (eq and fig)

Post by jezikk »

Hi,
in my project all equations and figures are indexed like 1,2,3...n. Could you help me, how to make indexing (for example) like 2.1,2.2,2.3....3.1,3.2... for eq. and fig.??
Thank you


PS: sry for my bad english :lol:

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

references and indexing (eq and fig)

Post by localghost »

First of all I would call that numbered and not indexed. From your descriptions I assume that you are using an article class without chapters. There are two steps needed to get the numbering as desired.

For the equations (and all other mathematical expressions) there is the (preferably to use) amsmath package. It provides a command that redefines the counter for equations so that it can be reset in every section.

For the figures (or floats in general) there is the caption package. It lets you customize the captions of floats in many ways and provides settings to get the same effect as for the equations.

So, enough words now. A code example will show how to get the desired result.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{bindingoffset=1cm,centering,includeheadfoot,margin=2cm]{geometry}
\usepackage{amsmath}
\usepackage{txfonts}
\usepackage{blindtext}

% Changing float numbering (caption)
\captionsetup{%
  figurewithin=section,
  tablewithin=section
}

% Changing equation numbering (amsmath)
\numberwithin{equation}{section}

\begin{document}
  \section{First section}
  \blindtext

  \begin{figure}[!ht]
    \centering
    \rule{8cm}{4.5cm}
    \caption{A dummy figure}\label{fig:dummy}
  \end{figure}

  \section{Second section}
  \blindtext
  \begin{equation}\label{eqn:einstein}
    E=mc^2
  \end{equation}
  \blindtext
\end{document}
The change of equation numbering with the command from amsmath principally works also for floats, but in my opinion is better done with the caption package. All other mathematical environments are numbered by sections, too.


Best regards
Thorsten¹
jezikk
Posts: 6
Joined: Sat Jun 28, 2008 8:31 pm

Re: references and indexing (eq and fig)

Post by jezikk »

:arrow: Thank you for your help
Post Reply