# No line here to end inside custom environment

I wrote an "advanced" environment, but I am having problems if I put another environment inside:

\documentclass{article}

\usepackage{amsmath,amsfonts,amssymb,amsthm} % For math equations, theorems, symbols, etc
\usepackage{thmtools}

\newcommand{\separator}{\noindent\makebox[\linewidth]{\rule{\linewidth}{0.4pt}}}

\declaretheoremstyle[%
spaceabove=-6pt,%
spacebelow=6pt,%
qed=\qedsymbol%
]{myproofstyle}
\declaretheorem[name={Proof},style=myproofstyle,unnumbered,

\begin{document}

inside proof
\end{document}


I could fix this problem by adding text between \end{advanced} and \end{advancedproof} but there must be a better way to solve this problem. I can't seem to find the answer, as I tried to add newlines inside the environments without luck.

UPDATE

The proposed code messes up the behavior where there is no inner environment:

\documentclass{article}

\usepackage{amsmath,amsfonts,amssymb,amsthm} % For math equations, theorems, symbols, etc
\usepackage{thmtools}

\newcommand{\separator}{\noindent\makebox[\linewidth]{\rule{\linewidth}{0.4pt}}}

\declaretheoremstyle[%
spaceabove=-6pt,%
spacebelow=6pt,%
qed=\qedsymbol%
]{myproofstyle}
\declaretheorem[name={Proof},style=myproofstyle,unnumbered,

\begin{document}

inside proof

Inside advanced environment. But without any other internal environment

\end{document}

• The problem is \ifadvanced\\  which you should replace, e.g. with \ifadvanced\hbox{}\\  or something else properly ending the environment. – TeXnician Feb 9 '17 at 12:57
• I don't have much experience defining environments. I had to use a flag to be able to remove advanced environments and thus I made it work using the code above. Do you have an example of what you mean by properly ending the environment? – aaragon Feb 9 '17 at 13:07
• I meant something which does not prevent the line break, e.g. a \vspace*{}. – TeXnician Feb 9 '17 at 13:08

You could replace your code with the following. This just translates \\ to \vspace*{0pt}.

\documentclass{article}

\usepackage{amsmath,amsfonts,amssymb,amsthm} % For math equations, theorems, symbols, etc
\usepackage{thmtools}

\newcommand{\separator}{\noindent\makebox[\linewidth]{\rule{\linewidth}{0.4pt}}}

\declaretheoremstyle[%
spaceabove=-6pt,%
spacebelow=6pt,%
qed=\qedsymbol%
]{myproofstyle}
\declaretheorem[name={Proof},style=myproofstyle,unnumbered,

\begin{document}

inside proof

\newenvironment{advanced}{\ifadvanced\par\separator \small \fi}{\ifadvanced\vspace*{-.75em}\par\separator\par\fi}

• @aaragon I've updated my answer (last lines) to meet your needs. If you have another \parskip please adjust the vspace. – TeXnician Feb 9 '17 at 13:49