I'm working to a document in memoir and I'm struggling trying to define a new environment which would allow me to place a figure in the main text and its caption in the outer margin. This is an extract of my preamble without the definition of such environment.
\documentclass[10pt]{memoir} %document class
\setstocksize{240mm}{150mm}
\usepackage[T1]{fontenc} %font output
\usepackage[utf8]{inputenc} %font input
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{marginfix}
\usepackage{graphicx}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PAGE LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{geometry}
\let\footruleskip\undefined %headings
\usepackage{fancyhdr}
\nouppercaseheads
\settrimmedsize{240mm}{150mm}{*}
\setlength{\trimtop}{0pt}
\setlength{\trimedge}{\stockwidth}
\addtolength{\trimedge}{-\paperwidth}
\settypeblocksize{193mm}{84mm}{*}
\setulmargins{27mm}{*}{*}
\setlrmargins{18mm}{*}{*}
\setmarginnotes{3mm}{3.5cm}{\onelineskip}
\setheadfoot{\onelineskip}{\onelineskip}
\setlength{\headsep}{1.2cm}
%\setheaderspaces{*}{2\onelineskip}{*}
\checkandfixthelayout
\addtolength{\footskip}{0.55cm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CAPTION LAYOUT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{caption} %customized captions
\captionsetup{font=footnotesize, labelfont={bf}}
\usepackage{captdef}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FULLWIDTH
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[outermargin=-3.5cm]{fullwidth}
\newenvironment{fullwidthblocked}{%
\blockmargin%
\begin{fullwidth}%
}{%
\end{fullwidth}%
\unblockmargin%
}
I thought I could use fullwidthblocked to define the new environment, so I tried this solution
\newenvironment{figureDX}[1]{%
\begin{fullwidthblocked}%
\begin{minipage}{84mm}%
\centering%
#1%
\end{minipage}%
\hspace{1.5mm}%
\begin{minipage}{3.5cm}%
}{%
\end{minipage}%
\end{fullwidthblocked}%
}
which can be used in the main text writing
\begin{figureDX}{\includegraphics[scale=•]{•}}
\figcaption{•}\label{•}
\end{figureDX}
This actually works, but it is good only for odd pages, since it puts the caption to the right of the image. I then tried to adapt this few lines to introduce their even pages counterpart:
\newenvironment{figureSX}[1]{%
\begin{fullwidthblocked}%
\begin{minipage}{3.5cm}%
}{%
\end{minipage}%
\hspace{1.5mm}%
\begin{minipage}{84mm}%
#1%
\end{minipage}%
\end{fullwidthblocked}%
}
but this returns the error ! Illegal parameter number in definition of \endfigureSX. which I don't know how to solve.
I'm aware the solution I'm proposing is not elegant nor compact, but at least I'd like it to work.. Any ideas how could I fix this?
\newenvironmentdoes not allow you to access#1in the end part of the env. You can try usingxparseits enviroment creating tools can – daleif Dec 17 '18 at 10:59xparseas you suggested, and it works without problems with the rest of my preamble. Thank you so much! – truffles Dec 17 '18 at 11:40#1in the end part of a new environment declaration – daleif Dec 17 '18 at 12:10