SORU
28 Kasım 2009, CUMARTESİ


Lateks İsteğe Bağlı Bağımsız Değişkenleri

Nasıl Lateks isteğe bağlı bağımsız değişkenleri ile bir komut oluşturmak mı? Gibi bir şey

\newcommand{\sec}[2][]{
    \section*{#1
        \ifsecondargument
            and #2
        \fi}
    }
}

Sonra, öyle diyebilirim

\sec{Hello}
%Output: Hello
\sec{Hello}{Hi}
%Output: Hello and Hi

CEVAP
28 Kasım 2009, CUMARTESİ


Gelen örnek guide:

\newcommand{\example}[2][YYY]{Mandatory arg: #2;
                                 Optional arg: #1.}

This defines \example to be a command with two arguments, 
referred to as #1 and #2 in the {<definition>}--nothing new so far. 
But by adding a second optional argument to this \newcommand 
(the [YYY]) the first argument (#1) of the newly defined 
command \example is made optional with its default value being YYY.

Thus the usage of \example is either:

   \example{BBB}
which prints:
Mandatory arg: BBB; Optional arg: YYY.
or:
   \example[XXX]{AAA}
which prints:
Mandatory arg: AAA; Optional arg: XXX.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • LevelUpTuts

    LevelUpTuts

    20 Ocak 2012
  • Motor Trend Channel

    Motor Trend

    11 Mart 2006
  • segtlim

    segtlim

    21 EKİM 2008