Wrapfig 更改所有后续 itemize 环境的缩进

Wrapfig 更改所有后续 itemize 环境的缩进

我试图将大量信息放入一页,包括项目符号和右侧的侧边栏(我不在乎侧边栏是否占满整个页面)。我知道 wrapfig 和 itemize 不能很好地协同工作,但我没有找到任何可以像 wrapfig 一样对侧边栏起作用的东西。有些环境无法处理\subsubsection*。multicols 不支持可变宽度的列。vwcols 很接近,但它目前甚至无法正确地处理宽度,如果我能让 wrapfig 工作,我不想在它上面投入时间。欢迎提出任何进一步的想法。

编辑:显然我没有仔细阅读 vwcols 文档。这是另一个不能很好地处理节/项目符号的环境。

\documentclass[]{article}

\usepackage{enumitem}
\usepackage[showframe=true]{geometry}
\usepackage{hanging}
\usepackage{wrapfig}

\begin{document}

\begin{wrapfigure}{r}{0.2\linewidth}

    \raggedright

    \vspace{-1.75em}
    \subsubsection*{Sidebar}
    \begin{hangparas}{1em}{1}
        A list

        A few of the items are long

        Other items aren't
    \end{hangparas}

\end{wrapfigure}

\section*{Main Document}

\subsection*{A Section}

\begin{itemize}
    \item Why does this fail?
\end{itemize}

\vspace{1cm}

\subsection*{Another Section}

\setlist{leftmargin=5mm}

\begin{itemize}
    \item Even after setting the left margin it still fails to indent appropriately
\end{itemize}

\end{document}

答案1

棘手的一点是,我\smash不喜欢小页面里面的东西,所以我使用了保存箱。

\documentclass[]{article}

\usepackage{enumitem}
\usepackage[showframe=true]{geometry}
\usepackage{hanging}
%\usepackage{wrapfig}

\newsavebox{\tempbox}

\begin{document}
\savebox{\tempbox}{\begin{minipage}[t]{0.2\textwidth}

    \raggedright

    \vspace{-1.75em}
    \subsubsection*{Sidebar}
    \begin{hangparas}{1em}{1}
        A list

        A few of the items are long

        Other items aren't
    \end{hangparas}

\end{minipage}}% something in here is incomplatible with \smash
\null\hfill\llap{\smash{\usebox\tempbox}}\par\vskip-\baselineskip

\section*{Main Document}

\subsection*{A Section}

\begin{itemize}
    \item Why does this fail?
\end{itemize}

\vspace{1cm}

\subsection*{Another Section}

\setlist{leftmargin=5mm}

\begin{itemize}
    \item Even after setting the left margin it still fails to indent appropriately
\end{itemize}

\end{document}

答案2

John Kormylo 的回答很有帮助,但是主页上的长行会覆盖侧边栏的顶部。最后,我只使用了几个小页面。 在此处输入图片描述

\documentclass[]{article}

\usepackage[showframe=true]{geometry}
\usepackage{hanging}

\begin{document}

\noindent\begin{minipage}[t]{0.78\textwidth}

    \section*{Main Page}

    \begin{itemize}
        \item Happily this will continue to work even when there's a very long line with lots of text
    \end{itemize}

    It also works... \hfill ...with hfill

    \subsection*{Another Section}

    \begin{itemize}
        \item Some people might not like that this will continue to cause wrapping even below the sidebar. Sorry.
    \end{itemize}

\end{minipage}
\hfill
\begin{minipage}[t]{0.2\textwidth}

    \raggedright

    \subsubsection*{Sidebar}
    \begin{hangparas}{1em}{1}
        A list

        A few of the items are long

        Other items aren't
    \end{hangparas}

\end{minipage}

\end{document}

相关内容