Graphics, Figures & TablesQuestions about table and graphic

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
lehe
Posts: 12
Joined: Mon Feb 09, 2009 11:57 pm

Questions about table and graphic

Post by lehe »

Hi,
I have some questions regarding tables and graphics.

1. How to make the table not to move too far away from where it is written? My table always move to 1~2 pages away on the top of that page. My code is:

Code: Select all

\begin{table}[h]
\begin{center} 
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline 
 ...
\hline
\end{tabular}
\end{center}
\end{table}
2. How to include png image into tex file? I tried to specify the extension .png and not to, and both give the "Latex cannot determine size of graphics". My code is:

Code: Select all

\documentclass[a4paper]{article}
%\documentclass[12pt]{article}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[margin=1in]{geometry}  % set the margins to 1in on all sides
\usepackage{graphicx}              % to include figures
\usepackage{amsmath}               % great math stuff
\usepackage{amsfonts}              % for blackboard bold, etc
\usepackage{amsthm}                % better theorem environments
\usepackage{slashbox}

...

\includegraphics[scale=2]{/home/lehe/results/0_1.png} 

3. If I have several images under the same directory (different from the one containing the tex file). Can we define some thing like vairable or string to store the common path of the images and then append the image file name to it when include them? It also seems that the going-one-level-up notation "../" does not work in the \includegraphics

4. If my image files are named after numbers from 1, 2, ..., 10, is it possible to use something like loop to go over them so to include them in the tex file?

Thank you and regards!

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10358
Joined: Mon Mar 10, 2008 9:44 pm

Questions about table and graphic

Post by Stefan Kottwitz »

Hi lehe!
  1. Use more positioning parameters, not just [h], perhaps even [!htbp]. I recommend \centering instead of \begin{center} ... \end{center}, see center vs. \centering.
  2. Use pdfLaTeX, not LaTeX. That means, compile directly to pdf.
  3. You could use \graphicspath or change environment variables, have a look here.
  4. Yes, if it would be really necessary.
Stefan
LaTeX.org admin
Post Reply