自動参照言語を変更しますか?

自動参照言語を変更しますか?

babel私はポーランド語で何かを記述するために LaTeX を使用しようとしています。パッケージを と一緒に使用しています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=` 機能を使用する場合の autoref 名が間違っている上記のすべき仕事。私が StackExchange や Google で見つけることができた他のすべての資料は、私が説明しているものよりも具体的な用途に焦点を当てていました。

それで、何が足りないのでしょうか?

私が知っている回避策としては、 を通じてすべての名前を手動で定義することです\def\figureautorefnameが、誰かがすでにそれをパブリック パッケージで実行し、適切にメンテナンスされていることを願っています。

答え1

残念ながら、マクロではPolish言語のサポートは定義されていません。hyperref\...autorefname

hyperref2017/03/14 のバージョン 6.85a 時点ではまだサポートされていenglish,afrikaans,french,german,spanish,catalan,portuges,magyar, russian,italian,vietnameseません。

解決策の試行:

マクロ

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

カンマ区切りのリストで指定されたカウンター名をループし、\##1autorefnameその場で生成します。

が指定されている場合はfigure=\figurename、 などの名前を使用し\figurename、カウンタ名だけが指定された場合は、いずれの場合も定義されていない をX使用しようとします。\Xname

私はポーランド語を話さないので、PolishSectionName代わりにetc.を使用しました。

\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}

関連情報