pgf-tikz / pgf

A Portable Graphic Format for TeX
https://pgf-tikz.github.io/
1.15k stars 109 forks source link

'initially' should not be in typewriter family #1278

Open SwitWu opened 1 year ago

SwitWu commented 1 year ago

Version

3.1.10

Details

In page 191, 248, 285, 361 etc, the word 'initially' and the comma before it should be in \rmfamily instead of \ttfamily. See the following screenshot for example:

image
muzimuzhi commented 1 year ago

That's because \begin{key}{/path/to/key=value (default xxx, initially yyy)} is not supported yet. Currently the whole "xxx, initially yyy" is parsed as the default value, hence typeset in typewriter font family. https://github.com/pgf-tikz/pgf/blob/6e5fd71581ab04351a89553a259b57988bc28140/tex/latex/pgf/doc/pgfmanual-en-macros.tex#L647-L659

% This is https://github.com/pgf-tikz/pgf/blob/master/doc/generic/pgf/pgfmanual-test.tex
% modified in place
\documentclass[a4paper,doc2]{ltxdoc}

% pgf version is defined in \pgfversion in file
% generic/pgf/utilities/pgfrcs.code.tex 

\input{pgfmanual.cfg} % default engine is LuaTeX
\input{pgfmanual-en-main-preamble.tex}

\makeatletter
\def\extractkeyequal#1=#2\@nil{%
  \pgfutil@in@{(default}{#2}%
  \ifpgfutil@in@%
    \pgfutil@in@{, initial}{#2}% <<< added logic
    \ifpgfutil@in@%
      \extractdefaultinitial{#1}#2\@nil%
    \else
      \extractdefault{#1}#2\@nil%
    \fi
  \else%
    \pgfutil@in@{(initial}{#2}%
    \ifpgfutil@in@%
      \extractinitial{#1}#2\@nil%
    \else
      \pgfmanualentryheadline{%
        \def\mykey{#1}%
        \def\mypath{}%
        \gdef\myname{}%
        \firsttimetrue%
        \pgfmanualdecomposecount=0\relax%
        \decompose#1/\nil%
        {\ttfamily\declare{#1}=}#2\hfill(\extrakeytext no default)}%
    \fi%
  \fi%
}

\def\extractdefaultinitial#1#2(default #3, initially #4)\@nil{%
  \pgfmanualentryheadline{%
    \def\mykey{#1}%
    \def\mypath{}%
    \gdef\myname{}%
    \firsttimetrue%
    \pgfmanualdecomposecount=0\relax%
    \decompose#1/\nil%
    {\ttfamily\declare{#1}\opt{=}}\opt{#2}\hfill
    (\extrakeytext default {\ttfamily#3}, initially {\ttfamily#4})}%
}
\makeatother

\begin{document}

\begin{key}{/pgf/tips=\meta{value} (default true, initially on draw)}
        \keyalias{tikz}
    This key governs in what situations arrow tips are added to a path. The
    following \meta{values} are permissible:
\end{key}

\end{document}

Before image After image