Graphics, Figures & TablesHow to add or delete figure/table in between other figures/tables

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Ali Sultan
Posts: 12
Joined: Sun Oct 02, 2016 5:09 am

How to add or delete figure/table in between other figures/tables

Post by Ali Sultan »

Hello,
I am writing my dissertation using latex. I do have more than 100 figures/tables in chapters 4 and 5. The figure files are stored in the same latex directory in an ascending order (i.e., Fig 4-1, Fig 4-2, etc). Sometimes I need to either add, or delete, a figure/table in the middle of chapter 4 for example, what is the most efficient way to do so without going over all the figures/tables after that position and changing the numbers manually? I hope you understood the problem and have some solutions. Thanks

Recommended reading 2024:

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

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

User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to add or delete figure/table in between other figures/tables

Post by Johannes_B »

LaTeX numbers figures automatically using the caption command.
That you named the figures using numbers, is a design flaw. That should never be done.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Ali Sultan
Posts: 12
Joined: Sun Oct 02, 2016 5:09 am

How to add or delete figure/table in between other figures/tables

Post by Ali Sultan »

Johannes_B wrote:LaTeX numbers figures automatically using the caption command.
That you named the figures using numbers, is a design flaw. That should never be done.
Do you mean that I should've named these figures exactly as their corresponding captions?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

How to add or delete figure/table in between other figures/tables

Post by Stefan Kottwitz »

Let's say, you have a picture of a book. You call it book.png.

In your LaTeX document, you write it like

Code: Select all

\begin{figure}
  \centering
  \includegraphics{book}
  \caption{This is a book.}
  \label{book}  
\end{figure}
% ...
% later in the text
See the figure \ref{book} as an example.
LaTeX does all the numbering for you!
It puts
  • a number before the caption, such as "Figure 4.1: This is a book"
  • the number with that caption into the list of figures
  • its number to all references of it in the LaTeX document (done by \ref)
It numbers in the correct sequence per chapter. You can change the design or function of numbering too. But don't number yourself, otherwise you see what happens: you need to change all manually, every time such a change happens, even your file names if you used numbers in file names.

Stefan
LaTeX.org admin
Ali Sultan
Posts: 12
Joined: Sun Oct 02, 2016 5:09 am

How to add or delete figure/table in between other figures/tables

Post by Ali Sultan »

Thanks Stefan and Johannes_B. for answering the question. You're the best guys. :D
Post Reply