Based on an answer to one of my previous questions, I implemented the following code which is supposed to enumerate examples discretely in the margins of my document:
\documentclass{memoir}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath,amssymb,geometry,graphicx,amstext}
\usepackage[amsmath]{ntheorem}
% margin theorem
\makeatletter
\newtheoremstyle{mymargin}%
{\item[\theorem@headerfont \llap{##1 ##2}]}%
{\item[\theorem@headerfont \llap{##1 ##2}| ##3\theorem@separator\hskip\labelsep]}%
\makeatother
% my example
\theoremstyle{mymargin}
\newtheorem{example}{Example}
\numberwithin{example}{chapter}
\begin{document}
\begin{example}
\centering
\begin{tabular}{cccc}
this & is & a & test\\
table & where & text & goes
\end{tabular}
\end{example}
\end{document}
This produces the following output:
As you see, because the table is centered, the example number is not actually in the margins, which is my major concern. Furthermore, I would like the number to appear aligned with the top of the table and always on the same page as the table (which is not always the case either). Finally, I would like the number always to appear in the outer margin when the two-page option is on. How may this be fixed?
\begin{tabular}[t]
that resolves one of the issues- switching the margins is quite tricky and intricate- see Equation numbers in outer margins on a two-sided document for example