![使用多列内枚举的全宽](https://linux22.com/image/375021/%E4%BD%BF%E7%94%A8%E5%A4%9A%E5%88%97%E5%86%85%E6%9E%9A%E4%B8%BE%E7%9A%84%E5%85%A8%E5%AE%BD.png)
在我的文档中,我需要一些文本应以全文本宽度出现,即,\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}