如何列出清單中部分內容右對齊的項目?

如何列出清單中部分內容右對齊的項目?

我有一個附錄標題頁,我想在上面整齊地列出所有不同的附錄。這是我的程式碼:

\documentclass[letter,12pt]{article}
\usepackage{enumitem}

\begin{document}

\vfill

\LARGE\rmfamily\bfseries\centering APPENDICES

\noindent\textcolor{complement2}{\rule{0.75\textwidth}{2mm}}\par

\Large
\begin{enumerate}
    \item Appendix A\hfill CFD Results \\
    \item Appendix B\hfill Pump and Inlet Pipe Specifications\\
    \item Appendix C\hfill Technical Drawings \\
    \item Appendix D\hfill Cost Breakdown \\
    \item Appendix E\hfill Some super other different thing\\
\end{enumerate}

\vfill

\end{document}

本質上,我想用 . 分隔「附錄 X」和「標題」\hfill。但是,正如您所看到的,文字重疊並擴展到下一行。在此輸入影像描述

如何使“規格”右對齊?

答案1

您可以在環境enumerate中模擬環境tabularx

\documentclass[letter,12pt]{article}
\usepackage{enumitem}
\usepackage[svgnames]{xcolor}
\usepackage{tabularx}

\begin{document}

\vfill

\LARGE\rmfamily\bfseries\centering APPENDICES

\noindent\textcolor{Peru!90}{\rule{0.75\textwidth}{2mm}}\par
\vspace{\dimexpr\baselineskip + \topsep\relax}
\Large
\renewcommand\arraystretch{1.4}
\newcounter{tabenum}\setcounter{tabenum}{0}
\newcommand{\tabitem}{\stepcounter{tabenum}\,\thetabenum.\hspace{\labelsep}}
\begin{tabularx}{\linewidth}{l>{\raggedleft\arraybackslash}X@{}}
    \tabitem Appendix A & CFD Results \\
    \tabitem Appendix B & Pump and Inlet Pipe Specifications\\
    \tabitem Appendix C & Technical Drawings \\
    \tabitem Appendix D & Cost Breakdown \\
    \tabitem Appendix E & Some super other different thing
\end{tabularx}
\vfill

\end{document} 

在此輸入影像描述

添加:

另一種(語意上更清晰的)可能性在於使用套件的部分目錄功能titletoc:在附錄的開頭,您可以使用以下命令:

\appendix
\startcontents[appendices]
  \section{CFD Results}
  \section{Some  super other different thing}
\stopcontents[appendices]

並使用以下命令將其列印到任意位置:

\printcontents[appendices]{Appendix}{1}{}

相關內容