线扩展空间独立

线扩展空间独立

我正在尝试设置独立于内容的行距。但我不知道该怎么做。我需要教授 1 和教授 2 之间有一个空格

这是 MWE。

\documentclass[a4paper,12pt]{report}
\usepackage{geometry}
\geometry{margin=2.5cm}
\usepackage{kantlipsum}
\linespread{1.2}


%-------------Title Chap & Section------------------------
\usepackage{titlesec}

\titleformat{\section}[block]{\filleft\bfseries\Large}{\thesection.}{0.5em}{}
\titleformat{\subsection}[block]{\filleft\bfseries\large}{\thesection.}{0.5em}{}
\titleformat{\subsubsection}[block]{\filleft\bfseries\large}{\thesection.}{0.5em}{}


\titleformat
{\chapter}                       % command
[display]                        % shape
{\Huge\bfseries\raggedleft}      % format
{}                               % label
{22pt}                           % separation between label and chapter-title
{\Huge}[\vspace{1ex}]            % before-code

\titleformat
{\section}                       % command
[display]                        % shape
{\Huge\bfseries\raggedleft}      % format
{}                               % label
{25pt}                           % separation between label and chapter-title
{\Huge}[\vspace{2ex}]            % before-code

% \titleformat{\section}{\bfseries\Large\raggedleft}{}{0.5em}{}
\titleformat{\subsection}{\bfseries\normalsize\raggedleft}{}{0.5em}{}
\titleformat{\subsubsection}{\bfseries\normalsize\raggedleft}{}{0.5em}{}

\titlespacing*{\chapter}{0pt}{\baselineskip}{\baselineskip}
\titlespacing*{\section}{0pt}{4ex}{1ex}
\titlespacing*{\subsection}{0pt}{0pt}{1ex}
\titlespacing*{\subsubsection}{0pt}{0pt}{6ex}

\newcommand{\autor}[1]{\textbf{\Large {#1}}\medskip\par}
\newcommand{\scoala}[1]{\textit{\normalsize{#1}}\medskip\par}
\newcommand{\prof}[1]{\textit{\small prof. coord. {#1}}\\ \smallskip}


\begin{document}
    \chapter{Chapter 1}
    \begin{flushright}
        \autor{Author 1}
        \scoala{Name of School}
        \prof{Professor 1}
        \prof{Professor 2}
    \end{flushright}
\kant[1]
\end{document}

答案1

我建议修改\prof命令以接受以 分隔的完整名称列表\\

\newcommand{\prof}[1]{%
  \par\begingroup\linespread{1}\small\itshape
  \begin{tabular}[t]{@{}r@{}}#1\end{tabular}%
  \par\endgroup\smallskip
}

该文件的代码为

\begin{document}
    \chapter{Chapter 1}
    \begin{flushright}
        \autor{Author 1}
        \scoala{Name of School}
        \prof{Professor 1 \\ Professor 2}
    \end{flushright}
\kant[1]
\end{document}

在此处输入图片描述

您可能更喜欢键值方法,它的优点是不要求键的特定顺序;但是prof将尊重多个键出现的顺序。

\documentclass[a4paper,12pt]{report}
\usepackage{geometry}
\usepackage{titlesec}

\usepackage{kantlipsum}

% page setup
\geometry{margin=2.5cm}
\linespread{1.2}


%-------------Title Chap & Section------------------------

\titleformat{\section}[block]{\filleft\bfseries\Large}{\thesection.}{0.5em}{}
\titleformat{\subsection}[block]{\filleft\bfseries\large}{\thesection.}{0.5em}{}
\titleformat{\subsubsection}[block]{\filleft\bfseries\large}{\thesection.}{0.5em}{}


\titleformat
{\chapter}                       % command
[display]                        % shape
{\Huge\bfseries\raggedleft}      % format
{}                               % label
{22pt}                           % separation between label and chapter-title
{\Huge}[\vspace{1ex}]            % before-code

\titleformat
{\section}                       % command
[display]                        % shape
{\Huge\bfseries\raggedleft}      % format
{}                               % label
{25pt}                           % separation between label and chapter-title
{\Huge}[\vspace{2ex}]            % before-code

% \titleformat{\section}{\bfseries\Large\raggedleft}{}{0.5em}{}
\titleformat{\subsection}{\bfseries\normalsize\raggedleft}{}{0.5em}{}
\titleformat{\subsubsection}{\bfseries\normalsize\raggedleft}{}{0.5em}{}

\titlespacing*{\chapter}{0pt}{\baselineskip}{\baselineskip}
\titlespacing*{\section}{0pt}{4ex}{1ex}
\titlespacing*{\subsection}{0pt}{0pt}{1ex}
\titlespacing*{\subsubsection}{0pt}{0pt}{6ex}

\ExplSyntaxOn

\NewDocumentCommand{\chapterdata}{m}
 {
  \begin{flushright}
  \keys_set:nn { mafsi/chapterdata } { #1 }
  \mafsi_chapterdata:
  \end{flushright}
 }

\keys_define:nn { mafsi/chapterdata }
 {
  autor  .tl_set:N = \l_mafsi_chapterdata_autor_tl,
  scoala .tl_set:N = \l_mafsi_chapterdata_scoala_tl,
  prof   .code:n = \seq_put_right:Nn \l_mafsi_chapterdata_prof_seq { #1 },
 }
\seq_new:N \l_mafsi_chapterdata_prof_seq

\cs_new:Nn \mafsi_chapterdata:
 {
  \textbf{\Large\l_mafsi_chapterdata_autor_tl}
  \par\medskip
  \textit{\normalsize\l_mafsi_chapterdata_scoala_tl}
  \par\medskip
  \linespread{1}\small\itshape
  \seq_use:Nn \l_mafsi_chapterdata_prof_seq { \\ }
 }

\ExplSyntaxOff


\begin{document}

\chapter{Chapter 1}
\chapterdata{
  autor=Author 1,
  scoala=Name of School,
  prof=Professor 1,
  prof=Professor 2,
}

\kant[1]

\end{document}

你会得到相同的输出

\chapterdata{
  prof=Professor 1,
  prof=Professor 2,
  autor=Author 1,
  scoala=Name of School,
}

或其变体。

相关内容