8

I am trying to create a custom word, f-hole, where instead of an f I use the actual outline of a violin f-hole:

enter image description here

I have an .svg file of the outline I want to make into a symbol, and using this answer I've managed to use \usetikzlibrary{svg.path} to include it in a tikzpicture. From there I've manually adjusted the size and position to make it sit next to the piece of text -hole. However, I'm having trouble getting it to align with the baseline of my text and get punctuation to work around it (before and after the word).

enter image description here

Additionally, my solution doesn't scale nicely when I change the size of the font (I need it to work with footnotesize and huge at a minimum). Any tips to improve this? I need a pdfLaTeX solution.

enter image description here

Code

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{newtxtext}
\usepackage{tikz}
\usetikzlibrary{svg.path}

\tikzset{
  fhole/.pic={
    \fill [scale=0.045] svg{m141.50504652572636,8.750154755020048 l12.88491,15.0039 c-6.33974,5.397 -6.91986,11.7233 -3.91811,17.7654 c2.79858,4.7279 9.39378,6.1777 14.58215,3.3698 c14.90229,-8.6016 2.97205,-29.2657 -8.32413,-35.8434 c-12.46952,-7.671 -23.48465,-2.9727 -32.06999,2.2816 c-32.57131,21.0958 -31.29905,53.0495 -36.53204,111.7787 l-3.80143,2.2686 l3.46803,2.8209 c-1.81268,50.3552 -7.19548,108.8638 -47.31312,118.9301 l-13.70647,-17.533 c6.63203,-1.8678000000000003 11.01697,-7.1683 12.24781,-13.0208 c1.58418,-12.036 -9.34214,-23.7985 -23.61721,-18.9647 c-14.27507,4.8337 -12.70367,27.7181 -1.47322,39.9927 c11.23043,12.2746 28.2174,15.8516 42.3734,10.8362 c41.92159,-16.3793 51.61678,-67.3469 52.89911,-111.1003 l3.68819,-2.1338 l-3.4807,-3.4122 c2.6751,-40.5983 -4.97189,-105.0606 32.09282,-123.0397 z};
  }
}

\newcommand\fhole{\begin{tikzpicture}
     \path (0,0) pic [yscale=-1] {fhole};
     \node at (0.64,-0.17) {-hole};
  \end{tikzpicture}}

\begin{document}
The violin \fhole.

\footnotesize The footnotesize violin \fhole.

\huge The huge violin \fhole.
\end{document}
Milo
  • 9,440

2 Answers2

10

Package scalerel could be used to scale the graphics to the size of 'f' in the current fontsize. The kerning is adjusted acc. to @Emma's suggestion.

Edit: \mbox added to prevent linebreak before hyphen and \hspace{0pt} inserted to allow linebreak after hyphen.

enter image description here

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{newtxtext}
\usepackage{tikz}
\usetikzlibrary{svg.path}

\tikzset{
  fhole/.pic={
    \fill svg{m141.50504652572636,8.750154755020048 l12.88491,15.0039 c-6.33974,5.397 -6.91986,11.7233 -3.91811,17.7654 c2.79858,4.7279 9.39378,6.1777 14.58215,3.3698 c14.90229,-8.6016 2.97205,-29.2657 -8.32413,-35.8434 c-12.46952,-7.671 -23.48465,-2.9727 -32.06999,2.2816 c-32.57131,21.0958 -31.29905,53.0495 -36.53204,111.7787 l-3.80143,2.2686 l3.46803,2.8209 c-1.81268,50.3552 -7.19548,108.8638 -47.31312,118.9301 l-13.70647,-17.533 c6.63203,-1.8678000000000003 11.01697,-7.1683 12.24781,-13.0208 c1.58418,-12.036 -9.34214,-23.7985 -23.61721,-18.9647 c-14.27507,4.8337 -12.70367,27.7181 -1.47322,39.9927 c11.23043,12.2746 28.2174,15.8516 42.3734,10.8362 c41.92159,-16.3793 51.61678,-67.3469 52.89911,-111.1003 l3.68819,-2.1338 l-3.4807,-3.4122 c2.6751,-40.5983 -4.97189,-105.0606 32.09282,-123.0397 z};
  }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{scalerel}
\newcommand\fhole{\mbox{\scalerel*{\tikz{\path (0,0) pic [yscale=-1] {fhole};}}{f}\hspace{-0.135em}-}\hspace{0pt}hole}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
The violin \fhole.

\footnotesize The footnotesize violin \fhole.

\huge The huge violin \fhole.

xxxxxx xxxxxx The huge violin \fhole.
\end{document}
AlexG
  • 54,894
  • 2
    I would think an \hspace{-.3ex} should do the trick for the spacing. The units ex and em are relative the the current font size. – Emma Jul 04 '18 at 14:21
  • @Emma I believe a horizontal space (hspace) should be given in a unit that is relative to the horizontal font size (em) ! - not ex that is relative to the vertical font size. – hpekristiansen Jul 04 '18 at 15:20
  • @hpekristiansen Yes, but for a given font, the ratio between 1ex and 1em is fixed, that is, independent from the font size, as far as I know. Thus, either can be used. – AlexG Jul 04 '18 at 15:30
  • @AlexG I did not know that - do you have a reference for this? Is no font wider than others? – hpekristiansen Jul 04 '18 at 15:38
  • Ok, if you change font, it is another story. – AlexG Jul 04 '18 at 15:42
  • @hpekristiansen You may be right, after all, using a horizontal unit here, because one may want to use e. g.\bfseries. Here, the ratio between 1em and 1ex is different. – AlexG Jul 04 '18 at 16:02
  • @hpekristiansen I did think of the horizontal/vertical discrepancy as I posted, but I was hoping that for most purposes it wouldn't matter much. I had actually thought that both were relative to the height. Now that I investigate further, I see several different definitions and it's not obvious which one TeX uses. Using the trick from this post I find that the length of an ex differs in bold vs. normal weight font, while the length of an em does not. – Emma Jul 04 '18 at 18:58
4

If you are not fuzzy about the exact shape, you could produce something similar using an integral sign:

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}
\usepackage{newtxtext}
\usepackage{graphicx}

\usepackage{wasysym}
\newcommand\fhole{\rotatebox{-10}{\kern-0.2em$\varint$}\kern-0.2em-hole}


\begin{document}

The normalsize violin \fhole.

\footnotesize The footnotesize violin \fhole.

\huge The huge violin \fhole.

\end{document}

enter image description here

  • Thanks ;) I hadn't realised how close it is to an integral sign! But the whole point of my exercise is to replicate an exact violin f-hole. Hence going to extra lengths to use an svg outline of an f-hole design based on that by Antonio Stradivari :) – Milo Jul 04 '18 at 15:28
  • @Milo there are some articles wondering about the similarity, but the answer seems always to be: coincident. Kind of boring... If you want the shape from someone truly famous, you could replace the Stradivari shape with the original integral shape from Leibniz :) – samcarter_is_at_topanswers.xyz Jul 04 '18 at 15:36