我有以下代码
\documentclass[8pt]{article}
\usepackage{enumerate}
\usepackage{multicol}
\usepackage[a4paper]{geometry}
\geometry{top=1.5cm, bottom=3cm, left=2cm, right=2cm}
\setlength\parindent{0pt}
\newenvironment{Word}[2]{
\vspace{2pt}
\textbf{words:}
\vspace{-7pt}
\begin{multicols}{#1}
\begin{enumerate}[#2]
}{\end{enumerate}\end{multicols}}
\begin{document}
\begin{Word}{4}{1.}
\item one
\item two
\item frghth
\item trh
\item trh
\item rthtrhrt
\item dfg
\item dfgdggr
\item rggrrrg
\item drgrgdrhdh
\item sgsdgdrgdr
\item grgrr
\item rgegreh
\item rgerger
\item rghrh
\item sgsdgdrgdr
\item grgrr
\item rgegreh
\item rgerger
\item rghrh
\end{Word}
\end{document}
这里我声明这里有一些列表,并开始枚举其项目。我怎样才能只集中枚举(在 pdf 中集中环境中和之下的所有内容\textbf{words:}
)?
为了更清楚,我想要的是这个:
答案1
我会使用两个嵌套的迷你页面,这样就不会出现分页符。此外,enumitem
比 更好enumerate
。
\documentclass{article}
\usepackage[a4paper]{geometry}
\usepackage{enumitem}
\usepackage{multicol}
\geometry{
top=1.5cm,
bottom=3cm,
left=2cm,
right=2cm,
showframe
}
\newenvironment{Word}[2]
{\par\noindent\begin{minipage}{\textwidth}
\vspace{2pt}
\textbf{words:}\par
\begin{center}
\begin{minipage}{.9\textwidth}
\begin{multicols}{#1}
\begin{enumerate}[label=#2,leftmargin=*]}
{\end{enumerate}\end{multicols}\end{minipage}\end{center}\end{minipage}}
\begin{document}
\begin{Word}{4}{\arabic*.}
\item one
\item two
\item frghth
\item trh
\item trh
\item rthtrhrt
\item dfg
\item dfgdggr
\item rggrrrg
\item drgrgdrhdh
\item sgsdgdrgdr
\item grgrr
\item rgegreh
\item rgerger
\item rghrh
\item sgsdgdrgdr
\item grgrr
\item rgegreh
\item rgerger
\item rghrh
\end{Word}
\end{document}
该showframe
选项仅显示文本块的边界。
如果你想允许分页符,你必须检查第一行不在底部(在 之前避免可行的分页符并不容易\begin{multicol}
)。将环境更改为
\newenvironment{Word}[2]
{\par\vspace{2pt}
\noindent\textbf{words:}\par
\setlength{\columnsep}{-1.5em}
\begin{multicols}{#1}
\begin{enumerate}[label=#2,leftmargin=\dimexpr1cm+1.5em\relax,rightmargin=1cm]}
{\end{enumerate}\end{multicols}}
答案2
你是这个意思吗?
\documentclass[8pt]{article}
\usepackage{enumerate}
\usepackage{multicol}
\usepackage[a4paper]{geometry}
\geometry{top=1.5cm, bottom=3cm, left=2cm, right=2cm}
\setlength\parindent{0pt}
\newenvironment{Word}[2]{
\centering
\vspace{2pt}
\textbf{words:}
\vspace{-7pt}
\begin{multicols}{#1}
\begin{enumerate}[#2]
\centering
}{\end{enumerate}\end{multicols}}
\begin{document}
\begin{Word}{4}{1.}
\item one
\item two
\item frghth
\item trh
\item trh
\item rthtrhrt
\item dfg
\item dfgdggr
\item rggrrrg
\item drgrgdrhdh
\item sgsdgdrgdr
\item grgrr
\item rgegreh
\item rgerger
\item rghrh
\item sgsdgdrgdr
\item grgrr
\item rgegreh
\item rgerger
\item rghrh
\end{Word}
\end{document}