I am having an issue with a custom environment where the first line of the environment gets a space preceding it. The example below illustrates the behevior. It seems to happen because of the newline character after \begin{oppg}
. It also seems to have something to do with the \noindent
in line 7, since removing it fixes the issue (but I don't want the line to be indented).
As you can see, the issue is easily fixed by adding a %
at the end of the line when i begin the environment, but it seems to me that there should be a more robust way of doing it. There is probably an obvious explanation for this, but I can't see it.
\documentclass{article}\newcounter{oppg}\newenvironment{oppg}{% \refstepcounter{oppg}% \par\noindent\textbf{Oppgave \theoppg}% \par\smallskip\noindent% }% {\bigbreak}%\begin{document}\begin{oppg}Lorem ipsum, et cetera...\end{oppg}\begin{oppg}%Lorem ipsum, et cetera...\end{oppg}\end{document}