在下面的代码中,我想添加在“雇主”/“职位”部分之后立即引入图片的选项。您知道我该如何实现这一点吗?(\newcommand 中的包+实现)。下面是所需结果的图片:
% Command for entering a new work position
\newcommand{\workposition}[5]{
{\raggedleft\textsc{#1\expandafter\ifstrequal\expandafter{#2}{}{}{\hspace{6pt}\footnotesize{(#2)}}}\par} % Duration and conditional full time/part time text
\expandafter\ifstrequal\expandafter{#3}{}{}{{\raggedright\large #3}\\}
% Employer
\expandafter\ifstrequal\expandafter{#4}{}{}{{\raggedright\large\textit{\textbf{#4}}}\\[4pt]} % Job title
\expandafter\ifstrequal\expandafter{#5}{}{}{#5\\} % Description
}
答案1
这是我使用 minipage 和 includegraphics 的解决方案:
\documentclass{article}
\usepackage{etoolbox}
\usepackage{graphicx}
\newcommand{\workposition}[6]{
{\raggedleft\textsc{#1\expandafter\ifstrequal\expandafter{#2}{}{}{
\hspace{6pt}\footnotesize{(#2)}}}\par
} % Duration and conditional full time/part time text
\begin{minipage}[T]{3cm}%
\expandafter\ifstrequal\expandafter{#3}{}{}{
{\raggedright\large #3}\\}%Job Title
\expandafter\ifstrequal\expandafter{#5}{}{}{%
{\raggedright\large\textit{\textbf{#5}}}%Employer
}
\end{minipage}
\expandafter\ifstrequal\expandafter{#4}{}{}{
\begin{minipage}[T]{0.5\textwidth}%
\includegraphics[height=30pt]{#4}% Logo
\end{minipage}\\[4pt]%
}
\expandafter\ifstrequal\expandafter{#6}{}{}{#6\\} % Description
}
\begin{document}
\workposition{potatoes}{potatoes}{potatoes}{logo}{potatoes}{potatoes}
\end{document}
编辑:
或者,如果您希望图像靠近雇主姓名,则可以使用 tabular 而不是 minipage。以下是示例。
\documentclass{article}
\usepackage{etoolbox}
\usepackage{graphicx}
\newcommand{\workposition}[6]{
{\raggedleft\textsc{#1\expandafter\ifstrequal\expandafter{#2}{}{}{
\hspace{6pt}\footnotesize{(#2)}}}\par
} % Duration and conditional full time/part time text
\noindent\begin{tabular}{l}
\expandafter\ifstrequal\expandafter{#3}{}{}{%
{\raggedright\large #3}\\}%Job Title
\expandafter\ifstrequal\expandafter{#5}{}{}{%
{\raggedright\large\textit{\newline\textbf{#5}}}%Employer
}%
\end{tabular}
\expandafter\ifstrequal\expandafter{#4}{}{}{
\begin{minipage}[T]{0.5\textwidth}%
\includegraphics[height=30pt]{#4}% Logo
\end{minipage}\\[4pt]%
}\\[4pt]
\expandafter\ifstrequal\expandafter{#6}{}{}{#6\\} % Description
}
\begin{document}
\workposition{potatoes}{potatoes}{potatoes}{logo}{potatoes}{potatoes}
\end{document}