3

I define a macro (\chit) that uses one font (sc), and the macro is used in another macro that textbf in the implementation - \textbf{Q\thequestion: #1?}.

\documentclass[12pt]{article}
\usepackage{xspace}

\newcounter{question}

\newcommand{\chit}{\textsc{Chitx}\xspace}
\newcommand\Que[1]{%
    \leavevmode\par
    \stepcounter{question}
    \noindent
    \textbf{Q\thequestion: #1?}\par}

\newcommand\Ans[1]{%
     \leavevmode\par\noindent
    {\textbf{A\thequestion:} #1\par}}

\begin{document}

\Que{What is \chit}? % <-- Wrong font
What is \chit? % <-- Correct font

\end{document}

As a result, the output does not show the font type that I expected. How to protect the font type that I specified in the \chit macro?

enter image description here

EDIT1

For the Q&A macro, I copied it from Q&A Template in LaTeX

  • what is the intention of \leavevmode\par\noindent ? It's a rather strange construct! – David Carlisle Mar 6 '16 at 1:06
  • @David: I just copied them from other question. I updated the post. – prosseek Mar 6 '16 at 1:28
4

You get the warning

LaTeX Font Warning: Font shape `OT1/cmr/bx/sc' undefined
(Font)              using `OT1/cmr/bx/n' instead on input line 19.

which means that there is no boldface small caps font in the Computer Modern font family.

On the other hand, the European Modern font family does have it.

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{xspace}

\newcounter{question}

\newcommand{\chit}{\textsc{Chitx}\xspace}
\newcommand\Que[1]{%
    \leavevmode\par
    \stepcounter{question}%
    \noindent
    \textbf{Q\thequestion: #1?}\par}

\newcommand\Ans[1]{%
     \leavevmode\par\noindent
    {\textbf{A\thequestion:} #1\par}}

\begin{document}

\Que{What is \chit}? % <-- Wrong font
What is \chit? % <-- Correct font

\end{document}

enter image description here

I'm not sure what \leavevmode\par is for; if your aim is to have some space before the question, it's the wrong tool:

\newcommand\Que[1]{%
    \par\addvspace{\bigskipamount}% <--- or whatever
    \noindent\stepcounter{question}
    \textbf{Q\thequestion: #1?}\par
}

Full code:

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

\newcounter{question}

\newcommand{\chit}{\textsc{Chitx}}
\newcommand\Que[1]{%
  \par\addvspace{\bigskipamount}% <---- fix it
  \noindent\stepcounter{question}%
  \textbf{Q\thequestion: #1?}\par
}

\newcommand\Ans[1]{%
  \par\noindent
  \textbf{A\thequestion:}~#1\par
}

\begin{document}

Some text before the question. What is \chit?

\Que{What is \chit}
\Ans{I don't know}

\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.