客製報價內的清單

客製報價內的清單

我想創建一個既可以在正文中也可以在我自己的引用中工作的自訂清單環境(在我的情況下,我稱為dialogue( list) 的環境位於我稱為myquotation( trivlist) 的環境內部)。但我在獲得預期的縮排方面遇到了麻煩。我的工作範例:

\documentclass{article}
\usepackage[paperwidth=12cm,paperheight=11cm]{geometry}
\usepackage{ifthen}

% quotes
\newenvironment{myquotation}
    {\begin{trivlist}
        \ifthenelse{\isodd{1}}
                   {\setlength\leftskip{6.5mm} \setlength\rightskip{0mm}}
                   {\setlength\leftskip{0mm} \setlength\rightskip{6.5mm}}
        \setlength\itemindent{\parindent}
        \item\relax \slshape}
    {\end{trivlist}}

% dialogues
\newcommand{\entrylabel}[1]{
    \ifthenelse{\equal{}{#1}}{
        \hfill\mbox{\small{\textsc{--}}}
    }{
        \mbox{\small{\textsc{#1:}}}
    }
}
\newenvironment{dialogue}{\list{}{\renewcommand{\makelabel}{\entrylabel}
                                  \itemsep=0cm \topsep=0cm \parsep=0cm
                                  \listparindent=0em}
                         }{\endlist}

\begin{document}
Dialogue inside the quotation (unwanted indentation of the first item):
\begin{myquotation}
    \begin{dialogue}
    \item[Cookiemonster] Om, om, om...
    \item[Roadrunner] Beep, beep, beep...
    \item[Reksio] Hau, hau, hau...
    \end{dialogue}

    Some text inside the quotation following short customized dialogue.
\end{myquotation}

Dialogue inside the quotation (solution that doesn't work by flexible
vertical distances between list items):
\begin{myquotation}
    \mbox{}\vspace{-\baselineskip}
    \begin{dialogue}
    \item[Cookiemonster] Om, om, om...
    \item[Roadrunner] Beep, beep, beep...
    \item[Reksio] Hau, hau, hau...
    \end{dialogue}
\end{myquotation}

Dialogue outside the quotation:
\begin{dialogue}
\item[Cookiemonster] Om, om, om...
\item[Roadrunner] Beep, beep, beep...
\item[Reksio] Hau, hau, hau...
\end{dialogue}
\end{document}

在此輸入影像描述

對我來說,最重要的是刪除報價單中第一項的縮排。最初,我考慮將行合併\mbox{}\vspace{-\baselineskip}到我的清單定義中(稱為此處dialogue),但在項目之間存在浮動空間以及清單周圍浮動垂直間距的情況下,它無法正常工作。

如何將以下列表項目自動移動到無縮排文字邊界的位置(如圖中綠色箭頭所指)?

答案1

\setlength\itemindent{\parindent}錯誤的縮排是由於您的 trivlist 中的錯誤造成的。另外,如果您希望對話環境根據等級而變化,最好外部環境也是一個清單。

我不知道你想要什麼垂直空間,所以我把它們全部刪除了。從長遠來看,使用 enumitem 套件定義此類清單會更好、更容易。

 \documentclass{article}
\usepackage[paperwidth=12cm,paperheight=11cm]{geometry}
\usepackage{ifthen}

% quotes

\newenvironment{myquotation}
    {\list{}{%
        \ifthenelse{\isodd{1}}
                   {\setlength\leftmargin{\parindent} \setlength\rightmargin{0mm}}
                   {\setlength\leftmargin{0mm} \setlength\rightmargin{6.5mm}}%
        \topsep=0cm \parsep=0cm \partopsep=0pt   \listparindent=0em
        }
        \item\relax \slshape
    }%
    {\endlist}

% dialogues
\newcommand{\entrylabel}[1]{%
    \ifthenelse{\equal{}{#1}}{%
        \hfill\mbox{\small{\textsc{--}}}%
    }{%
     \hspace\labelsep   \mbox{\small{\textsc{#1:}}}%
    }
}
\newenvironment{dialogue}{\list{}{\renewcommand{\makelabel}{\entrylabel}%
                                  \labelwidth0cm \itemindent-\leftmargin
                                  \topsep=0cm \parsep=0cm
                                  \partopsep=0pt
                                  \listparindent=0em
                                  }}{\endlist}

\begin{document}
Dialogue inside the quotation (unwanted indentation of the first item):

 \begin{myquotation}
 blblbl 
 \end{myquotation}


\begin{myquotation}
    \begin{dialogue}
    \item[Cookiemonster] Om, om, om...
    \item[Roadrunner] Beep, beep, beep...
    \item[Reksio] Hau, hau, hau...
    \item blbu
    \end{dialogue}

    Some text inside the quotation following short customized dialogue.
\end{myquotation}

Dialogue inside the quotation (solution that doesn't work by flexible
vertical distances between list items):
\begin{myquotation}
    \begin{dialogue}
    \item[Cookiemonster] Om, om, om...
    \item[Roadrunner] Beep, beep, beep...
    \item[Reksio] Hau, hau, hau...
    \end{dialogue}
\end{myquotation}

Dialogue outside the quotation:
\begin{dialogue}
\item[Cookiemonster] Om, om, om...
\item[Roadrunner] Beep, beep, beep...
\item[Reksio] Hau, hau, hau...
\end{dialogue}
\end{document}

在此輸入影像描述

相關內容