Köşeli ayraç içinde veya kırpmak için makro kullanamazsınız
Bir kullanıcı komutuyla isteğe bağlı şekil parametrelerini varsayılan olarak tanımlamaya çalışıyorum ancak [ ]
. Sonraki örnek, trim=0 0 0 0
ile değiştirdiğimde bir istisna atıyor trim=\trim
.
\usepackage[demo]{graphicx}
\newcommand{\trim}{0 0 0 0}
\begin{document}
\begin{figure}[htbp]
\centering
\includegraphics[width=\linewidth,trim=0 0 0 0,clip]{Figure}
\caption{blablabla.}
\end{figure}
\end{document}
Ayrıca amacım, width=\linewidth,trim=0 0 0 0,clip
içindeki tüm cümleyi [ ]
onunla değiştirebileceğim bir emir tanımlamaktır .
Yanıtlar
20 AĞUSTOS 2020'DE DÜZENLEME
Bir kez daha (Ulrich Diez) kendimi utanç verici bir duruma soktum:
Aşağıdakileri yazarken, ben (Ulrich Diez) köşeli parantezlerin [
ve ]
–küme parantezlerinin aksine– kategori kodu 1 ve 2 olmadıklarını, kategori kodu 12'nin sıradan karakterleri olduklarını ve bu nedenle köşeli parantezler olduğunu düşünmedim makro argümanlar içinde ortaya çıkabilir. Aşağıdaki koddan daha az karmaşık ve çok daha kısa:
\documentclass{article}
\usepackage[demo]{graphicx}
\newcommand\exchange[2]{#2#1}
\newcommand{\trim}{0 0 0 0}
\begin{document}
\begin{figure}[htbp]
\centering
\expandafter\exchange\expandafter{\trim}{%
\includegraphics[width=\linewidth,trim=%
},clip]{/path/to/graphics/file.jpg}%%%%%
% Why two captions?
\caption{Testing of the Y-axis.}%%%%%
\caption{blablabla.}%%%%%
\end{figure}
\end{document}
Sekans
\expandafter\exchange\expandafter{\trim}{%
\includegraphics[width=\linewidth,trim=%
},clip]{/path/to/graphics/file.jpg}%%%%%
aşağıdakileri tetikler:
\expandafter
Genişletilmesine-zinciri potansiyel müşteriler \trim
:
\exchange{0 0 0 0}{%
\includegraphics[width=\linewidth,trim=%
},clip]{/path/to/graphics/file.jpg}%%%%%
Artan \exchange
verim:
\includegraphics[width=\linewidth,trim=%
0 0 0 0,clip]{/path/to/graphics/file.jpg}%%%%%
20 AĞUSTOS 2020 DÜZENLEME SONU
\trim
-Komutunun tanımı şekilden şekle değişebiliyorsa, o zaman, örneğin, \romannumeral0
-genişleme- ve argüman alışverişi-tekniğini kullanabilirsiniz - -genişlemenin özü \romannumeral0
:
- TeX , roma rakamlarıyla temsil edilecek "sayı " miktarına ait jetonları toplarken genişletilebilir jetonları genişletir .
- TeX'in " sayı " miktarını toplarken bulduğu ilk belirteç bir rakamsa , örneğin,
0
" sayıya" ait jetonları toplama işlemi, daha fazla basamak veya olmayan bir şey toplama sürecine dönüşür. bir rakamdır ve bu nedenle toplama sürecini sonlandırır. Genişletilebilir belirteçler, rakamları toplarken genişletilir. Bir rakam dizisini sonlandıran bir boşluk belirteci, daha fazla basamak toplama sürecini sonlandırır ve sessizce atılır. - Toplanan sayı pozitif değilse, TeX karşılığında herhangi bir jeton teslim etmeden " sayı " miktarını oluşturan jetonları sessizce yutacaktır .
Bu \romannumeral
, sonunda pozitif olmayan bir sayının bulunması sağlandığı sürece TeX'i çok sayıda genişletme ve argüman değiş tokuşu yapması için kandırmak için kullanılabileceği anlamına gelir .
\documentclass{article}
\usepackage[demo]{graphicx}
\newcommand\exchange[2]{#2#1}
\newcommand{\trim}{0 0 0 0}
\begin{document}
\begin{figure}[htbp]
\centering
\expandafter\includegraphics\expandafter[%
\romannumeral0%
\expandafter\exchange
\expandafter{\trim}{ width=\linewidth,trim=},clip%
]{/path/to/graphics/file.jpg}%%%%%
% Why two captions?
\caption{Testing of the Y-axis.}%%%%%
\caption{blablabla.}%%%%%
\end{figure}
\end{document}
Sekans
\expandafter\includegraphics\expandafter[%
\romannumeral0%
\expandafter\exchange
\expandafter{\trim}{ width=\linewidth,trim=},clip%
]{/path/to/graphics/file.jpg}%%%%%
aşağıdakileri tetikler:
(Üst düzey) genişletme elde etme \expandafter
süreci, bir sonraki ancak bir belirtecin üst düzey genişlemesini sağlama sürecini tetikler ve bir sonraki jetonun üst düzey genişlemesini elde etme süreci sona erdiğinde sona erer. . Böylece:
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggers the process of obtaining the top-level-
% expansion of the next but one token:
\includegraphics\expandafter[%
\romannumeral0%
\expandafter\exchange
\expandafter{\trim}{ width=\linewidth,trim=},clip%
]{/path/to/graphics/file.jpg}%%%%%
Birinciden giden bir sonraki ancak bir jeton \expandafter
da bir \expandafter
, dolayısıyla:
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter in
% progress, this process triggers the process of obtaining the top-level-
% expansion of the next but one token:
[%
\romannumeral0%
\expandafter\exchange
\expandafter{\trim}{ width=\linewidth,trim=},clip%
]{/path/to/graphics/file.jpg}%%%%%
İkinciden iki sonraki jetonu giden \expandafter
olan \romannumeral
, böylece:
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of \romannumeral:
[%
% Process of obtaining the top-level-expansion of \romannumeral in progress;
% Sub-process of \romannumeral-expansion for gathering tokens of a <number>-
% quantity in progress:
0%
\expandafter\exchange
\expandafter{\trim}{ width=\linewidth,trim=},clip%
]{/path/to/graphics/file.jpg}%%%%%
TeX rakamı bulur 0
, bu nedenle bir \romannumeral
" sayı " miktarının jetonlarını toplama alt süreci, daha fazla rakam toplama sürecine veya rakam dizisini sonlandıran bir şeye dönüşür:
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of \romannumeral:
[%
% Process of obtaining the top-level-expansion of \romannumeral in progress;
% Sub-process of \romannumeral-expansion for gathering more digits of a
% <number>-quantity in progress; digit "0" found so far:
\expandafter\exchange
\expandafter{\trim}{ width=\linewidth,trim=},clip%
]{/path/to/graphics/file.jpg}%%%%%
" Sayı " miktarına ait daha fazla jeton / rakam ararken , TeX üçüncüyle karşılaşır \expandafter
:
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of \romannumeral:
[%
% Process of obtaining the top-level-expansion of \romannumeral in progress;
% Sub-process of \romannumeral-expansion for gathering more digits of a
% <number>-quantity in progress; digit "0" found so far:
% Process of obtaining the top-level-expansion of the third \expandafter
% in progress, this process triggers the process of obtaining the top-
% level-expansion of the next but one token:
\exchange
\expandafter{\trim}{ width=\linewidth,trim=},clip%
]{/path/to/graphics/file.jpg}%%%%%
Üçüncüsünden giden bir sonraki ancak bir jeton \expandafter
şu \expandafter
şekilde:
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of \romannumeral:
[%
% Process of obtaining the top-level-expansion of \romannumeral in progress;
% Sub-process of \romannumeral-expansion for gathering more digits of a
% <number>-quantity in progress; digit "0" found so far:
% Process of obtaining the top-level-expansion of the third \expandafter
% in progress, this process triggerd the process of obtaining the top-
% level-expansion of the fourth \expandafter:
\exchange
% Process of obtaining the top-level-expansion of the fourth \expandafter
% in progress, this process triggers the process of obtaining the top-
% level-expansion of the next but one token:
{\trim}{ width=\linewidth,trim=},clip%
]{/path/to/graphics/file.jpg}%%%%%
Dördüncü bir sonraki ama bir belirteç giden \expandafter
IS \trim
, dördüncü üst düzey genişleme elde böylece sürecin \expandafter
en üst düzey-genişleme elde etme süreci sona eren, \trim
sonlandırıldığında olup:
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of \romannumeral:
[%
% Process of obtaining the top-level-expansion of \romannumeral in progress;
% Sub-process of \romannumeral-expansion for gathering more digits of a
% <number>-quantity in progress, digit "0" found so far:
% Process of obtaining the top-level-expansion of the third \expandafter
% in progress, this process triggerd the process of obtaining the top-
% level-expansion of the fourth \expandafter:
\exchange
% Process of obtaining the top-level-expansion of the fourth \expandafter
% terminated.
{0 0 0 0}{ width=\linewidth,trim=},clip%
]{/path/to/graphics/file.jpg}%%%%%
Dördüncünün \expandafter
en üst düzey genişlemesini elde etme süreci \expandafter
sona erdiğinden, üçüncü sonların üst düzey genişlemesini elde etme süreci de sona erer:
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of \romannumeral:
[%
% Process of obtaining the top-level-expansion of \romannumeral in progress;
% Sub-process of \romannumeral-expansion for gathering more digits of a
% <number>-quantity in progress, digit "0" found so far:
% Process of obtaining the top-level-expansion of the third \expandafter
% terminated.
\exchange
{0 0 0 0}{ width=\linewidth,trim=},clip%
]{/path/to/graphics/file.jpg}%%%%%
Üçüncüsünün en üst düzey genişlemesini elde etme süreci \expandafter
sona ererken, \romannumeral
genişleme devam eder ve bu da genişlemeyi sağlar \exchange
:
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of \romannumeral:
[%
% Process of obtaining the top-level-expansion of \romannumeral in progress;
% Sub-process of \romannumeral-expansion for gathering more digits of a
% <number>-quantity in progress; digit "0" found so far:
<space-token>width=\linewidth,trim=0 0 0 0,clip%
]{/path/to/graphics/file.jpg}%%%%%
TeX, bir boşluk belirteci bulur. Bu boşluk, belirteci son bulur daha çok bir basamak toplama alt proses ⟨number⟩ -Miktar ve sessizce atılır alır.
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of \romannumeral:
[%
% Process of obtaining the top-level-expansion of \romannumeral in progress;
% Sub-process of \romannumeral-expansion for gathering more digits of a
% <number>-quantity terminated; number "0" found.
width=\linewidth,trim=0 0 0 0,clip%
]{/path/to/graphics/file.jpg}%%%%%
Tex olarak Bulunan ⟨number⟩ , değeri -Miktar 0
ise, 0
pozitif bir değer, en üst düzey-genişleme elde etme işlemi değil \romannumeral
sessizce şekillendirme belirteçleri yutarak sonlanıncaya ⟨number⟩ bir belirteç in teslim TeX olmadan -Miktar dönüş.
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of \romannumeral:
[%
% Process of obtaining the top-level-expansion of \romannumeral terminated.
width=\linewidth,trim=0 0 0 0,clip%
]{/path/to/graphics/file.jpg}%%%%%
Üst düzey genişlemeyi \romannumeral
elde etme süreci \expandafter
sona erdiğinden, ikinci sonun üst düzey genişlemesini elde etme süreci de sona erer:
% Process of obtaining the top-level-expansion of the first \expandafter in
% progress, this process triggerd the process of obtaining the top-level-
% expansion of the second \expandafter:
\includegraphics
% Process of obtaining the top-level-expansion of the second \expandafter
% terminated.
[%
width=\linewidth,trim=0 0 0 0,clip%
]{/path/to/graphics/file.jpg}%%%%%
İkincinin en üst düzey genişlemesini \expandafter
elde etme süreci \expandafter
sona ererken, ilkinin üst düzey genişlemesini elde etme süreci de sona erer:
% Process of obtaining the top-level-expansion of the first \expandafter
% terminated.
\includegraphics
[%
width=\linewidth,trim=0 0 0 0,clip%
]{/path/to/graphics/file.jpg}%%%%%