# Add vertical space before a \minipage

Is it possible to use a minipage with the a new line space before it in a single command?

Sample code here

\begin{minipage}[]{\linewidth}
\begin{minted}[linenos, frame=single]{java}
class Main {
public static void main(String[] args) {
/* code */
}
}
\end{minted}
\end{minipage}


If I don't use minipage I get the expected result

Sample code here

\begin{minted}[linenos, frame=single]{java}
class Main {
public static void main(String[] args) {
/* code */
}
}
\end{minted}


I would like to renew the minipage command (if it's possible) to add the new line before the minipage section. I'd prefer not to use \\ after "Sample code here" if possible.

• I might be overlooking your MWEs, but they both look exactly the same. – sztruks Oct 28 '17 at 18:55
• Right, my bad corrected! – fedemengo Oct 28 '17 at 18:56
• Why do you need that minipage around the minted block? – Skillmon Oct 28 '17 at 19:40
• Because if the code doesn't fit in the remaining page I don't want it to be displayed in a new page. I don't want the code to be splitted. – fedemengo Oct 28 '17 at 20:26
• So the real question is to avoid page breaks within minted environments? – Johannes_B Oct 29 '17 at 6:11