2

In the following picture, a lot of extra space (relative to the true size of it, which is around 4cm by 3cm) is added when I use the \prints macro I defined in the preamble (line 14 according to TeXstudio), as seen in the first image; this macro uses the pdfrender package's macro \textpdfrender; also, for some reason, the atril document viewer shows part of the Q's tail in white, whereas TeXstudio's internal viewer renders it correctly in blue. Compare to the second image, in which \prints[<colour>]{<letter>} is replaced by \textcolor{<colour>}{<letter>} in the line after the %%%%%%%%%%%%%%%%%%%%%%%%%TEXT CODE!!! comment (line 40 according to TeXstudio). The code:

\documentclass[tikz]{standalone}

\usepackage[T1]{fontenc}
\usepackage{pdfrender}

\usetikzlibrary{
    positioning, 
    backgrounds,
%   calc
}

%%%%%%%%%DEF \prints MACRO
\newcommand{\prints}[2][black]{
    \textpdfrender{%
        TextRenderingMode=FillStroke,%
        FillColor=#1,%
        LineWidth=0.1pt,%
    }{#2}%
}
\setlength{\parindent}{0pt}
\begin{document}

\begin{tikzpicture}
    %%%FONT SIZE DETS. PICTURE SIZE
    \newdimen\ttext
    \ttext = 80pt
    \fontsize{\ttext}{22}\fontfamily{trjn}\selectfont\par
    %%%%%/FONTSIZE.

    %%%%QED NODE
    \node[
        inner ysep = 1.5pt, 
        inner xsep = -1.7pt,
        outer sep = 0pt, 
%       draw, 
%       ultra thin
        ] (q) at (0,0) 
    %%%%%%%%%%%%%%%%%%%%%%%%%TEXT CODE!!!
    {
        \raisebox{-0.22em}{\prints[cyan!80!black]{Q}} 
        \kern -1.05ex \raisebox{0.22em}{\prints[red!80!black]{E}} 
        \kern -1.1ex\hbox{\prints[green!80!black]{D}} 
    };
    %%%%%%%%%%%%%%/QED

    %%%EXTRA NODE FOR MORE SPACE
    \node [below = 0.18\ttext of current bounding box.south, inner sep = 0pt, outer sep = 0pt, anchor = south] (a) {};

    %%%BG RECTANGLE
    \begin{scope}[
        on background layer, 
        every path/.style = {
        line width = 0.25pt, 
        opacity = 0.5
    }
    ]
    \fill[
    opacity = 1,
    top color = gray, 
    bottom color = gray!5,
    ] (current bounding box.south west) rectangle (current bounding box.north east);
    \end{scope}
\end{tikzpicture}

\end{document}

I would really like to have the second picture but with the outlined letters as in the first; I realise I can get the second image by kerning enough negative space on each letter, but I rather know why pdfrender adds this space and how to remove it, if possible. I also tried using the contour package, but I get the third image (after modifying the number of copies the \contour command prints; the image is done with 7, but I wasn't satisfied with the results, specially on the arm of the E). Thanks!!

With <code>\textpdfrender</code> Without <code>\textpdfrender</code> enter image description here

2

Basically all of this comes from spurious spaces (and has nothing to do with TikZ per se). Ironically this construction requires precisely one space between Q and E and one between E and D. I added % at various places to remove these spaces, such as at the beginning of the node.

\documentclass[tikz]{standalone}

\usepackage[T1]{fontenc}
\usepackage{pdfrender}

\usetikzlibrary{
    positioning, 
    backgrounds,
%   calc
}

%%%%%%%%%DEF \prints MACRO
\newcommand{\prints}[2][black]{%
    \textpdfrender{%
        TextRenderingMode=FillStroke,%
        FillColor=#1,%
        LineWidth=0.1pt,%
    }{#2}%
}
\setlength{\parindent}{0pt}
\newdimen\ttext
\ttext=80pt%
\begin{document}

\begin{tikzpicture}
    %%%FONT SIZE DETS. PICTURE SIZE
%     \fontsize{\ttext}{22}\fontfamily{trjn}\selectfont%\par
    %%%%%/FONTSIZE.

    %%%%QED NODE
    \node[
        inner ysep = 1.5pt, 
        inner xsep = -1.7pt,
        outer sep = 0pt, 
%       draw, 
       font=\fontsize{\ttext}{22}\fontfamily{trjn}\selectfont,
%       ultra thin
        ] (q) at (0,0) 
    %%%%%%%%%%%%%%%%%%%%%%%%%TEXT CODE!!!
    {%
        \raisebox{-0.22em}{\prints[cyan!80!black]{Q}} %<- need one space 
        \kern -1.05ex \raisebox{0.22em}{\prints[red!80!black]{E}} % 
        \kern -1.1ex\hbox{\prints[green!80!black]{D}}%
    };
    %%%%%%%%%%%%%%/QED

    %%%EXTRA NODE FOR MORE SPACE
    \node [below = 0.18\ttext of current bounding box.south, inner sep = 0pt, outer sep = 0pt, anchor = south] (a) {};

    %%%BG RECTANGLE
    \begin{scope}[
        on background layer, 
        every path/.style = {
        line width = 0.25pt, 
        opacity = 0.5
    }
    ]
    \fill[
    opacity = 1,
    top color = gray, 
    bottom color = gray!5,
    ] (current bounding box.south west) rectangle (current bounding box.north east);
    \end{scope}
\end{tikzpicture}

\end{document}

enter image description here

| improve this answer | |
  • Brilliant!!! Could you tell me why those spaces are relevant (or point me towards an appropriate source)? I specially want to know the reason behind the "ironic" spaces (ironic, indeed)! Many thanks and kudos! – Óscar Guajardo May 23 at 0:58
  • 1
    @ÓscarGuajardo Basically every % I added was to kill a space. A very important one was at the beginning of the node {%. Then I added another % after \kern -1.1ex\hbox{\prints[green!80!black]{D}}. I also made \fontsize{\ttext}{22}\fontfamily{trjn}\selectfont part of the font information of the node. You could get rid of the spaces after \raisebox{-0.22em}{\prints[cyan!80!black]{Q}} and \raisebox{0.22em}{\prints[red!80!black]{E}} by changing the kerning, but I think there is no real need for that since the result looks good. – Schrödinger's cat May 23 at 1:30
  • The result looks quite nice; but my question was as for the reason why the spaces between letters are needed. I understand the need for commenting out blank spaces I hadn't noticed, but why add the others? – Óscar Guajardo May 23 at 1:41
  • 1
    @ÓscarGuajardo I obviously did not invent the nice series of letters. However, it seems to me that whoever did that added the kerning under the assumption that there will be spaces. – Schrödinger's cat May 23 at 1:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.