GeneralPlace image on the left margin

LaTeX specific issues not fitting into one of the other forums of this category.
BorrajaX
Posts: 2
Joined: Fri Nov 28, 2008 1:58 pm

Place image on the left margin

Post by BorrajaX »

Hello all...

At first, I'd like to say "Hello" as this is my first message in this forum. Second, I'd like to explain that I am a newbie that is getting started in the WoL (world of latex) :) and probably many of my questions will be considered by many as silly or incredibly easy to answer, but well... I am just starting, and maybe one day I'll be able to solve doubts thinking that "they are very easy to answer" :)

There goes my first one:

I am writing a kind of manual, and I'd like to put some exclamation pictures on the left margin of the really relevant paragraphs, to pay the reader's attention, but it doesn't appear as I want... Right now, the best approach I could get was having something like this:

Code: Select all

Before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before.\\

\reversemarginpar\marginpar{
	\begin{flushright}
		\includegraphics[width=24px]{atencion.png}
	\end{flushright}
} 
Beware of this, and that and this thing. Beware of this, and that and this thing. Beware of this, and that and this thing. Beware of this, and that and this thing. Beware of this, and that and this thing. Beware of this, and that and this thing. Beware of this, and that and this thing.\\
With this, I get something like:

Image (link href: here)

But I'd like to get something like that:
Image (link href: here)

And I don't really know how...

Any hint (whatever: anything I can look for en google) would be appreciated...

Thank you all in advance!!

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

Place image on the left margin

Post by gmedina »

Hi BorrajaX,

one option could be to use the textpos package. refer to the package documentation
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Place image on the left margin

Post by localghost »

The marginal contents is not at the right place in the source code. You will get the desired result when placing it after the first word of the second paragraph.

Code: Select all

Before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before before.

\medskip
Beware\reversemarginpar\marginpar{\raggedleft\includegraphics[width=24pt]{atencion.png}} of this, and that and this thing. Beware of this, and that and this thing. Beware of this, and that and this thing. Beware of this, and that and this thing. Beware of this, and that and this thing. Beware of this, and that and this thing. Beware of this, and that and this thing.
Note that px is not a valid measure unit in LaTeX. You may replace it with pt. The marginnote package allows better adjustment of marginals.


Best regards and welcome to the board
Thorsten¹
picmax
Posts: 2
Joined: Sun Nov 30, 2008 5:39 am

Re: Place image on the left margin

Post by picmax »

There is a latex package called notes (notes.sty) for your purpose.

Max
BorrajaX
Posts: 2
Joined: Fri Nov 28, 2008 1:58 pm

Re: Place image on the left margin

Post by BorrajaX »

Thank you all for your answers!...

I got it working with the Textpos package.
I couldn't make it work with the \medskip and \reversemarginpar solution (maybe I did something wrong, I'll keep trying)
I'll try tomorrow (Monday) with the Notes package, and I'll tell you how it goes.

Thank you all!!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Place image on the left margin

Post by localghost »

BorrajaX wrote:[...] I couldn't make it work with the \medskip and \reversemarginpar solution (maybe I did something wrong, I'll keep trying) [...]
You did something wrong. That's for sure. The code I gave works fine for me. And the \reversemarginpar command comes from your own code sample. As suggested earlier, an approach with the marginnote package should also do the trick.
-Robin-
Posts: 31
Joined: Tue May 20, 2008 3:07 pm

Place image on the left margin

Post by -Robin- »

A little bump of this old topic. I had the same problem as the topic starter. I wanted to place an icon in the margin, to highlight a paragraph. By placing the \marginnote command after the first word everything works just fine.
But now, I want to create a new environment which automatically puts a predefined icon in the margin.
So I thought of using the

Code: Select all

\newenvironment{nam}[args]{begdef}{enddef}
command, where begdef would be the marginnote command and enddef empty. The problem is that by doing this, the marginnote command is put before the first word, and I would want it after the first word. Any ideas/tips how te solve this
-Robin-
Posts: 31
Joined: Tue May 20, 2008 3:07 pm

Place image on the left margin

Post by -Robin- »

The best I could come up with for the moment is (the marginnote will be replaced by a figure in the future, but to run the example file if replaced it by some text)

Code: Select all

\newenvironment{warnpar}[1]
{
\begin{shaded}
	#1\marginnote{test}
}
{

\end{shaded}
}
and then use it with

Code: Select all

\begin{warnpar}
	Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus nunc. Morbi cursus eleifend elit. Sed justo mi, dictum at, convallis et, dignissim id, turpis. Donec in enim. Cras cursus vulputate augue. Mauris sollicitudin nulla bibendum orci varius rutrum. Donec posuere, nulla ac ornare elementum, massa nunc blandit leo, eu aliquam lacus enim eget libero. Aenean molestie leo non enim porta imperdiet. Vivamus id augue non est laoreet porta. Proin porta, tellus quis tincidunt facilisis, leo lectus suscipit nunc, a adipiscing pede purus vel justo. Vestibulum iaculis, diam id lacinia tempus, tellus dolor ultrices enim, dapibus rhoncus augue tellus sit amet orci. Maecenas rhoncus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nam rhoncus blandit tortor. Integer a justo eget lorem ornare sodales. Cras varius, ipsum vel laoreet dapibus, nunc sapien auctor urna, sit amet iaculis magna lacus nec massa. In nibh tortor, posuere ut, tristique eu, hendrerit in, nisl.
\end{warnpar}
Now the margin note is correctly positioned but there is a blanco between the L and the orem of the first word

An example file is attachted, where the highlighted paragraph is positioned in such a way that defining the environment without the optional parameter, the marginnote stays on page 1 and the rest is put on page 2.
Attachments
colorodframes.tex
(5.47 KiB) Downloaded 279 times
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Place image on the left margin

Post by phi »

Don't do this, it will break ligatures. If you really want something like this, add comment characters at the right positions (e.g. after every line). \marginnote has an optional argument to control the vertical position:

Code: Select all

\newenvironment{warnpar}{\shaded\marginnote{test}[\baselineskip]\ignorespaces}{\endshaded}
-Robin-
Posts: 31
Joined: Tue May 20, 2008 3:07 pm

Place image on the left margin

Post by -Robin- »

I know about the optional argument for marginnotes. The problem is around a pagebreak.
The shaded paragraph is in my example put on page 2, while the margin note stays on page 1 (if you remove the optional parameter from the newenvironment command in the preamble):

Code: Select all

\newenvironment{warnpar}
{
\begin{shaded}
	\marginnote{test}[\baselineskip]\ignorespaces
}
{

\end{shaded}
}
Replacing baselineskip by e.g. 10\baselineskip doesn't help either.

Perhaps I'll look into the notes.sty file on CTAN (link) to see how they solve this problem, or I'll even try to use the notes package, although I've experimented with it and I couldn't configure it exactly the way I want it (didn't find the documentation helpful enough)
Post Reply