
현재 글꼴 크기가 small
. 여기 제가 하려는 일의 MWE가 있습니다.
\documentclass{article}
\usepackage{ifthen}
\begin{document}
\makeatletter
\ifthenelse{\f@size = 9}{the size is 9}{the size is not 9}
\makeatother
\makeatletter
\small
\ifthenelse{\f@size = 9}{the size is 9}{the size is not 9}
\makeatother
\makeatletter
\ifthenelse{\f@size = {\small \f@size} }{the size is small}{the size is not small}
\makeatother
\end{document}
내가 원하는 결과는 다음과 같습니다.
그러나 어쨌든 {\small \f@size}
숫자로 "확장"되지는 않습니다. 실제로는 그렇습니다. 도와 주셔서 감사합니다. :)
답변1
이것이 당신이 염두에 두고 있는 것입니까? 매크로 \definesizecommand
는 다양한 크기에서 다르게 동작하는 명령을 정의할 수 있습니다. 이 명령은 에 표시된 대로 인수를 가질 수도 있습니다 \baz
.
\documentclass{article}
\usepackage{relsize}
\usepackage{xparse}
\ExplSyntaxOn
% relsize builds a list \rs@fontsizes of the form
% \rs@size\normalfont{10.0pt}\rs@size\small{9.0pt}...
% and we can use it for building a different list
\prop_new:N \g_lbj_size_to_name_prop
\prop_new:N \g_lbj_name_to_size_prop
\group_begin:
\cs_set:cpn { rs@size } #1 #2
{
\prop_gput:Nnx \g_lbj_size_to_name_prop { #2 } { \cs_to_str:N #1 }
}
\use:c { rs@fontsizes }
% this is not used, but could become handy
\cs_set:cpn { rs@size } #1 #2
{
\prop_gput:Nnx \g_lbj_name_to_size_prop { \cs_to_str:N #1 } { #2 }
}
\use:c { rs@fontsizes }
\group_end:
% just print the current size name
\NewDocumentCommand{\currentsizename}{}
{
\prop_item:Nf \g_lbj_size_to_name_prop { \dim_eval:n { \use:c {f@size} pt } }
}
\cs_generate_variant:Nn \prop_item:Nn { Nf }
\NewDocumentCommand{\definesizecommand}{mmmO{}}
{% #1 is the command to define,
% #2 is the argument specifier,
% #3 is the list of actions,
% #4 is the optional action to do in uncovered cases
\NewDocumentCommand{#1}{#2}
{
\str_case:xnF
{ \prop_item:Nf \g_lbj_size_to_name_prop { \dim_eval:n { \use:c { f@size } pt } } }
{ #3 }
{ #4 }
}
}
\cs_generate_variant:Nn \str_case:nnF { x }
\ExplSyntaxOff
\definesizecommand{\foo}{}{
{normalsize}{normalfoo}
{small}{smallfoo}
{tiny}{tinyfoo}
}[extrafoo]
\definesizecommand{\baz}{m}{
{normalsize}{---#1---}
{small}{!#1!}
{tiny}{?#1?}
}[(#1)]
\begin{document}
Here we're in \currentsizename: \foo\ and \baz{x}
\small
Here we're in \currentsizename: \foo\ and \baz{y}
\tiny
Here we're in \currentsizename: \foo\ and \baz{z}
\Large
Here we're in \currentsizename: \foo\ and \baz{A}
\end{document}
relsize
로드하지 않고 다음을 활용하는 다른 버전 \@currsize
:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\cs_new:Nn \lbj_curr_size:
{
\__lbj_curr_size:c { @currsize }
}
\cs_new:Nn \__lbj_curr_size:N
{
\exp_after:wN \__lbj_curr_size_aux:NNw #1 \q_stop
}
\cs_generate_variant:Nn \__lbj_curr_size:N { c }
\cs_new:Npn \__lbj_curr_size_aux:NNw #1 #2 #3 \q_stop
{
\tl_if_blank:nTF { #3 }
{
\__lbj_curr_size:N #2
}
{
\cs_to_str:N #2
}
}
% just print the current size name
\NewDocumentCommand{\currentsizename}{}
{
\lbj_curr_size:
}
\NewDocumentCommand{\definesizecommand}{mmmO{}}
{% #1 is the command to define,
% #2 is the argument specifier,
% #3 is the list of actions,
% #4 is the optional action to do in uncovered cases
\NewDocumentCommand{#1}{#2}
{
\str_case:fnF
{ \lbj_curr_size: }
{ #3 }
{ #4 }
}
}
\cs_generate_variant:Nn \str_case:nnF { f }
\ExplSyntaxOff
\definesizecommand{\foo}{}{
{normalsize}{normalfoo}
{small}{smallfoo}
{tiny}{tinyfoo}
}[extrafoo]
\definesizecommand{\baz}{m}{
{normalsize}{---#1---}
{small}{!#1!}
{tiny}{?#1?}
}[(#1)]
\begin{document}
Here we're in \currentsizename: \foo\ and \baz{x}
\small
Here we're in \currentsizename: \foo\ and \baz{y}
\tiny
Here we're in \currentsizename: \foo\ and \baz{z}
\Large
Here we're in \currentsizename: \foo\ and \baz{A}
\end{document}
답변2
답변3
{\small \f@size}
숫자가 아닙니다. f@size-value를 먼저 저장하는 것이 좋습니다.
\documentclass{article}
\usepackage{ifthen}
\begin{document}
\makeatletter
\ifthenelse{\f@size=9}{the size is 9}{the size is not 9}
\makeatother
\makeatletter
\small
\ifthenelse{\f@size=9}{the size is 9}{the size is not 9}
\makeatother
\makeatletter
{\small \xdef\smallfsize{\f@size}}
\ifthenelse{\f@size=\smallfsize}{the size is small}{the size is not small}
\makeatother
\end{document}
답변4
나는 첫 번째 글꼴 크기를 저장했습니다 \f@size
( \small
이전 \begin{document}
및 \ifthenelse{...}
이를 현재 크기와 비교하는 데 사용).
\documentclass{article}
\usepackage{xifthen}
\makeatletter
{\small\xdef\smallfontsize{\f@size}}
\makeatother
\begin{document}
\makeatletter
\large
\ifthenelse{\f@size = \smallfontsize }{the size is small}{the size is not small}
\small
\ifthenelse{\f@size = \smallfontsize }{the size is small}{the size is not small}
\makeatother
\end{document}