将项目符号与段落文本对齐

将项目符号与段落文本对齐

我使用图形作为要点。我希望图像位于文本的中心,而不是文本的顶部。例如,这是我的代码:

    \documentclass[letterpaper,12pt]{article}
    \usepackage{graphicx}
    \usepackage{enumitem}
    \newcommand*{\drugs}{%
 \item[{\includegraphics[width=1.2cm]{figs/drugs.png}}]%
} \newcommand*{\mental}{%
 \item[{\includegraphics[width=1.2cm]{figs/mentalhealth.png}}]%
}\newcommand*{\nut}{%
 \item[{\includegraphics[width=1.2cm]{figs/nutandfit.png}}]%
}\newcommand*{\care}{%
 \item[{\includegraphics[width=1.2cm]{figs/care.png}}]%
}\newcommand*{\health}{%
 \item[{\includegraphics[width=1.2cm]{figs/healthicon.png}}]%
}\newcommand*{\economy}{%
 \item[{\includegraphics[width=1.2cm]{figs/economy.png}}]%
}

 \begin{document}
 \textbf{\textit{Health Priorities}}
 \begin{itemize}
\drugs \textbf{\textit{Substance Abuse and Misuse}} includes the use of alcohol, tobacco and e-cigarettes, prescription drugs, opioids and other drugs in a manner that is harmful, or causes problems or distress, to a person's health and/or daily life. 
\mental \textbf{\textit{Mental Health}} is the connection between mental illness, community stigma, social and community support, resiliency, and overall mental and emotional well-being. 
\nut \textbf{\textit{Nutrition and Physical Activity}} means the ability to access nutrition, physical activity and supportive resources for families and communities. 
 \end{itemize}

 \textbf{\textit{Social Determinants of Health}}
 \begin{itemize}
\economy \textbf{\textit{Economic stability }} influences the ability to access both mental and physical healthcare, nutritious foods, and physical activity opportunities. 
\care \textbf{\textit{Health care and quality/access to care}} means having equal access to convenient, quality, and affordable care for all that is trauma informed and culturally responsive. This includes factors such as proximity to care, diversity training for staff, diverse backgrounds of providers, cost of care, insurance coverage, medical transportation, and care coordination within the health care system.  
\health \textbf{\textit{Education}} influences mental and physical heath, economic stability, access to healthcare, substance abuse and misuse, and health equity.  
\end{itemize}

这将生成如下 PDF 格式的文件: 在此处输入图片描述

我希望它看起来像这样: 在此处输入图片描述

答案1

图形与文本使用两个并排的垂直对齐方式minipages。文本通过每个命令中定义的强制参数插入。

最后,使用全局设置使图形与左边距齐平itemize

\setlist[itemize]{<options>}

新定义的长度\LabWidth允许您选择图像的宽度。

无论文本的行数或图形的宽度如何,解决方案都将保持所请求的对齐(试试看!)。

C

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

\usepackage{showframe}% ONLY to show the margins

\newlength{\LabWidth}
\setlength{\LabWidth}{1.2cm}% set the labels widths <<<<<<<<<<<<<<

\newcommand*{\drugs}[1]{%
\item[{\begin{minipage}{\linewidth}\includegraphics[width=\LabWidth]{example-image-a}\end{minipage}}]
\begin{minipage}{\linewidth}#1\end{minipage}
}

\newcommand*{\mental}[1]{% changed <<<<<<
\item[{\begin{minipage}{\linewidth}\includegraphics[width=\LabWidth]{example-image-b}\end{minipage}}]
\begin{minipage}{\linewidth}#1\end{minipage}
}

\newcommand*{\nut}[1]{%changed <<<<<<
\item[{\begin{minipage}{\linewidth}\includegraphics[width=\LabWidth]{example-image-c}\end{minipage}}]
\begin{minipage}{\linewidth}#1\end{minipage}
}

\newcommand*{\care}[1]{%changed <<<<<<
\item[{\begin{minipage}{\linewidth}\includegraphics[width=\LabWidth]{example-image-b}\end{minipage}}]
\begin{minipage}{\linewidth}#1\end{minipage}
}

\newcommand*{\health}[1]{%changed <<<<<<
\item[{\begin{minipage}{\linewidth}\includegraphics[width=\LabWidth]{example-image-c}\end{minipage}}]
\begin{minipage}{\linewidth}#1\end{minipage}
}

\newcommand*{\economy}[1]{%changed <<<<<<
\item[{\begin{minipage}{\linewidth}\includegraphics[width=\LabWidth]{example-image-a}\end{minipage}}]
\begin{minipage}{\linewidth}#1\end{minipage}
}

\setlist[itemize]{align=parleft, labelwidth=\LabWidth, leftmargin =\dimexpr\labelwidth+\labelsep\relax}% global setting

\begin{document}
    \textbf{\textit{Health Priorities}}
    
    \begin{itemize}
        \drugs{\textbf{\textit{Substance Abuse and Misuse}} includes the use of alcohol, tobacco and e-cigarettes, prescription drugs, opioids and other drugs in a manner that is harmful, or causes problems or distress, to a person's health and/or daily life. }           
        \mental{\textbf{\textit{Mental Health}} is the connection between mental illness, community stigma, social and community support, resiliency, and overall mental and emotional well-being.}             
        \nut{\textbf{\textit{Nutrition and Physical Activity}} means the ability to access nutrition, physical activity and supportive resources for families and communities.}
    \end{itemize}
    
    \textbf{\textit{Social Determinants of Health}}

    \begin{itemize}
        \economy{\textbf{\textit{Economic stability}} influences the ability to access both mental and physical healthcare, nutritious foods, and physical activity opportunities.}
        \care{\textbf{\textit{Health care and quality/access to care}} means having equal access to convenient, quality, and affordable care for all that is trauma informed and culturally responsive. This includes factors such as proximity to care, diversity training for staff, diverse backgrounds of providers, cost of care, insurance coverage, medical transportation, and care coordination within the health care system.}
        \health{\textbf{\textit{Education}} influences mental and physical heath, economic stability, access to healthcare, substance abuse and misuse, and health equity.}
    \end{itemize}

\end{document}

由于代码定义了 6 个几乎相同的命令,因此可以使用一个带有两个必需参数的命令来简化:第一个命令带有图像名称,第二个命令带有文本。例如

\newcommand{\itemx}[2]{%
        \item[{\begin{minipage}{\linewidth}\includegraphics[width=\LabWidth]{figs/#1.png}\end{minipage}}]
    \begin{minipage}{\linewidth}#2\end{minipage}
}
    

因此你可以将其用于教育

\itemx{healthicon}{\textbf{\textit{Education}} influences mental and physical heath, economic stability, access to healthcare, substance abuse and misuse, and health equity.}  
    

相关内容