Skip to content

Instantly share code, notes, and snippets.

@wspr
Created October 16, 2010 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wspr/629640 to your computer and use it in GitHub Desktop.
Save wspr/629640 to your computer and use it in GitHub Desktop.
\documentclass{article}
\usepackage{framed,lipsum}
\newlength\colsize
\newlength\figcolsize
\setlength\colsize{8cm}
\setlength\figcolsize{8cm}
\newenvironment{twocol}{%
\def\FrameCommand##1{%
\hspace{-10cm}
##1%
}
\begin{MakeFramed}{%
\setlength\hsize{\colsize}%
}
}{%
\end{MakeFramed}%
}
\newcommand\marginfig[2][0pt]{%
\leavevmode
\smash{\makebox[0pt][l]{%
\hspace{\dimexpr(-\parindent+\colsize+\marginparsep)}%
\raisebox
{\dimexpr(#1+\baselineskip-\height)}
{\parbox{\figcolsize}{\centering #2}}%
}}%
}
\begin{document}
\lipsum[1-3]
\begin{twocol}
\lipsum[10]
\marginfig{\leftarrowfill figure column size is this big \rightarrowfill}
\lipsum[11]
\marginfig{\fbox{\rule{3cm}{3cm}}}
\lipsum[12]
\marginfig[-2cm]{\fbox{\fbox{\rule{2cm}{2cm}}}}
\lipsum[13-14]
\end{twocol}
\lipsum[20]
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment