Text Formattinglowering a character in a section heading.

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
AliceWonder
Posts: 28
Joined: Wed Oct 31, 2012 12:04 am

lowering a character in a section heading.

Post by AliceWonder »

TeXLive 2013 as distributed from TUG running in Fedora 18 x86_64.

Code: Select all

\newcommand{\nix}{\textsc{Un\raisebox{-0.3\height}{*}x}}
works in paragraph mode, it puts the * at the correct height relative to the small caps N and X (at least with the font I am using).

However if I then use the \nix{} command in a \section{} command it fails. What is the proper way to accomplish what I want to accomplish so it is not restricted to paragraphs?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

lowering a character in a section heading.

Post by cgnieder »

Most of all your macro throws an error when used in a \section:

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\newcommand{\nix}{\textsc{Un\raisebox{-0.3\height}{*}x}}
\begin{document}

\nix

\section{\nix}

\end{document}
gives

Code: Select all

! Argument of \@sect has an extra }.
<inserted text> 
                \par 
l.8 \section{\nix}
                  
Runaway argument?
{\normalfont \Large \bfseries }{\@rsbox {-0.3\height }}\def \reserved@b \ETC.
! Paragraph ended before \@sect was complete.
<to be read again> 
                   \par 
l.8 \section{\nix}
Here is an alternative solution:

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}

% only so we can test the different font variants that `lmodern' does not
% have:
\usepackage{libertine}

\newcommand{\nix}{\textsc{Un\lower.6ex\hbox{*}x}}

% a command for testing:
\newcommand\test[1]{%
  \begingroup
  #1 \tiny \nix
  \footnotesize\nix
  \small\nix
  \normalsize\nix
  \large\nix
  \Large\nix
  \LARGE\nix
  \huge\nix
  \Huge\nix
  \endgroup
}

\begin{document}

\nix

\section{\nix}

\test{}

\noindent\test{\bfseries}

\noindent\test{\itshape}

\noindent\test{\itshape\bfseries}

\noindent\test{\sffamily}

\noindent\test{\sffamily\bfseries}

\noindent\test{\sffamily\itshape\bfseries}


\end{document}
Regards
site moderator & package author
AliceWonder
Posts: 28
Joined: Wed Oct 31, 2012 12:04 am

Re: lowering a character in a section heading.

Post by AliceWonder »

Thank you! That works very well.
Post Reply