13

In this time, very busy from June, I'm creating my book of Physics and I'm using some options of the structure.tex of The Legrand Orange Book. I have occurred of your precious help if possible. Into my old MWE (year 2007) with macros, I can put to add my eyes (erre.69, erre.70 etc.) in format .eps files. You can see picture below,

enter image description here

with my source,

\documentclass[a4paper,italian,10pt]{article}
\usepackage{babel}

%occhietti
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input epsf
\def\ob{\epsfxsize=.28cm\epsfbox{erre.69}}
\def\os{\epsfxsize=.28cm\epsfbox{erre.72}}
\def\od{\epsfxsize=.28cm\epsfbox{erre.73}}
\def\oa{\epsfxsize=.28cm\epsfbox{erre.74}}
\def\oc{\epsfxsize=.28cm\epsfbox{erre.75}}
\def\ov{\epsfxsize=.28cm\epsfbox{erre.76}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\begin{document}

Different typology of examples or exercises with macros
$\ob,\os, \od,\oa,\oc,\ov$


\end{document}

But I would like to have the same eyes (created with TikZ - I don't remember that exists a symbol for these eyes!) without to use images in .pdf or .eps. format. Infact into my book I'm using many reduce figures only in .pdf. The code below is the same into Legrand Orange Book to create "examples" (for example) is:

\newenvironment{example}{\begin{exampleT}}{\hfill{\tiny\ensuremath{\blacksquare}}\end{exampleT}}.

Is the possibility to create a best \newenvironment {example} and \newenvironment {exercise} exactly to have the same eyes created with TikZ, same size, same command (\ob,\os,\oa, etc.)?

enter image description here

1
  • You don't need a tikz command for the square : \square will do.
    – marsupilam
    Commented Aug 27, 2017 at 9:13

2 Answers 2

22

It is very simple to do.

If you get the idea, you can create the other few you want.

The output

enter image description here

The code

\documentclass[12pt]{standalone}
\usepackage{tikz}
\newcommand\straightEye[1][1.2ex]
{%
\begin{tikzpicture}[scale=#1/1cm]
  \draw (0,0) circle (.5);
  \fill (0,0) circle (.25);
\end{tikzpicture}%
}
\newcommand\downwardsEye[1][1.2ex]
{%
\begin{tikzpicture}[scale=#1/1cm]
  \draw (0,0) circle (.5);
  \fill (0,-.25) circle (.25);
\end{tikzpicture}%
}
\newcommand\rightEye[1][1.2ex]
{%
\begin{tikzpicture}[scale=#1/1cm]
  \draw (0,0) circle (.5);
  \fill (.25,0) circle (.25);
\end{tikzpicture}%
}
\begin{document}
\straightEye \downwardsEye \ look at me \rightEye\rightEye
\end{document}

Or like this :

The output

enter image description here

The code

\documentclass[12pt]{standalone}
\usepackage{tikz}
\newcommand\sideEye[2][1.2ex]
{%
\begin{tikzpicture}[scale=#1/1cm]
  \draw (0,0) circle (.5);
  \fill (#2:.25) circle (.25);
\end{tikzpicture}%
}
\begin{document}
\foreach \ang in {0,30,...,360} {\sideEye{\ang}}
\end{document}
6
  • Thanks a lot lot for your job (+1). I prefer the first code, using the \newcommand. I have add other newcommand at your code for upeye and blank eye (similar at the simbol \circle, colored ocre). Thanks again and my best regards Sebastiano. Is there a reason for a downvote for your opinion?
    – Sebastiano
    Commented Aug 27, 2017 at 19:41
  • Thanks. Don't know about your downvote. I disagree with it and upvoted you in reaction. (Maybe someone thought it was not difficult enough to do for you to ask ?)
    – marsupilam
    Commented Aug 27, 2017 at 20:16
  • @Sebastiano You can maybe add a little bit of space between both eyes if you want to have exactly what you posted. Maybe a \hspace{2pt} or so, or a \, or another default space.
    – marsupilam
    Commented Aug 27, 2017 at 20:23
  • Your job was beautiful. I did not know some commands and learned something new. I believe that someone should have a pinch of humility and understanding the difficulties of others often when it hurries like me.
    – Sebastiano
    Commented Aug 27, 2017 at 20:25
  • This is not the case. It's perfect for your work and I put it in my structure.tex. I also gave you the green check.
    – Sebastiano
    Commented Aug 27, 2017 at 20:26
3

I like the answer of marsupilam. For the completeness sake: my idea of reducing the number of images embedded into the pdf file would be to embedd it only once.

Basically save each kind of eyes using a box, then just use these boxes. My current understanding is that the images would be embedded only once and then referenced again and again in the output file.

Update: I was just told than standard boxes don't work like this, but xsavebox does the trick. Thanks to AlexG.

3
  • 1
    No, the content of a standard \savebox is re-inserted on every \usebox, replicating the saved code in the output file (PDF, DVI, PS). To save space, the xsavebox package can be used.
    – AlexG
    Commented Aug 30, 2017 at 6:47
  • I haven't understood, but thanks for your answer. I have voted you.
    – Sebastiano
    Commented Sep 1, 2017 at 20:13
  • 1
    The idea is to call a macro once, to save the image in the output file. Then you use other macro, that only references the same image. This is not the standard behavior, normally on each call of a macro a new image is embedded. Commented Sep 1, 2017 at 20:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .