Visit Jeremy's Blog.
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org LaTeX problem with figures
 User Name Remember Me? Password
 Linux - Software This forum is for Software issues. Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

 11-14-2003, 06:43 AM #1 guygriffiths Member   Registered: Jun 2003 Location: Reading, UK Distribution: Debian 3.0, LFS Posts: 524 Rep: LaTeX problem with figures This is driving me slightly crazy. I have only been using LaTeX for a little while, but I have come across a problem. I have figures and equations in my document and they label differently. Basically, this is the problem: I write something like this: normal preamble... \section{I have a problem} Here is an equation. It is equation \ref{eq:einstein} E=mc^{2} \label{eq:einstein} Now here is a figure. I like to call it figure \ref{fig:albert} \begin{figure} \includegraphics[height=45mm]{einstein.eps} \caption{A picture of Einstein} \label{fig:albert} \end{figure} rest of document. ============================= ============================= Now this should be fine, but what I get is something like this: 2.1 I have a problem Here is an equation. It is equation 1 E=mc2 (1) Now here is a figure. I like to call it figure 2.1 ========== |||||||||| |||||||||| |||pic|||| |||||||||| |||||||||| ========== Figure 1: A picture of Einstein rest of document. =========================== =========================== Now, although the figure is captioned correctly as "Figure 1: ~~~~~", when it is referenced it is appearing as "figure 2.1", or whatever the section number is. If I have more than one figure in a section, they are all referenced with the same number (the section number). As in the above example, equations work fine, but tables behave the same way as figures. I thought I was doing this the right way, I've found loads of sites on the internet that say it should be done like this, but I just can't get it to work. Any help would be most appreciated. Guy
 11-14-2003, 11:49 AM #2 ehawk Senior Member   Registered: Jul 2003 Posts: 1,257 Rep: LyX You may want to look at LyX, a WYSIWYM front end for LaTeX...works very nicely. One you have inserted your equations and figures the way you like them, you can export it to LaTeX code, and see how it needed to be entered in the markup language.
 11-15-2003, 07:02 AM #3 guygriffiths Member   Registered: Jun 2003 Location: Reading, UK Distribution: Debian 3.0, LFS Posts: 524 Original Poster Rep: Thanks, but I primarily use LaTeX at university, where I don't have the power to install other software. Do you use LyX at all? If you have created any documents with figures in, I would be grateful if you could post the code for one. I'm pretty sure I'm doing it right, but obviously not. Guy
 11-15-2003, 12:22 PM #4 ehawk Senior Member   Registered: Jul 2003 Posts: 1,257 Rep: example figure I can't post attachements here, so you can't see what the output looks like, but here is the preamble and figure insertion commands I used. I think it turned out nicely. The figure is embedded within the text.. I have just included whtat I think are relative snippets. %% LyX 1.3 created this file. For more info, see http://www.lyx.org/. %% Do not edit unless you really know what you are doing. \documentclass[english]{article} \usepackage[T1]{fontenc} \usepackage[latin1]{inputenc} \usepackage{graphicx} \makeatletter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. %% Bold symbol macro for standard LaTeX users \newcommand{\boldsymbol}[1]{\mbox{\boldmath $#1$}} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. \usepackage[T1]{fontenc} \usepackage[latin1]{inputenc} \usepackage{geometry} \geometry{verbose,tmargin=2.54cm,bmargin=2.54cm,lmargin=2.54cm,rmargin=2.54cm} \usepackage{babel} \usepackage{graphics} \usepackage{setspace} \usepackage{indentfirst} \doublespacing \makeatletter \usepackage{babel} \makeatother \begin{document} \noindent \begin{flushleft}where $\chi$ denotes distorted waves. \end{flushleft} Equation (\ref{10}) refers to four different vectors: $\vec{r}_{n}$, $\vec{r}_{p}$, and $\vec{r}_{d}$ and $\vec{r}_{pn}=\mid\vec{r}_{p}-\vec{r}_{n}\mid$. The geometry of the reaction is presented by Figure \ref{1} . It can be seen that only two of the four vectors depicted are independent. The vectors $\vec{r}_{d}$ and $\vec{r}_{p}$ are associated with the distorted waves corresponding to the incident and scattered particles. The vector $\vec{r}_{pn}$ is necessary to describe the internal deuteron state. The vector directed from the target nucleus to the center of mass of the deuteron system is denoted as $\vec{r}_{d}$, and the vector directed from the proton to the neutron within the incident deuteron system is denoted as $\vec{r}_{pn}$. If it is desired to chose $\vec{r}_{d}$ and $\vec{r}_{pn}$ as the coordinates of integration, the other coordinates can be expressed in terms of these. % \begin{figure*} \begin{center}\includegraphics[% width=1.0\textwidth]{figure1.eps}\end{center} \caption{\label{1}Reaction Geometry} \end{figure*} \begin{flushleft}The equations of transformation in this case are given by:\end{flushleft} Hope this helps. It correctly refers to Figure 1 in both the labeling of the figure and inside the text discussing it. Oooops...nevermind...my referencing is not that good, and I have figure references actually pointing to equations later in the paper (I never label or refer to equation 1 explicitly, so that I can label the figure as 1 and refer to it...latex just gets the equation numbering right at the time its processed). Oh well, looks like I cludged things manually and referencing wasn't too important, just printing out the number correctly, which I would have to change if I inserted more figures, equations, or changed their order. Sorry.... Last edited by ehawk; 11-15-2003 at 12:54 PM.
 11-15-2003, 01:35 PM #5 guygriffiths Member   Registered: Jun 2003 Location: Reading, UK Distribution: Debian 3.0, LFS Posts: 524 Original Poster Rep: Yes, that's great! I need to label my figures within the captioning environment. Thanks a bunch, I've solved the problem now. Guy

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post max_sipos Linux - Software 2 12-21-2011 12:01 PM enemorales Programming 1 11-15-2005 04:03 PM FunkyRes Linux - Software 1 08-26-2005 05:03 PM kaon Linux - Software 7 01-23-2005 03:32 PM hhegab Linux - Software 2 04-03-2003 07:03 PM

LinuxQuestions.org

All times are GMT -5. The time now is 12:03 PM.

 Contact Us - Advertising Info - Rules - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -