
我打算將 itemize 環境與 minipage 環境結合起來,以防止段落出現在單獨的頁面上,但結果是項目符號和文字的對齊方式從
到
為了澄清這一點,我正在尋找一種將小型頁面和逐項/枚舉結合起來的方法,如下面的程式碼,以獲得與第一個範例中相同的項目符號和文字之間的間距。
\documentclass{article}
\begin{document}
\begin{itemize}
\item
\begin{minipage}{\textwidth}
Lorem\\
Ipsum
\end{minipage}
\end{itemize}
\end{document}
[t]
編輯:已建議使用小型頁面選項,並且通常可以工作,但與其他環境不完全相容。當如下將其與陣列環境配對時,子彈會重置到中心位置。
\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}
答案1
使用選項[t]
forminipage
可以解決這個問題:
\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}
筆記:僅\usepackage[showframe]{geometry}
用於顯示邊距,您可以在實際文件中將其刪除。
編輯:
至於衝突:
衝突的原因是整個array
環境被認為是一個元素,就像行中的字母一樣,這意味著array
環境將以第一行「居中」。
解決這個問題的一個快速而棘手的方法是:
\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}
標準解決方案array
:我們[t]
再次使用(感謝 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}
答案2
我要做的是這樣的:
\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}
移除最後一個 Lorem,看看物品是否會跟著破裂。
來源:我的舊答案這裡
輸出: