mardi 2 décembre 2014

Removing indentation from macro


I've created two macros for my math book project. One is an enumerate environment that numbers problems as "Example 1.1" and so on. The other is a command that writes metadata about each problem to a text file.


The problem is that for some reason when I combine these two macros, there's an unnecessary indentation that I'm not sure how to get rid of.



\documentclass{article}

\newcounter{myenumi}
\renewcommand{\themyenumi}{\textbf{Example \thesection.\arabic{myenumi}.}}
\newenvironment{myenumerate}{%
% stuff for beginning of environment goes here
\setlength{\parindent}{0pt}% don't indent paragraphs
\setcounter{myenumi}{0}% restart numbering
\bigskip% skip a line
\renewcommand{\item}{% new definition of item
\par% start a new line
\medskip
\refstepcounter{myenumi}% advance counter
\makebox[8em][l]{\themyenumi}% print counter to width of 3em, aligned to left
}% end of definition of item
}{% at end of environment
\par% start new paragraph
\bigskip% skip a line
\noindent% don't indent new paragraph
\ignorespacesafterend% ignore spaces after environment
}

\makeatletter
\newwrite\@datawrite
\immediate\openout\@datawrite=\jobname.data

\newcommand\exampledata[3]{%
\immediate\write\@datawrite{Example \thesection.\theenumi}
\immediate\write\@datawrite{Source: #1}
\immediate\write\@datawrite{Checked: #2}
\immediate\write\@datawrite{Difficulty: #3}
\immediate\write\@datawrite{}}

\AtEndDocument{\closeout\@datawrite}

\makeatother

\begin{document}
\section{A section}

\begin{myenumerate}
\item
\exampledata{A nice book}{yes}{easy}
Show that $a=b$.
\item
\exampledata{Another nice book}{no}{impossible}
Show that $c=d$.
\end{myenumerate}

\begin{enumerate}
\item
\exampledata{A nice book}{yes}{easy}
Show that $a=b$.
\item
\exampledata{Another nice book}{no}{impossible}
Show that $c=d$.
\end{enumerate}

\end{document}


The problem is that for the first items, Example 1.1 and Example 1.2, there's an indentation before the problem statement that I do not want. Could someone help me get rid of it?


Thanks in advance for the help. Here's a picture of the above document.


enter image description here





Aucun commentaire:

Enregistrer un commentaire