打印列表项时改变几何形状

打印列表项时改变几何形状

我已经使用 geometry 包更改了页面大小。一直使用 list 打印标签和缩进段落。我敢打赌,中的文本\item打印在文档的文本区域之外。也就是说,中的内容[#2]打印在左边距的左侧。

我还希望从下一行开始的段落为TAG.xxx

\documentclass[a4paper,10pt]{article}
\usepackage{geometry}

\ExplSyntaxOn

\NewDocumentEnvironment {Spar} { O{0.3cm} m }
  {
    \list {}
      {
        \setlength{\leftmargin}{#1}
        \setlength{\topsep}{0pt}
        \setlength{\partopsep}{0pt}
        \setlength{\parskip}{0pt}
      }
    \item[[#2]]
  }
    { \endlist }

\ExplSyntaxOff

\geometry { paperwidth=13cm, paperheight=21cm,
             left=8mm, right=8mm, top=8mm, bottom=8mm,
             includehead, includefoot }

\begin{document}

\begin{Spar}{TAG.1999-DEF8}
  PAR.Deligne Pierre, Etingof Pavel, et al., 1999; "Quantum Fields and
  Strings: A Course for Mathematicians."  Vol. 1-2. With Freed Daniel
  S., Jeffrey Lisa C., Kazhdan David, Morgan John W., Morrison David R.,
  Witten Edward.
\end{Spar}

\end{document}

答案1

您会发现使用起来更容易enumitem,但基本上这是一个描述列表,如果您复制更多的description设置,您将保留边缘内的标签。

在此处输入图片描述

我添加了粗体(复制自description)来突出显示标签,但显然可以删除。

\documentclass[a4paper,10pt]{article}
\usepackage{geometry}

\ExplSyntaxOn

\NewDocumentEnvironment {Spar} { O{0.3cm} m }
  {
    \list {}
      {
        \setlength{\leftmargin}{#1}
        \setlength{\topsep}{0pt}
        \setlength{\partopsep}{0pt}
        \setlength{\parskip}{0pt}
        \setlength{\labelwidth}{0pt}
        \setlength{\itemindent}{-\leftmargin}
        \renewcommand*\makelabel[1]{\hspace\labelsep
                                \normalfont\bfseries ##1}
      }
    \item[{[#2]}]
  }
    { \endlist }

\ExplSyntaxOff

\geometry { b5paper, 
  left=8mm, right=8mm, top=8mm, bottom=8mm,
  includehead, includefoot }

\begin{document}

\noindent X\dotfill X

\begin{Spar}{TAG.1999-DEF8}
  PAR.Deligne Pierre, Etingof Pavel, et al., 1999; "Quantum Fields and
  Strings: A Course for Mathematicians."  Vol. 1-2. With Freed Daniel
  S., Jeffrey Lisa C., Kazhdan David, Morgan John W., Morrison David R.,
  Witten Edward.
\end{Spar}

\noindent X\dotfill X

\end{document}

或者使用换行符(如前面的答案所示很多更容易做的enumitem是做同样的事情或多或少,但打包为style=newline

在此处输入图片描述

\documentclass[a4paper,10pt]{article}
\usepackage{geometry}

\ExplSyntaxOn

\NewDocumentEnvironment {Spar} { O{0.3cm} m }
  {
    \list {}
      {
        \setlength{\leftmargin}{#1}
        \setlength{\topsep}{0pt}
        \setlength{\partopsep}{0pt}
        \setlength{\parskip}{0pt}
        \setlength{\labelwidth}{0pt}
        \setlength{\itemindent}{-\leftmargin}
        \renewcommand*\makelabel[1]{\rlap{\parbox[b]{\linewidth}{\hspace*{\labelsep}
              \normalfont\bfseries ##1\endgraf\mbox{}
            }}
          \hspace{\leftmargin}
      }}
  \item[{[#2]}]
  }
    { \endlist }

\ExplSyntaxOff

\geometry { b5paper, 
  left=8mm, right=8mm, top=8mm, bottom=8mm,
  includehead, includefoot }

\begin{document}

\noindent X\dotfill X

\begin{Spar}{TAG.1999-DEF8}
  PAR.Deligne Pierre, Etingof Pavel, et al., 1999; "Quantum Fields and
  Strings: A Course for Mathematicians."  Vol. 1-2. With Freed Daniel
  S., Jeffrey Lisa C., Kazhdan David, Morgan John W., Morrison David R.,
  Witten Edward.
\end{Spar}

\noindent X\dotfill X

\end{document}

相关内容