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?

CarLaTeX
  • 62,716

2 Answers2

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

egreg
  • 1,121,712