# To make one environment flow into another without empty space

I have this design at the moment.

However, when you have many of those, they distract much.

I propose to have Answer just on the same line with Question like

Question 41 Lorem ipsun. Answer 38 Lorem again.

My tex

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}

\newtheorem{question}{Question}
\let\masiquestion\question
\AtBeginDocument{%
\let\umquestion\question
\let\question\masiquestion
}
\mdfdefinestyle{ans}{
linecolor=cyan,
backgroundcolor=yellow!20
}

\usepackage{environ}
\usepackage{ifthen}

{%
{%
\noindent
\begin{minipage}[t]{\linewidth}
\BODY
\end{minipage}%  here put what the command has to do when outside
}%
}%

\begin{document}
\begin{question}
Why is the pressure same in Arteries and aorta?
\end{question}
Because they do not coil (only arch of aorta), so the Frank-Starling equation does not hold but Laplace law instead.
Laplace law is the reason why you can have the same pressure in aorta (big) and arteries (small), because the pressure depends inversely on the pressure.

\end{document}


I am thinking what would be the right way of changing these Question and Answer environments. I do not want to remove them because they offer me flexibility. I just want to remove the empty line and put the answer flowing just flowing after the question.

How can you remove the space between the two environments?

-
question being in the color box too? –  percusse Mar 13 at 20:38
The \tcolorbox package might be worth to look at. –  Christian Hupfer Mar 13 at 20:40
@percusses color box is not necessary. It can be easily disabled. The easy way to read is most important without distracting the reader much. –  Masi Mar 13 at 20:45

I would recomend using the frametitle of the mdframed environment to show the question and the body to show the answer:

## Notes:

• You can probably select better colors.
• Also need to add the numbering if that is required.

## Code:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}

\mdfdefinestyle{ans}{
linecolor=cyan,
backgroundcolor=yellow!20,
frametitlebackgroundcolor=green!40,
frametitlerule=true,
}

\newenvironment{question}[1]{%
\begin{mdframed}[style=ans,frametitle={Question: #1}]
}{%
\end{mdframed}%
}%

\begin{document}
\begin{question}{Why is the pressure same in Arteries and aorta?}
Because they do not coil (only arch of aorta), so the Frank-Starling equation does not hold but Laplace law instead.
Laplace law is the reason why you can have the same pressure in aorta (big) and arteries (small), because the pressure depends inversely on the pressure.
\end{question}
\begin{question}{Why is the pressure same in Arteries and aorta?}
Because they do not coil (only arch of aorta), so the Frank-Starling equation does not hold but Laplace law instead.
Laplace law is the reason why you can have the same pressure in aorta (big) and arteries (small), because the pressure depends inversely on the pressure.
\end{question}
\end{document}

-
I had conflicting packages - problem solved. Thank you for your answer! –  Masi Mar 14 at 6:35

With tcolorbox:

\documentclass{article}
\usepackage[most]{tcolorbox}

\newtcolorbox[auto counter,number within=section]{question}[2][]{%
colback=magenta!15!white,colframe=blue!40!green,fonttitle=\bfseries,
title=Question.~\thetcbcounter: #2,#1}

\begin{document}
\section{Some section}

\begin{question}{Why is the pressure same in Arteries and aorta?}
Because they do not coil (only arch of aorta), so the Frank-Starling equation does not hold but Laplace law instead.
Laplace law is the reason why you can have the same pressure in aorta (big) and arteries (small), because the pressure depends inversely on the pressure.
\end{question}
\begin{question}{Why is the pressure same in Arteries and aorta?}
Because they do not coil (only arch of aorta), so the Frank-Starling equation does not hold but Laplace law instead.
Laplace law is the reason why you can have the same pressure in aorta (big) and arteries (small), because the pressure depends inversely on the pressure.
\end{question}
\end{document}


-

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}

\newtheorem{question}{Question}

\mdfdefinestyle{ans}{
linecolor=cyan,
backgroundcolor=yellow!20
}

\makeatletter
\def\endquestion{\ifhmode\unskip\fi\begingroup\let\par\relax}
\makeatother