我是 TeX 的新手,我正在尝试创建一个模板简历来学习 LaTeX 课程和新命令。
我想创建一个\iconsection
命令来获取 2 个值:第一,图标文件名或 pifont 符号,第二,部分的名称。例如Education
带有书本图标的部分。
我可以使用添加图标文件\titleformat
,但我不知道如何添加图像作为参数\section
\newcommand\SecImage{%
\llap{\makebox[3em][l]{%
\raisebox{-.65\totalheight}[0pt][0pt]{%
\includegraphics[width=2em]{example-grid-100x100pt}%
}%
}%
}%
}
\titleformat{\section}
{\normalfont\Large\bfseries}{}{0em}
{%
\setbox0=\hbox{\Large\bfseries\thesection\hspace{1em}}%
\SecImage\thesection\hspace{1em}\hangindent\wd0\strut#1\strut%
}
% i want something like this
\newcommand{\iconsection}[2]{%
\section{#1 image file path}[#2]%
}
\newcommand{\iconsection*}[2]{%
\section{#1 pifont symbol like ding{41}}[#2]%
}
提前致谢。
答案1
我终于弄清楚了如何在部分之前插入符号。为了对齐,我想我应该有更多的训练
\newcommand{\iconsection}[2]{%
\titleformat{\section} % Customise the \section command
{\Large\scshape\raggedright} % Make the \section headers large (\Large),
% small capitals (\scshape) and left aligned
{}{0em} % Can be used to give a prefix to all sections, like 'Section ...'
{#2} % Can be used to insert code before the heading
[\titlerule]
\section[#1]{#1}
}
pifont 符号的用法示例
\iconsection{Education}{\ding{45}}
\iconsection{Hobbies}{\includegraphics[width=12px]{hob} }