그룹의 첫 글자만 조판하세요

그룹의 첫 글자만 조판하세요

텍스트 그룹의 첫 글자만 조판(인쇄)하려면 어떻게 해야 합니까?

예를 들어, 이름의 첫 번째 이니셜을 어떻게 결정합니까 biblatex?bibtex

MWE를 시작하려면:

\documentclass[]{article}

\begin{document}

This prints \firstinit{just the first letter}.

My hero is \firstinit{John} \firstinit{Paul} Jones.

\end{document}

답변1

루틴\justfirst 인수가 필요합니다.~ 아니다중괄호 안에 있지만 알려진 수량으로 종료됩니다. 따라서 는 사용자가 모르는 사이 \firstinit에 와 공모하여 a를 종결자로 사용합니다. 왜냐하면 a가 사용자 텍스트에 표시될 가능성이 낮기 때문입니다.\justfirst\relax

\documentclass[]{article}
\def\firstinit#1{\justfirst#1\relax}
\def\justfirst#1#2\relax{#1}

\begin{document}

This prints \firstinit{just the first letter}.

My hero is \firstinit{John} \firstinit{Paul} Jones.

\end{document}

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


물론, 여러 단어로 구성된 구문에서 첫 글자를 출력하려는 ​​경우즉, 조금 더 어렵습니다. 재귀를 활용하도록 수정되었습니다. 패키지 사용을 제거하기 위해 다시 개정되었습니다. "라마"에 의한 패배를 방지하기 위해 다시 개정되었습니다.

\documentclass[]{article}
\def\firstinit#1{\justfirst#1 \relax\relax}
\def\justfirst#1#2 #3\relax{#1\if\relax#3\else{} \justfirst#3\relax\fi}
\begin{document}
This prints \firstinit{just the first llama in the list}.

My hero is \firstinit{John} \firstinit{Paul} Jones.
\end{document} 

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

관련 정보