I've tried to create a new environment using minipage, which has the same vertical space between paragraphs as would be there when not using the minipage. What I have so far is:
\usepackage{boxedminipage} % had to use this to get minipage
\newlength{\currentparskip}
\newenvironment{minipageparskip}
{%
\setlength{\currentparskip}{\parskip}% save the value
\begin{minipage}{1.0\textwidth}% open the minipage
\setlength{\parskip}{\currentparskip}% restore the value
}%
{\end{minipage}}
\newenvironment{songverse}
{%
\begin{minipageparskip}{1.0\textwidth}%
\begin{center}%
}
{%
\end{center}%
\end{minipageparskip}%
\leavevmode \\%
}
However, in the line, where I first use this new environment, like this:
\begin{songverse}
...
Text
...
\end{songverse}
I get the following error:
! Missing number, treated as zero.
<to be read again>
}
\songverse ...in {minipageparskip}{1.0\textwidth }
\begin {center}
l.118 \begin{songverse}
At first I thought it was talking about the 1.0\textwidth
, but then I saw, that I have written that everywhere, where I used minipage
, so now I think it might not be that. I don't understand where else a number could be missing, leading to this error.
The minipageparskip
environment is actually copied from another SE post.
Ultimately, I want to have an environment, in which no pagebreak occurs and which contains a verse of a song.
How can I fix the error?
Example (samepage
not preventing the pagebreak within songverse)
Note: using xelatex
to compile.
\documentclass[12pt, a5paper]{extarticle}
\usepackage[
top=20mm,
bottom=20mm,
left=24mm,
right=24mm
]{geometry}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage[UTF8]{ctex}
% AUTOMATICAL PINYIN PHONETIC SCRIPT
\newfontfamily{\DVS}{DejaVu Sans}
\usepackage{xpinyin}
\xpinyinsetup{ratio={.6}, hsep={.5em plus .1em}, vsep={1.1em}, multiple={\color{red}}, pysep={.2em}, footnote=false, font=\DVS}
\newenvironment{songverse}
{%
\begin{samepage}%
\begin{center}%
}{%
\end{center}%
\end{samepage}%
}
\begin{document}
\begin{pinyinscope}
\begin{songverse}
无量心 生福报 无极限
无极限 生息息 爱相连
为何君视而不见
规矩定方圆
悟性 悟觉 悟空 心甘情愿
\end{songverse}
\begin{songverse}
放下 颠倒梦想 放下云烟
放下 空欲色 放下悬念
多一物 却添了 太多危险
少一物 贪嗔痴 会少一点
\end{songverse}
\begin{songverse}
若是缘 再苦味也是甜
若无缘 藏爱 在心田
尘世 藕断还丝连
回首一瞬间
种颗善因 陪你走好每一天
\end{songverse}
\begin{songverse}
唯有 心无挂碍 成就大愿
唯有 心无故 妙不可言
算天算\xpinyin{地}{di4} 算尽\xpinyin{了}{liao3} 从前
算不出 生死 会在哪一天
\end{songverse}
\begin{songverse}
勿生恨 点化虚空的眼
勿生怨 欢喜 不遥远
缠绕 欲望的思念
善恶一瞬间
心怀忏悔 陪你走好每一天
\end{songverse}
\begin{songverse}
再牢的谎言
却逃不过天眼
明日之前 心流离更远
浮云霎那间
障眼 人心渐离间
集苦连连 不断的出现
\end{songverse}
\begin{songverse}
无量心 生福报 无极限
无极限 生息息 爱相连
凡人却视而不见
规矩定方圆
悟性 悟觉 悟空 心甘情愿
\end{songverse}
\begin{songverse}
简简单单 陪你走好每一天
\end{songverse}
\end{pinyinscope}
\end{document}
\@parboxrestore
not to reset pasrskip see tex.stackexchange.com/questions/279856/… but why not justsamepage
environment?samepage
, I didn't know it. Unfortunately, in the resulting PDF the content within thesamepage
environment does still get split. Maybe it's my definition, which is wrong though:\newenvironment{songverse}{\begin{samepage} \begin{center}}{\end{center}\end{samepage}\leavevmode \\\\}
\leavevmode\\\\
is wrong in any case (don't you get underfull hbox badness 10000 warnings for each of those?) although that doesn't affect the splitting of the content.samepage
tells all "normal" latex constructs not to break, but as you have provided no example document it is not possible to test any answer. (It's always best to include an example document in a question)