TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.