I have a custom environment that I reference. It seems that the indentation changes if I do not include a space before \label
(see MWE below). So, I have a few questions:
- Should it matter where
\label
is placed on a custom environment; could the environment be changed so that I don't have to put a space before\label
? - Is there a convention on where
\label
should be placed (on non-floating environments), or is this a matter of style? - Is there a preferred way of getting a line break rather than using
\newline
?
Please note that I do not want to use ntheorem
as the actual version I use takes 2 optional arguments (using newenvironmentx
from xargs
).
EDIT:
I am particularly interested in trying to answer my first question- could the definition of the environment be changed so that I don't have to put a space before \label
, or a %
after it? The ntheorem
package seems to accomplish it using trivlist
.
\documentclass{article}
\usepackage{lipsum}
\setlength{\parindent}{0mm}
\newcounter{problem}
\newenvironment{problem}%
{%
\refstepcounter{problem}%
\textbf{Problem \theproblem }\newline%
}{}
\begin{document}
\begin{problem}\label{firstlabel}
\lipsum[1]
\end{problem}
\begin{problem} \label{secondlabel}
\lipsum[1]
\end{problem}
\end{document}
Best Answer
\caption[..]{...}
, or more accurately, after\refstepcounter{...}
for correct labelling. Otherwise the label would refer to a previous instance of the most recent\refstepcounter{...}
that was executed.\par
or\endgraf
instead of\newline
.