Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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: 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'.

share|improve this question
    
Hi ernesto. Note that you don't have to sign with your name since it automatically appears in the lower right corner of your post. –  Claudio Fiandrino Feb 13 '13 at 17:31
2  
Try \tikz[baseline=0pt] \node[anchor=south, inner sep=0pt] at (0,0) {\foot}; –  JLDiaz Feb 13 '13 at 17:49
    
There is no difference. I don't understand well the behavior. If I use texto \tikz[baseline=0pt]{\includegraphics[width=60pt]{imagen}}; without node then the image is aligned to the baseline as I would like in my environment, but the graphics is over the paragraph. However, if I use node as 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 '13 at 14:59

1 Answer 1

up vote 2 down vote accepted

Ok, I have found what I wanted. That was a problem with marginfigure enviroment. I had to use marginpar so my environment is:

\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}%
{\marginpar{%
\hfill\tikz[baseline=0pt]\node[anchor=base] {\foot};}
\bigskip}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.