4

I am defining options using the pgfkeys command.

\newcommand{\subtitlefont}{}
\pgfkeys{
   /titleblock/.is family, /titleblock,
   default/.style = 
       {titlesize = 48, titlelineskip = 52,
        subtitlesize = 36, subtitlelineskip = 39, subtitlefont=\itshape,
       },
   titlesize/.estore in = \titlesize,
   titlelineskip/.estore in = \titlelineskip,
   subtitlesize/.estore in = \subtitlesize,
   subtitlelineskip/.estore in = \subtitlelineskip,
   subtitlefont/.add code={}{\subtitlefont},
}

Them I want to use this options in a node font option.

\node[align=left, inner sep=0mm, outer sep=0mm,
 font={\fontsize{\subtitlesize}{\subtitlelineskip}\subtitlefont\selectfont},
 text=\titleblockcolor,
 below= 0.1cm of title.south west, anchor=north west] (subtitle) {
   \thesubtitle%
   };

The document compiles but the \itshape is not selected for the subtitle. What is the best way to define an option that consist in macros that can be passed to a node option?

Complete MWE

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfkeys}

\newcommand{\subtitlefont}{}
\pgfkeys{
   /titleblock/.is family, /titleblock,
   default/.style = 
       {
         subtitlesize = 36, subtitlelineskip = 39, subtitlefont=\itshape,
       },
   subtitlesize/.estore in = \subtitlesize,
   subtitlelineskip/.estore in = \subtitlelineskip,
   subtitlefont/.add code={}{\subtitlefont},
}



\newcommand{\titleblock}[1][]{%
\pgfkeys{/titleblock, default, #1}%
\begin{tikzpicture}
  \node[align=left, inner sep=0mm, outer sep=0mm,
  font={\fontsize{\subtitlesize}{\subtitlelineskip}\subtitlefont\selectfont},
  text=black] (subtitle) {A nice title};
\end{tikzpicture}

}

\begin{document}
\titleblock
\end{document}
  • Please, make a minimal (non) working example. – egreg Oct 14 '15 at 7:49
  • Before anything, you shouldn't /.estore them. – percusse Oct 14 '15 at 7:57
  • In addition to what percusse told, add subtitlefont/.store in=\subtitlefont, and \usepackage{lmodern}. – user11232 Oct 14 '15 at 8:27
  • @HarishKumar I don't know why I was using estore in. That didn't work, but store in is working. If you make the comment an asnwer I can select it. – TeXtnik Oct 14 '15 at 8:45
2

From pgfmanual page, 889

enter image description here

Hence you should be using store in instead of estore in. Also use subtitlefont/.add code={}{\subtitlefont}, instead of subtitlefont/.store in=\subtitlefont,. Adding to this, since you are using large font sizes, it is better to use lmodern package which provides nice scalable fonts and you wouldn't get warnings.

With these your code becomes

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfkeys}
\usepackage{lmodern}

\newcommand{\subtitlefont}{}
\pgfkeys{
   /titleblock/.is family, /titleblock,
   default/.style =
       {
         subtitlesize = 36, subtitlelineskip = 39, subtitlefont=\itshape,
       },
   subtitlesize/.store in = \subtitlesize,
   subtitlelineskip/.store in = \subtitlelineskip,
   subtitlefont/.store in=\subtitlefont,
}



\newcommand{\titleblock}[1][]{%
\pgfkeys{/titleblock, default, #1}%
\begin{tikzpicture}
  \node[align=left, inner sep=0mm, outer sep=0mm,
  font={\fontsize{\subtitlesize}{\subtitlelineskip}\subtitlefont\selectfont},
  text=black] (subtitle) {A nice title};
\end{tikzpicture}

}

\begin{document}
\titleblock
\end{document}

enter image description here

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.