# H placement of floats in tufte book

I am using the tufte-book document class for writing a user manual. It involves many short code examples. I would like to achieve the following:

1. Being able to use [H] with the floats such that the caption will be displayed as usual in tufte at the side.

2. Having a new float environment that is just the same as figure, but its caption starts with Example. At the same time I would like to keep the option of having figures.

I tried to use the figurerow package for the [H] placement, but the captions are then part of the text, not on the side. The newfloat package can create an Example float, but does not recognize [H] at all. Any ideas please?

It should work like

\documentclass{tufte-book}
% ...
% all the preamble
% ...
\begin{example}[H]
\begin{lstlisting}
print "Hello World";
\end{lstlisting}
\caption{Hello world}
\end{example}

• Welcome to TEX.SX. Could you please add a minimal working example? – bmv Jan 13 '18 at 15:54
• Hi bmv, if I had a working example I wouldn't ask :) But I added an example of the expected syntax. – Isolin Jan 13 '18 at 17:05
• For getting familiar with MWEs, you might have a look at tex.meta.stackexchange.com/questions/228/… – bmv Jan 13 '18 at 22:37