I am trying to create an environment with some picture in the left margin. Here is the code
\documentclass[twoside]{article}
\usepackage[paperwidth=170mm, paperheight=240mm, left=142pt, top=40pt,textwidth=280pt, marginparsep=6pt, marginparwidth=100pt, textheight=560pt, footskip=40pt,bindingoffset=30pt,asymmetric,reversemarginpar]{geometry}
\usepackage{lipsum}
\usepackage{sidenotes}
\usepackage{tikz}
\newcounter{sides}
\newenvironment{sideletter}[2]%
{\newcommand{\foot}{\includegraphics[width=#2]{#1}}%
\refstepcounter{sides}%
\par\makebox(0,0)[r]{\large\bfseries\sffamily\colorbox{red}{Ejercicio~\thesides}%
\hspace{6pt}%
}\ignorespaces}%
{\begin{marginfigure}
\hfill\tikz{\node at (0,0){\foot};}
\end{marginfigure}\bigskip}
\newenvironment{sideletter*}%
{\refstepcounter{sides}%
\par\makebox(0,0)[r]{\large\bfseries\sffamily\colorbox{red}{Ejercicio~\thesides}%
\hspace{6pt}%
}\ignorespaces}%
{\begin{marginfigure}
\hfill\tikz{\node at (0,0) {text};}
\end{marginfigure}\bigskip}
\setlength\parindent{0pt}
\begin{document}
\begin{sideletter}{imagen}{20pt}
\lipsum[4]
\end{sideletter}
\begin{sideletter}{imagen}{35pt}
\lipsum[6]
\end{sideletter}
\begin{sideletter*}
\lipsum[7]
\end{sideletter*}
\end{document}
which needs a graphic file.
This is a result:

This is almost what I want. A paragraph on the right, with some text in the margin as a title, and at the bottom of the paragraph, some picture on the left margin.
My problem is that the base of the picture is not align with the baseline because, I think, \includegraphics inside a \tikz command considers the origin at the center of the picture. I want the picture to be aligned with the baseline of the paragraph as in the third example with the word 'text'.
\tikz[baseline=0pt] \node[anchor=south, inner sep=0pt] at (0,0) {\foot};– JLDiaz Feb 13 at 17:49texto \tikz[baseline=0pt]{\includegraphics[width=60pt]{imagen}};withoutnodethen the image is aligned to the baseline as I would like in my environment, but the graphics is over the paragraph. However, if I usenodeas in\tikz[baseline=0pt] \node at (0,0) {\includegraphics[width=60pt]{imagen}};then the image is included putting the center of the picture at (0,0). – ernesto Feb 14 at 14:59