Graphics, Figures & TablesNewbie: Horizontal Space between figures and text!!

Information and discussion about graphics, figures & tables in LaTeX documents.
shiven
Posts: 6
Joined: Mon Sep 14, 2009 5:53 pm

Newbie: Horizontal Space between figures and text!!

Post by shiven »

hi all,

this is my first post and i am a complete newbie regarding LaTeX.

i also posted this to the texhax mailing list but haven't heard anything back...

i am using pdflatex via the texmaker editor to create a pdf document with figures and text. the final output seems to have a large "horizontal" distance between the text and figures. how do i change this?

the figures are inserted using wrapfig.sty

please see the image uploaded at this link to get an idea of what i am talking about
horizontal.jpg
horizontal.jpg (7.98 KiB) Viewed 5947 times
thanks!

--shiven

p.s. i will post the MWE as soon as i can... meanwhile, any help wiil be much appreciated!
Last edited by shiven on Tue Sep 15, 2009 6:17 pm, edited 1 time in total.

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

Newbie: Horizontal Space between figures and text!!

Post by localghost »

shiven wrote:[...] p.s. i will post the MWE as soon as i can... meanwhile, any help wiil be much appreciated! [...]
A MWE is essential in this because there can be more than one probable cause.
  • The length \columnsep has been modified
  • The reserved space is more than the (centered) figure needs
Specific help isn't possible until we have the MWE.


Best regards and welcome to the board
Thorsten
shiven
Posts: 6
Joined: Mon Sep 14, 2009 5:53 pm

Newbie: Horizontal Space between figures and text!!

Post by shiven »

hi localghost,

thanks for taking the time to answer my query!

so, here is the .tex code:
(WARNING, this may be too long!)

Code: Select all

\documentclass[11pt,letterpaper,english]{article}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[OT1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[letterpaper]{geometry}
\geometry{verbose,tmargin=0.5in,bmargin=0.5in,lmargin=0.5in,rmargin=0.5in,headheight=0.15in,headsep=0.15in,footskip=0.15in}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{textcomp}
\usepackage{enumitem}
\usepackage{amstext}
\usepackage{babel}
\usepackage{sectsty}
\allsectionsfont{\sffamily\normalsize}
\usepackage[compact]{titlesec}
\titlespacing{\section}{0pt}{*0}{*0}
\titlespacing{\subsection}{0pt}{*0}{*0}
\titlespacing{\subsubsection}{0pt}{*0}{*0}
\titleformat{\section}{\bf}{\thesection.}{4pt}{}{}
\titleformat{\subsection}{\bf}{\thesubsection.}{4pt}{}{}
\titleformat{\subsubsection}{\bf}{\thesubsubsection.}{4pt}{}{}
\usepackage{graphicx}
\usepackage{ccaption}
\usepackage[bf,nooneline]{subfigure}
\usepackage{wrapfig}
\fussy

\begin{document}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt} % Get rid of horizontal line in the header
\renewcommand{\footrulewidth}{0.25pt} % Create a thin horizontal line in the footer
\renewcommand{\abovecaptionskip}{0pt}
\renewcommand{\belowcaptionskip}{0pt}
\renewcommand{\thesection}{\arabic{section}}
\captionnamefont{\bfseries}
\captionstyle{\raggedright}
\captiontitlefont{\small\sffamily}
\renewcommand{\figurename}{Figure}
\setcounter{section}{1} % TOPMOST Section
\section{SPECIFIC AIMS} % TOPMOST Section
\noindent \begin{center}\textbf{ELUCIDATING} \par\end{center}
Many blah blah blah, blah blah blah, following two specific aims:
\renewcommand{\thesection}{Aim \arabic{section}}
\setcounter{section}{0} % Aims Section
\section{Structural}
\noindent blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah.
\section{Elucidate}
\subsection{Elucidating alpha:}
\noindent blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\subsection{Elucidating beta:}
\noindent blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\newpage{}
\renewcommand{\thesection}{\arabic{section}}
\section{BACKGROUND} % TOPMOST Section
\begin{wrapfigure}{r}[-0.25in]{0.4\textwidth}
\hrule
\caption{}
\subfigure[\scriptsize{blah blah blah}]{\label{fig:1a}\includegraphics[width=0.4\textwidth]{Fig1a.png}}
\hrule
\subfigure[\scriptsize{blah blah blah}]{\label{fig:1b}\includegraphics[width=0.4\textwidth]{Fig1b.png}}
\hrule
\subfigure[\scriptsize{blah blah blah}]{\label{fig:1c}\includegraphics[width=0.4\textwidth]{Fig1c.png}}
\hrule
\subfigure[\scriptsize{blah blah blah}]{\label{fig:1d}\includegraphics[width=0.4\textwidth]{Fig1d.png}}
\hrule
\end{wrapfigure}
\subsection{Background:}
\noindent  blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\\
 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\\
 blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\\
\end{document}
in case someone wants to regenerate the page (with pdflatex), i am attaching a zipped version of the .tex file, all four images and the final PDF with this message.

many thanks!

--shiven
Attachments
MWE.zip
MWE files
(29.07 KiB) Downloaded 191 times
shiven
Posts: 6
Joined: Mon Sep 14, 2009 5:53 pm

Newbie: Horizontal Space between figures and text!!

Post by shiven »

OK solved!

all i had to was add the line:

Code: Select all

 \renewcommand{\columnsep}{-15pt} 
right before the:

Code: Select all

 \begin{wrapfigure}{r}[-0.25in]{0.4\textwidth}
to get the separation i needed.

thanks for the pointers!

--shiven
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Newbie: Horizontal Space between figures and text!!

Post by localghost »

shiven wrote:[...] all i had to was add the line:

Code: Select all

\renewcommand{\columnsep}{-15pt}
[...]
I'm quite sure that this can't work since \columnsep is a length. The syntax has to be different.

Code: Select all

\addtolength{\columnsep}{-15pt}
shiven
Posts: 6
Joined: Mon Sep 14, 2009 5:53 pm

Newbie: Horizontal Space between figures and text!!

Post by shiven »

hi Thorsten,

maybe there is some issue at my end. but it appears that using your command in place of mine results in the same large distance as before... whereas if i use what i mentioned in my last post, things look fine.

please see page 2 in the attached PDF files:
MWE_0.pdf <- created using my \renewcommand syntax
MWE_1.pdf <- created using your \addtolength syntax

thanks!

--shiven

p.s. i had added [SOLVED] to my initial post title, but it seems to have been removed... is that against forum rules? just curious.
Attachments
MWE_1.pdf
using \addtolength
(28.84 KiB) Downloaded 217 times
MWE_0.pdf
using \renewcommand
(28.84 KiB) Downloaded 253 times
shiven
Posts: 6
Joined: Mon Sep 14, 2009 5:53 pm

Newbie: Horizontal Space between figures and text!!

Post by shiven »

another update.

i may be wrong when i said that "using your command in place of mine results in the same large distance as before" in the previous post...

the \addtolength syntax does reduce the space... though not as much as the \renewcommand syntax

please the attached MWE_2.pdf which is the same PDF as i uploaded in the .zip file in my second reply above.
Attachments
MWE_2.pdf
same as original PDF
(28.84 KiB) Downloaded 241 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Newbie: Horizontal Space between figures and text!!

Post by localghost »

shiven wrote:[...] maybe there is some issue at my end. but it appears that using your command in place of mine results in the same large distance as before... whereas if i use what i mentioned in my last post, things look fine. [...]
Both versions work although I don't understand why yours does. The difference between your solution and mine is that you assign a complete new value to that length whereas I only subtract a little bit. The default value of \columnsep is 35pt. Thus the result of your solution is more significant than mine. See code below.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage{lmodern}
\usepackage{wrapfig}
\usepackage{blindtext}

\begin{document}
  \begin{wrapfigure}{r}{7cm}
    \rule{7cm}{5cm}
  \end{wrapfigure}
  \blindtext

  \medskip
  \addtolength{\columnsep}{-15pt}
  \begin{wrapfigure}{r}{7cm}
    \rule{7cm}{5cm}
  \end{wrapfigure}
  \blindtext
\end{document}
If you do the modification your way you will see the difference. Usually the assignment of a value to a length looks slightly different.

Code: Select all

\setlength{\columnsep}{-15pt}
This yields the same result as your solution but without side effect.
shiven wrote:[...] p.s. i had added [SOLVED] to my initial post title, but it seems to have been removed... is that against forum rules? just curious. [...]
I edited your initial post and marked the topic as solved by choosing the green checkmark. All other solved topics can be recognized from that. And yes, solved topics shall be marked like this (Section 3, last paragraph).
shiven
Posts: 6
Joined: Mon Sep 14, 2009 5:53 pm

Newbie: Horizontal Space between figures and text!!

Post by shiven »

Thorsten,

you are absolutely right! i have no idea why my command works... however the problem is immediately apparent from the following code:

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage{lmodern}
\usepackage{wrapfig}
\usepackage{blindtext}

\begin{document}
  \medskip
  \renewcommand{\columnsep}{-5pt}
  \begin{wrapfigure}{r}{7cm}
    \rule{7cm}{5cm}
  \end{wrapfigure}
  \blindtext
  
  \medskip
  \addtolength{\columnsep}{-5pt}
  \begin{wrapfigure}{r}{7cm}
    \rule{7cm}{5cm}
  \end{wrapfigure}
  \blindtext
\end{document}
the above code will thow an error!

however if you exchange the position of \renewcommand and \addtolength as such, it works fine!

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{babel}
\usepackage{lmodern}
\usepackage{wrapfig}
\usepackage{blindtext}

\begin{document}
  \medskip
  \addtolength{\columnsep}{-5pt}
  \begin{wrapfigure}{r}{7cm}
    \rule{7cm}{5cm}
  \end{wrapfigure}
  \blindtext
  
  \medskip
  \renewcommand{\columnsep}{-5pt}
  \begin{wrapfigure}{r}{7cm}
    \rule{7cm}{5cm}
  \end{wrapfigure}
  \blindtext
\end{document}
so i guess the moral of the story is:
1. use \addtolength for changing \columnsep
2. multiple \addtolength commands will work as expected
3. avoid using \renewcommand indiscriminately

thanks for the schooling!

--shiven
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Newbie: Horizontal Space between figures and text!!

Post by localghost »

shiven wrote:[...] however if you exchange the position of \renewcommand and \addtolength as such, it works fine! [...]
This only works as long as you don't try to access \columnsep as a length again because now there is a clash between the length and the command with the same name.
shiven wrote:[...] so i guess the moral of the story is:
1. use \addtolength for changing \columnsep
2. multiple \addtolength commands will work as expected
3. avoid using \renewcommand indiscriminately

[...]
This perception is absolutely correct. However, this is a very interesting issue since the compiler should check whether something is already defined. I wonder why it doesn't do that in this case.
Post Reply