在自定义命令内换行文档中的文本

在自定义命令内换行文档中的文本

我创建了一个自定义命令,如下所示:

\newcommand{\projectSubheading}[3]{
%  \vspace{-1pt}
  \item
    \begin{tabular*}{0.97\textwidth}[t]{l@{\extracolsep{\fill}}r}
      \textbf{#1} & #2 \\
      \textit{\small#3}
    \end{tabular*}
    %\vspace{-5pt}
}

我将 3 个字段传递给命令

    \projectSubheading
          {Multipurpose Unmanned Autonomous Vehicle \href{https://github.com/}{\faGithub}{Arizona, US}
{Relevant Coursework: Artificial Intelligence, Data Structure and Algorithms, System Programming and Operating Systems, Computer Networks, Soft Computing, Digital Signal Processing}

输出内容不适合该页面:

在此处输入图片描述

我怎样才能将文本换行到命令中?

答案1

似乎没有必要将内容放在tabular类似 - 的环境中。相反,下面的定义\projectSubheading使用\hfill来扩展前两个参数,并将最后一个参数设置为单独的段落。

在此处输入图片描述

\documentclass{article}

\usepackage{hyperref,fontawesome}

\newenvironment{projects}
  {\begin{itemize}}
  {\end{itemize}}

% \projectSubheading{<project>}{<location>}{<description>}
\newcommand{\projectSubheading}[3]{%
  \item
    \textbf{#1} \hfill #2 \par
    \itshape\small #3
}

\begin{document}

\begin{projects}

  \projectSubheading
    {Multipurpose Unmanned Autonomous Vehicle \href{https://github.com/}{\faGithub}}% Project
    {Arizona, US}% Location
    {Relevant Coursework: Artificial Intelligence, Data Structure and Algorithms, 
      System Programming and Operating Systems, Computer Networks, Soft Computing, Digital Signal Processing}% Description

\end{projects}

\end{document}

相关内容