Graphics, Figures & Tablescentering of large figure

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kth
Posts: 4
Joined: Mon May 25, 2009 3:34 pm

centering of large figure

Post by kth »

As I want to print a figure even larger I have noticed that
it doesnt remain centered (inspite of the \begin{center} \end{center} command)

The figure moves a little to the right, not aligned with caption and text.
Is there a command that will allow the figure to use more space in the page while being aligned as i want to?

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
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

centering of large figure

Post by localghost »

The preferable way would be to make the figure fit the text width. The epslatex document introduces the narrow environment which makes it possible to specify the range of the figure into the margins. A more simpler way is to put the figure into a special box

Code: Select all

\begin{figure}[!ht]
  \makebox[\textwidth]{
    \includegraphics{filename}
  }
  \caption{Wide figure}\label{fig:wide}
\end{figure}
In case the inclusion of the external graphics without any options makes it appear wide than the text width, it will be centered automatically.


Best regards and welcome to the board
Thorsten
fatra2
Posts: 126
Joined: Fri May 01, 2009 1:43 pm

centering of large figure

Post by fatra2 »

Hi there,

Does the command:

Code: Select all

\begin{figure}
\includegraphics[width=\textwidth]{filename}
\end{figure}
would do the same thing???

This way, you would save the creation of a box.

Cheers
kth
Posts: 4
Joined: Mon May 25, 2009 3:34 pm

Re: centering of large figure

Post by kth »

Ive tried that but my figure has details u cant see if i reduce the size to textwidth. I need to give my figure width more than the textwidth..

Can i do it somehow?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

centering of large figure

Post by localghost »

kth wrote:[...] Can i do it somehow?
Just translate the suggestion from my last reply. Theoretically you can stretch the width of the figure to paper width without obtaining warnings.
kth
Posts: 4
Joined: Mon May 25, 2009 3:34 pm

centering of large figure

Post by kth »

When i use

Code: Select all

\begin{figure}[h]
  \makebox(3,3){
    \includegraphics{filename}
  }
\end{figure}
My figure appears enormous no matter what the option (3,3) is.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

centering of large figure

Post by localghost »

Please explain what (3,3) shall do and why you just don't copy the code I provided. Learn how to use the \makebox command.

It goes without saying the you still can specify a width for the included graphics file in addition to my code example.

Code: Select all

\includegraphics[width=1.2\textwidth]{filename}
If you don't need a caption and want to place the imagewhere declared in the source, omit the figure environment.
kth
Posts: 4
Joined: Mon May 25, 2009 3:34 pm

centering of large figure

Post by kth »

cause i thought that the code u posted had a little error
the syntax is:

Code: Select all

\makebox(width,height)[position]{ ... }
so i have to specify width and height and i chose 3 by 3 inches to test it.
If I specify a width in the \includegraphics command shouldnt that be smaller than the box dimension?

Also my figure goes on the text...

Thanx for reading this
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

centering of large figure

Post by localghost »

It seems that you need to do some basic reading [1]. Please provide a minimal working example (MWE) that shows the behaviour you described. Attach a sample graphics file if necessary. For the present take a look at this example.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage[includeheadfoot,margin=2cm]{geometry}
\usepackage{blindtext}

\setlength{\parindent}{0em}

\begin{document}
  \blindtext

  \makebox[\textwidth]{%
    \rule{1.1\textwidth}{0.5\textheight}
  }

  \blindtext
\end{document}

[1] View topic: LaTeX Resources for Beginners
episanty
Posts: 26
Joined: Tue Mar 24, 2009 2:24 am

centering of large figure

Post by episanty »

Another possible solution is to use a picture environment and then \put the included graphic way left:

Code: Select all

\begin{figure}[htbp]
  \centering
  \setlength{\unitlength}{\textwidth} 
    \begin{picture}(1,0.5)%in case your image is twice as wide as it is high.
       \put(-0.1,0){\includegraphics[width=1.2\unitlength]{image.jpg}}
    \end{picture}
\end{figure}
Post Reply