자동 참조 언어를 변경하시겠습니까?

자동 참조 언어를 변경하시겠습니까?

나는 라텍스를 사용하여 폴란드어로 글을 쓰려고 합니다. babel와 함께 패키지를 사용하고 있습니다 hyperref. 나는 이것으로 충분할 것이라고 생각했지만 분명히 그렇지 않습니다.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[polish]{babel}
\usepackage[utf8]{inputenc}

\usepackage{hyperref}

\begin{document}
\section{foo}
\label{sec:here}

\begin{figure}
\caption{\label{fig:here} This is a figure caption}
\end{figure}

\autoref{sec:here}

\autoref{fig:here}
\end{document}

이는 다음을 생성합니다.

산출

보시다시피 그림 캡션은 폴란드어로 올바르게 작성되었지만 자동 참조는 여전히 영어로 되어 있습니다.

뭔가 간단해야 할 것 같아요. 예를 들어, 질문babel의 `main=` 기능을 사용할 때 잘못된 자동 참조 이름위와 같은 것을 암시한다~해야 한다일하다. 내가 Stackexchange나 Google에서 찾을 수 있었던 다른 모든 자료는 내가 설명하는 것보다 더 구체적인 용도에 초점을 맞추고 있었습니다.

그렇다면 내가 무엇을 놓치고 있는 걸까요?

내가 알고 있는 가능한 해결 방법은 를 통해 해당 이름을 모두 수동으로 정의하는 것입니다 \def\figureautorefname. 하지만 누군가가 이미 공개 패키지에서 해당 작업을 수행하여 적절하게 유지관리되기를 바랍니다.

답변1

불행하게도 언어 지원은 매크로 Polish에 정의되어 있지 않습니다 .hyperref\...autorefname

hyperrefenglish,afrikaans,french,german,spanish,catalan,portuges,magyar, russian,italian,vietnamese아직 2017/03/14 버전 6.85a부터 지원됩니다 .

솔루션 시험:

매크로

\ProvidePolishAutoRefNames{figure=\figurename,chapter,section={PolishSectionName},table,equation={PolishEquationName}}

쉼표로 구분된 목록에 제공된 카운터 이름을 반복하여 \##1autorefname즉시 생성합니다.

figure=\figurename주어지면 etc의 이름을 사용하고 \figurename, 카운터 이름만 주어지면 어떤 경우에도 정의되지 않은 을 X사용하려고 시도합니다 .\Xname

PolishSectionName나는 폴란드어를 할 수 없기 때문에 등을 대체품으로 사용했습니다 .

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[polish]{babel}
\usepackage[utf8]{inputenc}

\usepackage{xparse}

\ExplSyntaxOn
\cs_generate_variant:Nn \cs_gset:cpn {cpx,cpo}
\NewDocumentCommand{\ProvidePolishAutoRefNames}{m}{%
  \seq_set_from_clist:Nn \l_tmpa_seq {#1}
  \seq_map_inline:Nn \l_tmpa_seq {% Loop through names
    \seq_set_split:Nnn \l_tmpb_seq {=} {##1}
    \tl_set:Nx \l_tmpa_tl {\seq_item:Nn \l_tmpb_seq {1} autorefname}
    \int_compare:nNnTF {\seq_count:N \l_tmpb_seq } > {1} {% Check whether there is a "=", if so, use the RHS 
      \cs_gset:cpx {\l_tmpa_tl} {\seq_item:Nn \l_tmpb_seq {2}}
    }{% No, try to evaluate \##1name, e.g. \chaptername
      \cs_gset:cpx {\l_tmpa_tl} {\use:c{\seq_item:Nn \l_tmpb_seq {1}name}}
    }
  }
}
\ExplSyntaxOff

\usepackage{hyperref}

\addto\captionspolish{%
  \ProvidePolishAutoRefNames{figure=\figurename,chapter,section={PolishSectionName},table,equation={PolishEquationName}}
}

\begin{document}

\chapter{Foo chapter}\label{foochapter}



\section{foo}

\figureautorefname

\label{sec:here}

\begin{figure}
\caption{\label{fig:here} This is a figure caption}
\end{figure}

\begin{equation} 
  E=mc^{2} \label{fooequation}
\end{equation}

See \autoref{foochapter} or \autoref{fooequation}

\autoref{sec:here}

\autoref{fig:here}
\end{document}

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

유사한 버전 \HyLang@polish으로 유사하게 정의합니다 HyLang@french.

\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage[polish]{babel}
\usepackage[utf8]{inputenc}

\usepackage{xparse}

\ExplSyntaxOn
\cs_generate_variant:Nn \cs_gset:cpn {cpx,cpo}
\NewDocumentCommand{\ProvidePolishAutoRefNames}{m}{%
  \seq_set_from_clist:Nn \l_tmpa_seq {#1}
  \seq_map_inline:Nn \l_tmpa_seq {% Loop through names
    \seq_set_split:Nnn \l_tmpb_seq {=} {##1}
    \tl_set:Nx \l_tmpa_tl {\seq_item:Nn \l_tmpb_seq {1} autorefname}
    \int_compare:nNnTF {\seq_count:N \l_tmpb_seq } > {1} {% Check whether there is a "=", if so, use the RHS 
      \cs_gset:cpx {\l_tmpa_tl} {\seq_item:Nn \l_tmpb_seq {2}}
    }{% No, try to evaluate \##1name, e.g. \chaptername
      \cs_gset:cpx {\l_tmpa_tl} {\use:c{\seq_item:Nn \l_tmpb_seq {1}name}}
    }
  }
}
\ExplSyntaxOff

\usepackage{hyperref}


\makeatletter
\def\HyLang@polish{
  \ProvidePolishAutoRefNames{figure=\figurename,chapter,section={PolishSectionName},table,equation={PolishEquationName}}
}

\HyLang@DeclareLang{polish}{polish}{}

\makeatother



\begin{document}

\chapter{Foo chapter}\label{foochapter}



\section{foo}

\figureautorefname

\label{sec:here}

\begin{figure}
\caption{\label{fig:here} This is a figure caption}
\end{figure}

\begin{equation} 
  E=mc^{2} \label{fooequation}
\end{equation}

See \autoref{foochapter} or \autoref{fooequation}

\autoref{sec:here}

\autoref{fig:here}
\end{document}

관련 정보