使用多列内枚举的全宽

使用多列内枚举的全宽

在我的文档中,我需要一些文本应以全文本宽度出现,即,\textwidth+\marginparwidth+\marginparsep为此我做了一些代码,如下所示:

\documentclass{book}
\usepackage{xcolor,framed,multicol}
\begin{document}

\makeatletter

\setlength\textwidth{144truemm}
\setlength\marginparsep{5truemm}
\setlength\marginparpush{6\p@}
\setlength\marginparwidth{28truemm}

\newenvironment{splcolorshaded}{%
  \def\FrameCommand{\fboxsep=\FrameSep%
\ifodd\c@page\hskip\marginparwidth\hskip\marginparsep\else%
\hskip-\iotextleftskip%
\hskip-\marginparwidth\hskip-\marginparsep\fi\colorbox{shadecolor}}%
  \MakeFramed {\FrameRestore}}%
 {\endMakeFramed}

\definecolor{testcolor}{cmyk}{0,0.07,0.05,0}%

\newenvironment{testcolorenv}{\bgroup%
\colorlet{shadecolor}{testcolor}%
\setlength{\FrameSep}{14\p@}%
\begin{splcolorshaded}\vspace*{-1\FrameSep}\vspace*{-1.45\p@}\advance\hsize\marginparwidth\advance\hsize\marginparsep%%
\advance\hsize-2\FrameSep%
\fontsize{8.5}{12.75}\sf\selectfont%
\nopagebreak\@afterheading\@afterindentfalse\nopagebreak}{\par\vphantom{y}\vspace*{-1\FrameSep}\end{splcolorshaded}\egroup}%

\makeatother

This is test for sublist. Explain how the kinetic energy of a substance
changes as it goes from a solid to a liquid to a gas.
(You learnt about kinetic energy in Year 10.)

\begin{testcolorenv}
This is test for sublist. Explain how the kinetic energy of a substance
changes as it goes from a solid to a liquid to a gas.
(You learnt about kinetic energy in Year 10.)
\begin{multicols}{2}
\begin{enumerate}
\item List the main assumptions of the kinetic
particle model.
Apply, analyse and interpret
\begin{enumerate}
\item This is test for sublist. Explain how the kinetic energy of a substance
changes as it goes from a solid to a liquid to a gas.
(You learnt about kinetic energy in Year 10.)
\end{enumerate}
\item Explain how the kinetic energy of a substance
changes as it goes from a solid to a liquid to a gas.
(You learnt about kinetic energy in Year 10.)
\item Solids and liquids can’t be compressed very
much. It takes large forces to compress them
even slightly. What can you infer about the
microscopic nature of solids and liquids from their
incompressibility?
\item Gases are very compressible compared with solids
and liquids. Conclude what this says about the
microscopic nature of gases.
\end{enumerate}
\end{multicols}
\end{testcolorenv}
\end{document}

如果是文本,那么它就会出现fullwidth,但如果我numbered list在环境中给出multicols,它就不会出现fullwidth,我该如何解决这个问题?

为了便于理解,输出如下所示...在此处输入图片描述

答案1

问题是multicols使用\linewidth而不是\hsize。您可能还应该设置\textwidth\columnwidth

\documentclass{book}
\usepackage{xcolor,framed,multicol}
\begin{document}

\makeatletter

\setlength\textwidth{144truemm}
\setlength\marginparsep{5truemm}
\setlength\marginparpush{6\p@}
\setlength\marginparwidth{28truemm}

\newenvironment{splcolorshaded}{%
  \def\FrameCommand{\fboxsep=\FrameSep%
\ifodd\c@page\hskip\marginparwidth\hskip\marginparsep\else%
\hskip-\iotextleftskip%
\hskip-\marginparwidth\hskip-\marginparsep\fi\colorbox{shadecolor}}%
  \MakeFramed {\FrameRestore}}%
 {\endMakeFramed}

\definecolor{testcolor}{cmyk}{0,0.07,0.05,0}%

\newenvironment{testcolorenv}{\bgroup
\colorlet{shadecolor}{testcolor}%
\setlength{\FrameSep}{14\p@}%
\begin{splcolorshaded}\vspace*{-1\FrameSep}\vspace*{-1.45\p@}\advance\hsize\marginparwidth\advance\hsize\marginparsep%%
\advance\hsize-2\FrameSep%
\linewidth=\hsize%****************   this is the only change
\fontsize{8.5}{12.75}\sf\selectfont%
\nopagebreak\@afterheading\@afterindentfalse\nopagebreak}{\par\vphantom{y}\vspace*{-1\FrameSep}\end{splcolorshaded}\egroup}%

\makeatother

This is test for sublist. Explain how the kinetic energy of a substance
changes as it goes from a solid to a liquid to a gas.
(You learnt about kinetic energy in Year 10.)

\begin{testcolorenv}
This is test for sublist. Explain how the kinetic energy of a substance
changes as it goes from a solid to a liquid to a gas.
(You learnt about kinetic energy in Year 10.)

\begin{multicols}{2}
\begin{enumerate}
\item List the main assumptions of the kinetic
particle model.
Apply, analyse and interpret
\begin{enumerate}
\item This is test for sublist. Explain how the kinetic energy of a substance
changes as it goes from a solid to a liquid to a gas.
(You learnt about kinetic energy in Year 10.)
\end{enumerate}
\item Explain how the kinetic energy of a substance
changes as it goes from a solid to a liquid to a gas.
(You learnt about kinetic energy in Year 10.)
\item Solids and liquids can’t be compressed very
much. It takes large forces to compress them
even slightly. What can you infer about the
microscopic nature of solids and liquids from their
incompressibility?
\item Gases are very compressible compared with solids
and liquids. Conclude what this says about the
microscopic nature of gases.
\end{enumerate}
\end{multicols}
\end{testcolorenv}
\end{document}

演示

相关内容