![如何将文字放在图片旁边](https://linux22.com/image/374542/%E5%A6%82%E4%BD%95%E5%B0%86%E6%96%87%E5%AD%97%E6%94%BE%E5%9C%A8%E5%9B%BE%E7%89%87%E6%97%81%E8%BE%B9.png)
我有这个:
\begin{figure}[!hb]
\label{curve}
\includegraphics[width=10cm, height=4cm]{images/smoothSinCurve.png}
\end{figure}
\begin{trivlist}
\item \textcolor{orange}{Orange} is overdose
\item \textcolor{green}{Green} is underdose
\item \textcolor{blue}{Blue} is perfect dosage.
\end{trivlist}
它看起来像这样:
我怎样才能把它们放在同一条线上?
答案1
也许是这样的?
\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{graphicx,xcolor}
\begin{document}
\begin{figure}[!hb]
\centering
\label{curve}
\includegraphics[width=10cm, height=4cm]{example-image}
\begin{minipage}[b]{1.4in}
\begin{trivlist}
\item \textcolor{orange}{Orange} is overdose
\item \textcolor{green}{Green} is underdose
\item \textcolor{blue}{Blue} is perfect dosage.
\end{trivlist}
\end{minipage}
\end{figure}
\end{document}
答案2
我写了一个命令,可以简单地做到这一点。它被@egreg更正,他在这里将其作为环境编写:https://tex.stackexchange.com/a/403618/138900
此后,我对它进行了修改,使其可以放置或不放置垂直分隔线:
\newlength\colG\newlength\colD%
\newenvironment{Compo}[1][0.5]
{%
\setlength{\colG}{#1\linewidth}%
\setlength{\colD}{\linewidth}%
\addtolength{\colD}{-\colG}%
\addtolength{\colG}{-10pt}%
\addtolength{\colD}{-10pt}%
\par\noindent%
\begin{minipage}{\colG}%
}%
{%
\end{minipage}%
\par%
}%
\newcommand{\compobreak}{%
\end{minipage}\hfill\vrule\hfill%
\begin{minipage}{\colD}%
}%
\newcommand{\componubreak}{%
\end{minipage}\hfill%
\begin{minipage}{\colD}%
}%
由此可得:
\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{graphicx,xcolor}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% nouvel environnement Compo
\newlength\colG%\newlength\colD%
\newenvironment{Compo}[1][0.5]
{%
\setlength{\colG}{#1\linewidth}%
\setlength{\colD}{\linewidth}%
\addtolength{\colD}{-\colG}%
\addtolength{\colG}{-10pt}%
\addtolength{\colD}{-10pt}%
\par\noindent%
\begin{minipage}{\colG}%
}%
{%
\end{minipage}%
\par%
}%
\newcommand{\compobreak}{%
\end{minipage}\hfill\vrule\hfill%
\begin{minipage}{\colD}%
}%
\newcommand{\componubreak}{%
\end{minipage}\hfill%
\begin{minipage}{\colD}%
}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{Compo} [.5]
\label{curve}
\includegraphics[width=10cm, height=4cm]{example-image}
\compobreak
\begin{trivlist}
\item \textcolor{orange}{Orange} is overdose
\item \textcolor{green}{Green} is underdose
\item \textcolor{blue}{Blue} is perfect dosage.
\end{trivlist}
\end{Compo}
\end{document}
输出: