0

I'd like to add a couple of equations over a picture. I'm using the overpic package as explained in overpic_link. However, I'm trying to get the equation in color as shown in color_link

\documentclass{article}
\usepackage[percent]{overpic}
\usepackage{xcolor}

\begin{document} \begin{overpic}[width=0.5\textwidth,grid,tics=10]{pictures/baum} \put (20,85) \textcolor{blue}{\huge$\displaystyle\gamma$} \end{overpic} \end{document}

but I'm getting the error below: ! Package xcolor Error: Undefined color `\hss '. could anyone please provide a feedback on why the error, I'm just starting using Latex, thanks.

AGH
  • 103
  • 1
    Try \put (20,85) {\color{blue} \huge $\gamma$}? (I don't think the \displaystyle is doing anything here...) – Willie Wong Jun 29 '21 at 02:36
  • many thanks that solved the problem – AGH Jun 29 '21 at 03:04
  • 1
    I’m voting to close this question because it was solved in comments. – SebGlav Jun 29 '21 at 04:41
  • 1
    we may keep it, but ask willie wong to put it as an answer so that the new user may upvote it and accept it, and get acquainted with this site's model. – jarnosc Jun 29 '21 at 05:12
  • @SebGlav One of the things that drives me nuts on tex.se is the tendency for questions to get answered in the comments instead of answers. It makes it a bit of a pain to locate unanswered questions. – Don Hosek Jun 29 '21 at 05:25
  • 1
    @WillieWong can you make your comment an answer? – Don Hosek Jun 29 '21 at 05:25
  • @DonHosek: looks like egreg did it already. :-) I generally put things in comments when I am not sure whether it will solve the problem (when I don't have a nearby TeX installation and/or time to test my hunch). – Willie Wong Jun 29 '21 at 13:06
  • @DonHosek You're right in a general way. I think it's better to make one's comment an answer before closing the question. But in this case, this is just about using the correct command syntax, not really a question though. – SebGlav Jun 29 '21 at 17:01

1 Answers1

2

The correct syntax is

\put(<x>,<y>){<material>}

and you're missing the braces around the material you want to \put.

Spaces around the coordinates are ignored.

\documentclass{article}
\usepackage[percent]{overpic}
\usepackage{xcolor}

\begin{document}

\begin{overpic}[width=0.5\textwidth,grid,tics=10]{example-image-9x16} \put (20,85) {\textcolor{blue}{\huge$\gamma$}} \end{overpic}

\end{document}

I removed \displaystyle that does nothing here, but it could make a difference with more complicated formulas.

enter image description here

egreg
  • 1,121,712