4

I want to have a macro that behaves differently based on the context. Assume I write a tutorial in X language. A term that I use must be written in X language followed by the corresponding English translation (enclosed and italicized in ()) only when it occurs at the first time. The remaining occurrence will only be written in X language.

I can do it with the following code.

\newif\ifVector
\newcommand{\Vector}{%
    \ifVector
        vektor%
    \else
        vektor (\textit{vector})%
        \Vectortrue
    \fi}

But a new problem arises. How to make the macro change its capitalization when it appears in the beginning of a sentence? Here is my complete dummy code for you.

\documentclass[preview,border=12pt]{standalone}

\newif\ifVector
\newcommand{\Vector}{%
    \ifVector
        vektor%
    \else
        vektor (\textit{vector})%
        \Vectortrue
    \fi}


\begin{document}
\Vector\space isg kush guste vien. Fur sji nam von gis ta marjo
navar \Vector. \Vector\space is fin nom bis kan da dej vanm.
\end{document}

enter image description here

2
  • Please, don't delete it, but vote to close pointing the original question: it might help future visitors. :) – Claudio Fiandrino Sep 13 '13 at 6:35
  • Why don't you just make two commands \vector and \Vector with appropriate capitalization in each? – Thruston Sep 13 '13 at 15:28

Browse other questions tagged or ask your own question.