3

I want to do a command in LaTeX named \facil where:

  1. I read the counter ejercicio, I add 1 to it and I display it with sans-serif font, and then write down a dot. I've previously created it in the preamble, and the code I've done:

    {%
    \sffamily\arabic{ejercicio}%
    \addtocounter{ejercicio}{1}.%
    }%
    
  2. Then write a space with "\ " (without quotes) and draw a blue circle (or point) where is exactly in the middle of the line, with color blue!25!black and minimum size=1ex. That's what I don't know how to do it, I've tried with baseline option but I haven't done anything right.

  3. Write a large space "\;" (the text "Representa en forma..." is not part of the command).

An image of what I want to do:

enter image description here

JnxF
  • 886

2 Answers2

4

Something like this?

\documentclass{article}
\usepackage{xcolor}

\newcounter{ejercicio}
\newcommand\facil{%
  \stepcounter{ejercicio}{\sffamily\theejercicio.}~\textcolor{blue!25!black}{$\bullet$}~}

\begin{document}

\facil Representa en forma de intervalo...

\end{document}

enter image description here

Using \raisebox and/or \scalebox from the graphicx package you can change the attributes for the \bullet; for example:

\usepackage{graphicx}
\usepackage{xcolor}

\newcounter{ejercicio}
\newcommand\facil{%
  \stepcounter{ejercicio}{\sffamily\theejercicio.}~\textcolor{blue!25!black}{\scalebox{1.2}{$\bullet$}}~}
Gonzalo Medina
  • 505,128
4

Since you did not provide a complete MWE, I am guessing the problem with what you were attempting was to apply baseline to the \draw, or \node. It needs to be applied to the \tikz. Here is what I think you were doing incorrectly (shown in red) and a way to fix it:

enter image description here

References:

Code:

\documentclass{article}

\usepackage{tikz} \newcounter{ejercicio}

\newcommand{\Oldfacil}{% \addtocounter{ejercicio}{1}% \sffamily\arabic{ejercicio}.~% \tikz \draw [fill=red, yshift=0.75ex] (0,0) circle (2pt);~% }%

\newcommand{\facil}{% \addtocounter{ejercicio}{1}% \sffamily\arabic{ejercicio}.~% \tikz[baseline] \draw [fill=blue!25!black, yshift=0.75ex] (0,0) circle (2pt);~% }% \begin{document} \Oldfacil Baseline applied to \verb|\draw|

\facil Baseline applied to \verb|\tikz| \end{document}

Peter Grill
  • 223,288
  • I think it also a good solution. I can ask you from my ignorance why are you using .75 ex, and not other distance? – JnxF Nov 18 '12 at 00:01
  • I adjusted that value so that it looked right, and used the ex units so that it will adjust if the font size is changed. – Peter Grill Nov 18 '12 at 00:03