2

I would like to write a \newcommand to define a stylish word, like \LaTeX.

Let's take this example:

\newcommand{\mystyle}{ \textit{\raisebox{+0.2ex}{M} \kern-0.66em\raise-0.3ex\hbox{\scriptsize y} \kern-0.3em\raise0.4ex\hbox{\scriptsize s} \kern-0.75em\raise-0.3ex\hbox{\scriptsize t} \kern-0.3em\hbox{yle} } } 

The problem is, when \mystyle is put inside \title{} or \section{} the fontsizes which are defined by brute force (1st 4 letters) get too small since they do not proportionally scale with the remaining letters. If I write \LaTeX inside \title{} there is no problem.

How to get my command working smoothly like that?

0

2 Answers 2

2

You can use the relsize package for this.

enter image description here

\documentclass{article} \usepackage{relsize} \newcommand{\mystyle}{ \textit{\raisebox{+0.2ex}{M} \kern-0.66em\raise-0.3ex\hbox{\relsize{-1}y} \kern-0.3em\raise0.4ex\hbox{\relsize{-1}s} \kern-0.75em\raise-0.3ex\hbox{\relsize{-1}t} \kern-0.3em\hbox{yle} } } \begin{document} \section{\mystyle} Text talking about \mystyle \end{document} 
2

This problem cannot really be solved with relsize.

You can use the fact that \check@mathfonts sets up the font sizes for subscripts and superscripts based on the current font size, saving it in \sf@size.

\documentclass{article} \makeatletter \newcommand{\mystyle}{% \textit{% \check@mathfonts \itshape \raisebox{0.2ex}{M}% \kern-0.1em \raisebox{-0.3ex}{\fontsize\sf@size\z@\selectfont y}% \kern-0.1em \raisebox{0.4ex}{\fontsize\sf@size\z@\selectfont s}% \kern-0.2em \raisebox{-0.3ex}{\fontsize\sf@size\z@\selectfont t}% yle% }% } \makeatother \begin{document} \mystyle \bigskip \Large\mystyle \bigskip \footnotesize\mystyle \end{document} 

Note that you had several spaces (due to unprotected end-of-lines) that I removed, so the kerning had to be changed. Fix it to your liking.

enter image description here

3
  • What are the down sides to using relsize? I was going to suggest \scalebox, but I like your \check@mathfonts much better. Commented Feb 15, 2018 at 12:58
  • Neat :). Are there other font sizes saved by \check@mathfonts? Commented Feb 15, 2018 at 13:03
  • 1
    @PhelypeOleinik \ssf@size has the size for second level subscripts/superscripts. Commented Feb 15, 2018 at 13:11

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.