LyXFigure with label key

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
xray
Posts: 4
Joined: Sun Aug 01, 2010 12:28 am

Figure with label key

Post by xray »

Hey,

my problem is that I want to add a figure with automatic numeration and a label. So I tried the floating object because it has the automatic numeration and a label key, but this object seem not to stay on a specific location if I add some more stuff. So is there a solution to fix this object, or the other way around, why is there no label and numeration feature for the normal figure object ???

cheers

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Figure with label key

Post by gmedina »

Hi,
xray wrote: ...why is there no label and numeration feature for the normal figure object ???
Who says there is no such thing? Take a look at the following example:

Code: Select all

\documentclass{article}
\usepackage{caption}

\begin{document}

\noindent\begin{minipage}{\textwidth}
  \centering
  \rule{5cm}{3cm} % to simulate an actual image
  \captionof{figure}{this is a non-floating figure with a caption an a label.}
  \label{fig:test}
\end{minipage}

\end{document}
That's the LaTeX code. You'll have to figure out how to implement this code using LyX.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
xray
Posts: 4
Joined: Sun Aug 01, 2010 12:28 am

Re: Figure with label key

Post by xray »

Ok, nice. But I thought lyx exists because people don't wont to use latex code. So is there a way to fix a floating figure, with a simple command ? This would be the easiest because this object still has a label and auto numeration without knowing about latex code.

thanks
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Figure with label key

Post by torbjorn t. »

xray wrote:But I thought lyx exists because people don't wont to use latex code.
Sure it is, but there is a limit to what you can do with LyX. This may well be one thing that you cannot do with the graphical interface in LyX alone, and thus some LaTeX-code is required.


One way of achieving this in LyX is the following:
  1. Go to Document --> Settings --> LaTeX Preamble, and add the line

    Code: Select all

    \usepackage{caption}
  2. Where you want a figure, insert first the code

    Code: Select all

    \noindent
    by hitting Ctrl + L, and typing the code in the box. Immediately after that, insert a minipage, by choosing Insert --> Box.
  3. To center the figure, put the text marker in the box, and click the Paragraph settings-button on the toolbar, where you choose centering.
  4. Insert the image as usual, via toolbar or menu.
  5. Add the caption by inserting code: Hit Ctrl + L and type

    Code: Select all

    \captionof{figure}{This is the caption}
    where "figure" is the type of float.
  6. Add a label by choosing Insert --> Label, which will allow you to reference it later.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Figure with label key

Post by meho_r »

xray wrote:Ok, nice. But I thought lyx exists because people don't wont to use latex code. So is there a way to fix a floating figure, with a simple command ? This would be the easiest because this object still has a label and auto numeration without knowing about latex code.

thanks
You may also provide an example .lyx file containing some text and figures that show the problem you're having with it.
xray
Posts: 4
Joined: Sun Aug 01, 2010 12:28 am

Re: Figure with label key

Post by xray »

Thanks a lot torbjorn, this works!

cheers
torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Figure with label key

Post by torbjorn t. »

Glad to be of assistance.

Now that the problem is solved, you can mark the thread as such, by editing the original post, and selecting the green check mark as post icon. (As mentioned in the board rules, section 3.)
xray
Posts: 4
Joined: Sun Aug 01, 2010 12:28 am

Re: Figure with label key

Post by xray »

I can't edit my original post, there's only a 'edit' button for the last post I made here.
Post Reply