LyXposition floating listings and figures where I want them

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
PogoMips
Posts: 1
Joined: Mon Jan 20, 2014 5:51 pm

position floating listings and figures where I want them

Post by PogoMips »

Hi,

I'm trying to position listings as well as figures in my document.
But I'm only able to position either figures or listings as I want them.

First I had the global setting for positioning floats on "Here, absolutely", which positioned the figures as they are in the lyx file but not the listings. They just appeared somewhere else.

Second I tried the setting mentioned here:
Select Document→Settings.... In the Float Placement section, unset "Use Default Placement" and select "Top of Page", "Page of Floats", "Here, if possible" and "Ignore LaTeX rules".

This positioned the listings correctly but not the floating figures anymore. They then appeared somewhere else.

Third attempt was again setting the global settings to "Here, absolutely" and telling the listings to be float object, and setting their position to "h". This worked for all listings but one. Just this one listing appears on the top of the next page.

Can someone explain to me how I should change the settings so that following criteria are matched:
1. listings without page breaks
2. figures and listings positioned where I want them to be

Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
mgmillani
Posts: 16
Joined: Fri Dec 20, 2013 7:26 pm

position floating listings and figures where I want them

Post by mgmillani »

A minimal example would be nice.

If you want a float to be precisely where you tell it to be, you should use the package float and use a 'H' instead of 'h'. Like this:

Code: Select all

...
\usepackage{float}
...
\begin{figure][H]
...
\end{figure}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

position floating listings and figures where I want them

Post by Johannes_B »

If you do not want your objects to float around, don't use float, don't use any floating environment (figure, table).

You can use package capt-of to typeset captions. If you are using a KOMA-class, the functionality is built-in.

But beware: Not floating can mean big white spaces in your document. If you want your texts to look nice, scientific and serious (and not like swiss cheese), you need your objects to float.

Best regards
Johannes
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply