3

I have this MWE:

\documentclass[11pt]{article}
\usepackage{tikz}
\usepackage{vmargin}
\usepackage{fancyhdr}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}

\setpapersize{A4}
\setmargins{2.2cm}
{0.5cm}
{16.5cm}
{23.42cm}               
{30pt}
{1cm}
{0pt}
{2cm}   

\renewcommand{\headrulewidth}{0pt}

\pagestyle{fancy}
\fancyhf{}
\cfoot{\large \thepage}
\fancyfoot[RO,LE]{
\definecolor{micolor}{RGB}{191,14,50}
\def\sc{0.15}
\vspace{-8.85mm}
\begin{tikzpicture}[inner sep =0,outer sep=0,line width={0.6*\sc cm},scale=\sc]
    \draw[micolor,line width={0.8*\sc cm}] (23.6cm,2.45cm)--(23.6cm,-2.5cm); % Vertical line of "B"
    \draw[fill,micolor, line width={0.3*\sc cm}]
    (23.197cm,1.9cm)--
    (24.8cm,1.9cm) arc(90:-90:1.6cm and 0.943cm) --
    (23.35cm,0.015cm) --
    (23.35cm,-0.2cm) --
    (25.197cm,-0.2cm)  arc(-90:90:1.8cm and 1.3cm) --
    (23.197cm, 2.4cm);     % Upper belly of "B"
    \draw[fill,micolor,line width={0.3*\sc cm},rotate=180]
    (-23.197cm,1.9cm)--
    (-24.8cm,1.9cm) arc(90:-90:-1.8cm and 0.943cm) --
    (-23.35cm,0.015cm) --
    (-23.35cm,-0.2cm) --
    (-25.197cm,-0.2cm)  arc(-90:90:-2cm and 1.3cm) --
    (-23.197cm, 2.4cm);    % Lower belly of "B"
\end{tikzpicture}
}

\begin{document}
B
\end{document}

As you can see, I am trying to make the letter "B" as similar as possible to an already given one, but it does not remain identical to me.

Letter B

The image on the right is what I created, and the left is what it should look like.

Keep in mind what you can not modify:

  • The scale of the letter.
  • The thickness of each part.
  • The ymin of the vertical line (-2.5 cm) and the ymax (2.45 cm). If by design issue you have to modify the width of the letter you can add or remove a few millimeters (that is, lengthen or shrink the bellies).

Please, can you help me improve that style?

Thanks!

manooooh
  • 3,203
  • 2
  • 21
  • 46
  • 3
    What's the purpose of the exercise? Where does the left B comes from? – Heiko Oberdiek Mar 26 '18 at 23:35
  • 1
    Off-topic: don't use vmargin. Use geometry or one of the other alternatives instead. Why don't you just use the relevant font to make the 'B' or include it as an image, if that's all you've got? – cfr Mar 26 '18 at 23:35
  • @HeikoOberdiek It comes from this topic:

    My problem is that I do not know how to handle the arc command correctly, that's why I asked for help.

    – manooooh Mar 26 '18 at 23:37
  • @cfr If I use an image it is likely that in the final document I pixelee, something I do not want. That's why I decided to create it by hand, but I understand that it goes through something more of style than a question about LaTeX. I apologize – manooooh Mar 26 '18 at 23:39
  • 1
    Are you aware of this post. You can use convert to convert the pic to pnm and then inkspace to make a vector graphics from it or convert it to PSTricks ot TikZ. If you are confused about arcs, it might be better to ask a different question. –  Mar 26 '18 at 23:45
  • 2
    I doubt that there are perfect arcs. For a better approximation you would need Bezier curves instead. – Heiko Oberdiek Mar 27 '18 at 00:13
  • It won't look fuzzy if you have a vector image. Are you saying you only have a raster B? I doubt that TikZ is the best way to do this, if it must be done. MetaPost might be more amenable. Essentially, the lines vary in width as if drawn with a pen. The effect is not very pronounced here, but it is still there. MetaPost (like MetaFont) has this concept, whereas TikZ does not. (At least, not out-of-the-box - for MP, the concept is fundamental.) – cfr Mar 27 '18 at 00:17
  • If this is just an exercise for arc, then I do not understand the unrelated fancyhdr stuff. Why can't you just use a sans-serif and probably bold B, scale it and color it red? – Heiko Oberdiek Mar 27 '18 at 00:20
  • You can use potrace to get the vectorized version of this bitmap image. Here is an example of a more complicated image https://tex.stackexchange.com/questions/172336/drawing-roman-laurel-leaves-spqr-in-tikz – percusse Mar 27 '18 at 01:02
  • I will go in parts:

    @marmot I applied the concepts you told me in the previous topic, but particularly this letter did not turn out well, and that's why I asked if a charitable soul offered to improve what I had done.

    @cfr Something I read before about the vector image. If I'm honest, I do not need such complicated things; I prefer (for now, just for now) to handle the "crafts" and then refine myself with more advanced topics (I'm not in a LaTeX course learning how to use this or that thing, to be clear).

    – manooooh Mar 27 '18 at 02:19
  • @HeikoOberdiek The fanchyhdr package and the footer are unnecessary, you're right. I should have taken it out of the MWE because it does not apply to this question.

    @percusse The same thing I said to @cfr, I do not want to know that kind of solutions for now because I do not need them. It was about someone finishing the work "by hand" of doing the lyrics in TikZ simply.

    – manooooh Mar 27 '18 at 02:19
  • I can only thank you for the time you have taken to write. Thank you all! – manooooh Mar 27 '18 at 02:19
  • Lol, who do you think is a useful question? And the star who put it? It goes against what you told me about this question (and I have it very clear and I accept it)... – manooooh Mar 27 '18 at 02:21
  • 1
    @manooooh I think it is a useful question because you can grow ducks in the B, please see my update. ;-) –  Mar 27 '18 at 02:22

1 Answers1

4

Just for fun and because marmots like ducks, here are some arcs that give an OK fit to the letter. BTW, you should not call your macros \sc because that is already taken. And it is true what all the senior people like Heiko and cfr say. (B.png is just a screen shot of the left B of the question.)

enter image description here

\documentclass[tikz]{standalone}
\definecolor{micolor}{RGB}{191,14,50}
\begin{document}
\begin{tikzpicture}
\node at (-8,0) {\includegraphics[width=5cm]{B.png}};
\fill[even odd rule,micolor]
(-2.1,-2.8) -- (-2.1,2.6) -- (0.85,2.6) arc (90:-70:1.25 and 1.28) 
arc (70:-90:1.54 and 1.5) --cycle
 (-1.2,-2) -- (-1.2,-0.3) -- (0.6,-0.3) arc(90:-90:0.8 and 0.85) --cycle
(-1.2,0.38) -- (-1.2,1.82) -- (0.6,1.82) arc(90:-90:0.6 and 0.72) --cycle;
\end{tikzpicture}

\begin{tikzpicture}
\node at (0,0) {\includegraphics[width=5cm]{B.png}};
\fill[even odd rule,blue,opacity=0.4]
(-2.1,-2.8) -- (-2.1,2.6) -- (0.85,2.6) arc (90:-70:1.25 and 1.28) 
arc (70:-90:1.54 and 1.5) --cycle
 (-1.2,-2) -- (-1.2,-0.3) -- (0.6,-0.3) arc(90:-90:0.8 and 0.85) --cycle
(-1.2,0.38) -- (-1.2,1.82) -- (0.6,1.82) arc(90:-90:0.6 and 0.72) --cycle;
\end{tikzpicture}

\end{document}

enter image description here

As you see in the overlay, the fit is at best OK. One difference to your drawing is that I draw the contours differently and that not all arcs run from -90 to 90.

And here is why redrawing some characters with TikZ might eventually be useful. You can shade them, vary the colors along the fill, and do lots of other things like hiding ducks in the letters.

\documentclass[tikz]{standalone}
\usepackage{tikzducks}
\usetikzlibrary{shadings,fadings}
\definecolor{micolor}{RGB}{191,14,50}
\begin{document}
\begin{tikzpicture}
\begin{scope}[xshift=0cm]
\shade[even odd rule,top color=micolor,bottom color=blue]
(-2.1,-2.8) -- (-2.1,2.6) -- (0.85,2.6) arc (90:-70:1.25 and 1.28) 
arc (70:-90:1.54 and 1.5) --cycle
 (-1.2,-2) -- (-1.2,-0.3) -- (0.6,-0.3) arc(90:-90:0.8 and 0.85) --cycle
(-1.2,0.38) -- (-1.2,1.82) -- (0.6,1.82) arc(90:-90:0.6 and 0.72) --cycle;
\end{scope}
\begin{scope}[xshift=5cm]
\fill[even odd rule,micolor]
(-2.1,-2.8) -- (-2.1,2.6) -- (0.85,2.6) arc (90:-70:1.25 and 1.28) 
arc (70:-90:1.54 and 1.5) --cycle
 (-1.2,-2) -- (-1.2,-0.3) -- (0.6,-0.3) arc(90:-90:0.8 and 0.85) --cycle
(-1.2,0.38) -- (-1.2,1.82) -- (0.6,1.82) arc(90:-90:0.6 and 0.72) --cycle;
\node at(-0.4,1.1){\tikz[xscale=-1]{\duck}};
\fill[micolor] (-1.2,1.82) -- (-1.2,0.38) -- (0.5,0.38) -- 
(0.5,-0.3) -- (-2.1,-0.3) -- (-2.1,-1.82) -- cycle; 
\node at(-0.5,-1.2){\tikz[xscale=-1]{\duck}};
\fill[micolor] (-1.2,-0.3) -- (-1.2,-2) -- (0.5,-2) -- 
(0.5,-2.8) -- (-2.1,-2.8) -- (-2.1,-0.3) -- cycle; 
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

  • It's very good! As much as it is the most basic programming that includes, it helps me a lot. The only thing I had to add to the code was \fill[xshift = 25.197cm, ... since I have more letters and it was not positioned correctly in the right place. I wish I could put ducklings! It's for a college work... Regards – manooooh Mar 27 '18 at 03:30
  • 1
    @manooooh Even though it does not produce a different result, I'd suggest that you put the thing in a scope \begin{scope}[xshift=...] ... \end{scope}. –  Mar 27 '18 at 04:14
  • I will consider that, dear @marmot ^-^ – manooooh Mar 27 '18 at 13:37