![라텍스의 하이퍼참조에 적절한 하이퍼링크가 있는 두 개의 숫자 카운터를 구현하는 방법은 무엇입니까?](https://rvso.com/image/266396/%EB%9D%BC%ED%85%8D%EC%8A%A4%EC%9D%98%20%ED%95%98%EC%9D%B4%ED%8D%BC%EC%B0%B8%EC%A1%B0%EC%97%90%20%EC%A0%81%EC%A0%88%ED%95%9C%20%ED%95%98%EC%9D%B4%ED%8D%BC%EB%A7%81%ED%81%AC%EA%B0%80%20%EC%9E%88%EB%8A%94%20%EB%91%90%20%EA%B0%9C%EC%9D%98%20%EC%88%AB%EC%9E%90%20%EC%B9%B4%EC%9A%B4%ED%84%B0%EB%A5%BC%20%EA%B5%AC%ED%98%84%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
퀴즈가 포함된 책을 조판하고 싶습니다. 두 가지 유형의 수치를 갖고 싶습니다.
- 텍스트 숫자: i, ii(로마자)로 색인화되어 있습니다.
- 퀴즈 숫자: 이 숫자는 퀴즈와 관련되어 있으며 적절한 번호가 지정되어야 합니다: 1,2,3...n
나는 퀴즈 그림이 서로의 위에 있지 않고 서로 옆에 있기를 원합니다. 이를 달성하는 유일한 방법은 하위 플로트를 사용하는 것입니다. 원칙적으로 이것은 적절한 참조를 제공하는 사용자 정의 카운터를 사용하여 가능합니다. 그러나 hyperref 패키지는 이러한 사용자 지정 카운터를 이해하지 못하는 것 같습니다.
적절한 그림에 연결되는 하이퍼참조 링크를 어떻게 얻나요?
내 구현은 다음과 같습니다.
\documentclass{book}
\usepackage[english]{babel}
\usepackage[]{graphicx}
\usepackage{subfig}
\usepackage{hyperref}
%Counters
\newcounter{textcounter}
\setcounter{textcounter}{0}
\newcounter{quizcounter}
\setcounter{quizcounter}{0}
\begin{document}
\chapter*{Chaptername}
\section*{Introduction}
This is our normal text, where we want to refer to accompanying figures like figure \ref{textfigure1}.
\begin{figure}
\addtocounter{textcounter}{1}
\renewcommand{\thesubfigure}{\roman{textcounter}}
\renewcommand{\thefigure}{}
\subfloat[Example textfigure]{\includegraphics[width=0.5\columnwidth]{example_ti.jpg}\label{textfigure1}}
\end{figure}
\section*{Table}
\begin{enumerate}
\item Question one, asking questions about quizfigure \ref{quizfigure1}.
\item Question two, asking questions about quizfigure \ref{quizfigure2} , with more info in textfigure \ref{textfigure1}.
\end{enumerate}
\section*{quizfigures}
\begin{figure}
\renewcommand{\thesubfigure}{\arabic{quizcounter}}
\renewcommand{\thefigure}{}
\addtocounter{quizcounter}{1}
\subfloat[Example quizfigure 1]{\includegraphics[width=0.5\columnwidth]{example_q1.jpg}\label{quizfigure1}}
\end{figure}
\newpage
\begin{figure}
\renewcommand{\thesubfigure}{\arabic{quizcounter}}
\renewcommand{\thefigure}{}
\addtocounter{quizcounter}{1}
\subfloat[Example quizfigure 2]{\includegraphics[width=0.5\columnwidth]{example_q2.jpg}\label{quizfigure2}}
\addtocounter{quizcounter}{1}
\subfloat[Example quizfigure 3]{\includegraphics[width=0.5\columnwidth]{example_q3.jpg}\label{quizfigure3}}
\end{figure}
\end{document}
답변1
사용자 정의 카운터를 사용할 필요는 없으며 패키지에 내장된 카운터를 사용할 수 있습니다 subcaption
. 이는 더 이상 사용되지 않는 패키지를 대체합니다 subfig
.
당신이 사용할 수있는
\captionsetup{labelformat=empty,labelsep=none}
\renewcommand{\thefigure}{}
피규어 자체의 라벨을 억제하고 하위 피규어에 마치 피규어인 것처럼 이름을 지정합니다.
로마 숫자가 포함된 내장 카운터를 사용하려면 다음을 사용할 수 있습니다.
\renewcommand{\thesubfigure}{\roman{subfigure}}
별도의 Figure 환경 사이에서 하위 Figure의 레이블 개수를 계속하려면 caption{}
마지막 Figure에서만 사용해야 합니다.
\documentclass{book}
\usepackage[english]{babel}
\usepackage[]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{hyperref}
\captionsetup{labelformat=empty,labelsep=none}
\renewcommand{\thefigure}{}
\begin{document}
\chapter*{Chaptername}
\section*{Introduction}
This is our normal text, where we want to refer to accompanying figures like figure \ref{textfigure1}.
\begin{figure}
\renewcommand{\thesubfigure}{\roman{subfigure}}
\begin{subfigure}{6cm}
\caption{Example textfigure}
\label{textfigure1}
\end{subfigure}
\caption{}
\label{test}
\end{figure}
\section*{Table}
\begin{enumerate}
\item Question one, asking questions about quizfigure \ref{quizfigure1}.
\item Question two, asking questions about quizfigure \ref{quizfigure2} and \ref{quizfigure3} , with more info in textfigure \ref{textfigure1}.
\end{enumerate}
\section*{quizfigures}
\begin{figure}
\begin{subfigure}{3cm}
\caption{Example quizfigure 1}
\label{quizfigure1}
\end{subfigure}
\end{figure}
\newpage
\begin{figure}
\begin{subfigure}{3cm}
\caption{Example quizfigure 2}
\label{quizfigure2}
\end{subfigure}
\begin{subfigure}{3cm}
\caption{Example quizfigure 3}
\label{quizfigure3}
\end{subfigure}
\caption{}
\end{figure}
\end{document}