# Custom itemize alignment

I intend to combine the itemize environment with the minipage environment to prevent paragraphs from appearing on separate pages, but as a result the alignment of the bullet and the text changes from

to

To clarify, I'm looking for a way to combine minipage and itemize/enumerate like the code below to get the same spacing between the bullet and text as in the first example.

\documentclass{article}
\begin{document}
\begin{itemize}
\item
\begin{minipage}{\textwidth}
Lorem\\
Ipsum
\end{minipage}
\end{itemize}
\end{document}


EDIT: The option [t] for minipage has been suggested, and generally works, but is not fully compatible with other environments. When pairing it with the array environment as follows, the bullet resets to a centered position.

\documentclass{article}
\begin{document}
\begin{itemize}
\item
\begin{minipage}[t]{\textwidth}
$\begin{array}{rcl} x &=& y\\ y &=& x\\ 2x &\neq& 5y \end{array}$
\end{minipage}
\end{itemize}
\end{document}


Using option [t] for minipage does the trick:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{lipsum}
\usepackage{enumerate}
\begin{document}
\begin{itemize}
\item
\begin{minipage}[t]{\linewidth} % Thanks to Bernard
\lipsum[1]

\lipsum[2]
\end{minipage}
\end{itemize}
\lipsum[3]
\end{document}


Note: The \usepackage[showframe]{geometry} is only for showing margin, you can delete it in actual document.

### Edit:

As for the conflict:

The reason for the conflicts is that the whole array environment is considered to be an element, like a letter in the line, which means the array environment will be "centerized" with the first line.

A quick and tricky way to solve this:

\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{itemize}
\item
\begin{minipage}[t]{\linewidth}
\raisebox{-\baselineskip}{$\begin{array}{rcl} x &=& y\\ y &=& x\\ 2x &\neq& 5y \end{array}$}
\end{minipage}
\end{itemize}
\end{document}


A standard solution for the array: We use [t] once again (thanks to koleygr):

\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{itemize}
\item
\begin{minipage}[t]{\linewidth}
$\begin{array}[t]{rcl} x &=& y\\ y &=& x\\ 2x &\neq& 5y \end{array}$
\end{minipage}
\end{itemize}
\end{document}


• Even with the simpler \begin{minipage}[t]{\textwidth}, it works. – Bernard Mar 4 at 14:10
• @Bernard Yes, but for the OP's example only. If he/she has a paragraph in the item, we have to do some calculations so that it doesn't get "Overfull hbox...". Warnings are not fatal, but they annoy me ;-) and the output is bad then. – user156344 Mar 4 at 14:11
• That's right, but check what happens replacing \textwidth with \linewidth. No \dimexpr necessary. – Bernard Mar 4 at 14:15
• For the array a \begin{array}[t] should work too – koleygr Mar 4 at 14:56
• welcome... We all learn every day... (You already have my +1) – koleygr Mar 4 at 15:00

What I would do is this:

\documentclass{article}
\usepackage{lipsum}
\newsavebox{\mybottombox} % Box to save the text of the command
\newlength{\mybottomlength} % The length of our text inside the command
\newlength{\availafter} % The available length left on the page after placing our text

% Optional argument is the minimum length after the nobottom text for not pagebreak. Change it to your needs
\newcommand{\mnobreak}[2][0pt]{\savebox{\mybottombox}{\vbox{#2}}\setlength{\mybottomlength}{\ht\mybottombox}%
\setlength{\availafter}{\dimexpr\textheight-\mybottomlength-\pagetotal\relax}\ifdim\availafter<#1%
\pagebreak\noindent\usebox{\mybottombox}%
\else%
\noindent\usebox{\mybottombox}%
\fi%
}%

\begin{document}
\lipsum[1-4]

To clarify, I'm looking for a way to combine minipage and itemize/enumerate like the code below to get the same spacing between the bullet and text as in the first example. To clarify, I'm looking for a way to combine minipage and itemize/enumerate like the code below to get the same spacing between the bullet and text as in the first example.

\begin{itemize}
\item \mnobreak{Lorem\\Lipsum\\Lorem\\Lipsum\\Lorem}
\end{itemize}
\end{document}


Remove the last Lorem to see that the item would break with it.