다양한 유형 관련 측정항목을 인쇄하는 방법

다양한 유형 관련 측정항목을 인쇄하는 방법

@Johan_E의 답변에서LaTeX에서는 어떤 측정 단위를 사용해야 합니까?, 1em의 크기(포인트), 의 너비 M, 1ex 및 의 높이를 보여주는 유용한 차트가 있습니다 x. 어떻게 이런 차트를 만들 수 있나요? 가장 유용한 것은 측정 명령을 설명하기 위해 첫 번째 행을 생성하는 방법 및/또는 글꼴 선택이 수행되는 방법을 설명하기 위해 다른 행(예: bf, it)을 생성하는 방법에 대한 예입니다. (나는 BF,it을 얻는 방법을 알고 있지만 M어떻게 BF,it을 얻습니까 1em?)

나는 PDF 뷰어 화면을 확대하고 눈을 부릅뜨고 내 글꼴에 맞게 zlmtt의 크기를 조정하려고 영원히 노력하고 있습니다. 실제 측정을 하면 이러한 확장이 훨씬 쉬워집니다.

아래 주석에서 @jfbu의 조언을 활용하여 xintools 루프에서 다음을 추출했는데 작동하는 것 같습니다.

\documentclass{article}
\usepackage[T1]{fontenc}

\newcommand\oneem{}
\newcommand\oneex{}
\newcommand\Mwidth{}
\newcommand\xheight{}
\newcommand\xwidth{}
\newcommand\xdepth{}

\begin{document}
\edef\oneem{\the\dimexpr 1em\relax}%
\edef\oneex{\the\dimexpr 1ex\relax}%
\setbox0\hbox{M}%
\edef\Mwidth{\the\wd0}%
\setbox0\hbox{x}%
\edef\xheight{\the\ht0}%
\edef\xwidth{\the\wd0}%
\edef\xdepth{\the\dp0}%
%
\begin{tabular}{lllllll}
  font & 1em    & M-width & 1ex    & x-height & x-width & x-depth \\
  rm   & \oneem & \Mwidth & \oneex & \xheight & \xwidth & \xdepth
\end{tabular}
\end{document}

답변1

여기 있습니다:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[margin=1cm]{geometry}
\usepackage{xinttools}

\newcommand\WithFont [4]{%
   \csname text#1\endcsname {%
      \csname text#3\endcsname {%
         \csname text#2\endcsname {#4}}}}

\begin{document}
\begin{table}
  \centering
\Large\textbf{Computer Modern fonts (pdf\LaTeX) [10pt]}\\
\small
Selected using \detokenize{\textA{\textB{\textC{(some text)}}}},\\
with A in \detokenize{{rm, sf, tt}}; B in \detokenize{{md, bf}}; C in
\detokenize{{up, it, sl, sc}}\\
  \begin{tabular}{*{9}{l}}
    \bf Font&\bf 1em&&\bf M-width&\bf 1ex&&\bf x-height&\bf x-width&\bf x-depth\\
\hline
\xintForpair #1#2 in {(Roman,rm), (Sans,sf), (Typewriter,tt)} \do
{%
\xintFor #3 in {up, it, sl, sc}\do
  {%
    \xintFor #4 in {md, bf}\do
    {%
      \WithFont {#2}{#3}{#4}{#1, #3, #4\normalsize
                             \xdef\oneem{\the\dimexpr 1em\relax}%
                             \xdef\oneex{\the\dimexpr 1ex\relax}%
                             \setbox0\hbox{M}\xdef\Mwidth{\the\wd0}%
                             \setbox0\hbox{x}\xdef\xheight{\the\ht0}%
                                             \xdef\xwidth{\the\wd0}%
                                             \xdef\xdepth{\the\dp0}}%
      &\oneem&\WithFont{#2}{#3}{#4}{\normalsize\strut M}&\Mwidth
      &\oneex&\WithFont{#2}{#3}{#4}{\normalsize x}&\xheight&\xwidth&\xdepth
     \\
     }%
   }\hline
}\hline
  \end{tabular}
\end{table}
\end{document}

( 치수 계산을 포함하여 \normalsize모든 테이블이 체제 하에서 이전에 생성되었기 때문에 편집에 추가되었습니다 ).\small

여기에 이미지 설명을 입력하세요


위의 표에는 다양한 글꼴 대체가 진행되고 있습니다.

LaTeX Font Warning: Font shape `T1/cmss/m/sc' in size <9> not available
(Font)              Font shape `T1/cmr/m/sc' tried instead on input line 55.

LaTeX Font Warning: Font shape `T1/cmss/m/sc' in size <10> not available
(Font)              Font shape `T1/cmr/m/sc' tried instead on input line 55.

LaTeX Font Warning: Font shape `T1/cmss/bx/sc' undefined
(Font)              using `T1/cmss/bx/n' instead on input line 55.

LaTeX Font Info:    Font shape `T1/cmtt/bx/n' in size <9> not available
(Font)              Font shape `T1/cmtt/m/n' tried instead on input line 55.
LaTeX Font Info:    Font shape `T1/cmtt/bx/n' in size <10> not available
(Font)              Font shape `T1/cmtt/m/n' tried instead on input line 55.
LaTeX Font Info:    Font shape `T1/cmtt/bx/it' in size <9> not available
(Font)              Font shape `T1/cmtt/m/it' tried instead on input line 55.
LaTeX Font Info:    Font shape `T1/cmtt/bx/it' in size <10> not available
(Font)              Font shape `T1/cmtt/m/it' tried instead on input line 55.

LaTeX Font Warning: Font shape `T1/cmtt/bx/sl' undefined
(Font)              using `T1/cmtt/bx/n' instead on input line 55.

LaTeX Font Info:    Font shape `T1/cmtt/bx/sl' in size <10> not available
(Font)              Font shape `T1/cmtt/m/n' tried instead on input line 55.
LaTeX Font Info:    Font shape `T1/cmtt/bx/sl' in size <9> not available
(Font)              Font shape `T1/cmtt/m/n' tried instead on input line 55.

LaTeX Font Warning: Font shape `T1/cmtt/bx/sc' undefined
(Font)              using `T1/cmtt/bx/n' instead on input line 55.

LaTeX Font Info:    Font shape `T1/cmtt/bx/sc' in size <10> not available
(Font)              Font shape `T1/cmtt/m/n' tried instead on input line 55.
LaTeX Font Info:    Font shape `T1/cmtt/bx/sc' in size <9> not available
(Font)              Font shape `T1/cmtt/m/n' tried instead on input line 55.

예를 들어 전체 행에 취소선을 그리는 것을 고려했지만 이렇게 하면 자동으로 복잡해집니다. 이것이 OP의 주요 초점이 아니기 때문에 그대로 둡니다.


자동 결정을 위해 egreg의 답변을 뻔뻔하게 다른 구문으로 복사합니다. 위에서 사용된 패키지는 아래 xinttools에서 사용된 패키지와 별도입니다 xintfrac.

\documentclass[border=4pt]{standalone}

\usepackage{zlmtt}
\usepackage{xintfrac}


\makeatletter
\newcommand{\scalezlmtt}[2][1]{%
   {\setbox0\hbox{\normalfont #2}%
    \setbox2\hbox{\fontfamily{lmtt}\selectfont #2}%
    \xdef\zlmtt@scale {\xintPFloat {\xintMul{#1}{\ht0/\ht2}}}%
    \typeout{zlmtt scaling factor: \zlmtt@scale}% 
   }%
}%
\makeatother

\AtBeginDocument{\scalezlmtt[.9]{a}}

\begin{document}

TT font scaled to 90\% lowercase: A\texttt{A}a\texttt{a}

\end{document}

여기에 이미지 설명을 입력하세요

로그에서 다음을 확인할 수 있습니다.

zlmtt scaling factor: 0.9143980556305698

이것은 l3fp의 계산과 마지막 숫자가 다르지만 인쇄상 그다지 관련이 없습니다 ...

\xintPFloat [32]...( 예를 들어 더 많은 관련 없는 숫자를 원한다면 시도해 보십시오 . 좋습니다. 제가 했습니다:

zlmtt scaling factor: 0.91439805563056980826357007831488

0.1여기서 관련없는 장난을 숨기려면 배율 인수가 정말로 필요합니다 )

답변2

가능한 한 자동으로 축척 비율을 결정하는 매크로를 제공할 수 있습니다.

\documentclass{article}

\usepackage{zlmtt}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\scalezlmtt}{O{1}m}
 {
  \hbox_set:Nn \l_tmpa_box { \normalfont #2 }
  \hbox_set:Nn \l_tmpb_box { \fontfamily{lmtt}\selectfont #2 }
  \tl_set:cx { zlmtt@scale }
   {
    \fp_eval:n
     {
      #1 *
      \dim_to_fp:n { \box_ht:N \l_tmpa_box } /
      \dim_to_fp:n { \box_ht:N \l_tmpb_box }
     }
   }
  \typeout{ zlmtt~scaling:~\tl_use:c { zlmtt@scale } }
 }
\ExplSyntaxOff

\AtBeginDocument{\scalezlmtt{A}}

\begin{document}

TT font scaled to uppercase: A\texttt{A}a\texttt{a}

\end{document}

여기에 이미지 설명을 입력하세요

호출을 로 변경하면 \scalezlmtt{a},

\AtBeginDocument{\scalezlmtt{a}}

\begin{document}

TT font scaled to lowercase: A\texttt{A}a\texttt{a}

\end{document}

나는 얻다

여기에 이미지 설명을 입력하세요

"수정 인자"도 있습니다

\AtBeginDocument{\scalezlmtt[.9]{a}}

\begin{document}

TT font scaled to 90\% lowercase: A\texttt{A}a\texttt{a}

\end{document}

여기에 이미지 설명을 입력하세요

이는 테이블 조회나 시선을 피하는 데 충분히 유연해야 합니다. 작업을 수행하면 \AtBeginDocument에 대한 호출이 \normalfont올바른 호출이 됩니다. 이 지침 전에 다른 글꼴 패키지를 로드하세요. 일부 글꼴 패키지는 시작 문서에서도 작업을 수행하기 때문입니다.

트릭은 lmtt측정에 사용하는 것이므로 아직 <encoding>zlmtt.fd.

로그 파일에 다음과 같은 내용이 표시됩니다.

zlmtt scaling: 0.9143980556305699

(이것은 마지막 예에 사용된 값입니다.) 이 값이 자신에게 적합하다고 확신되면 반올림하여 패키지 옵션에 사용할 수 있습니다.

관련 정보