
나는 책을 쓰고 있는데 각 장의 마지막에는 다음과 같은 문제 라벨이 붙은 섹션이 있습니다.
\chapter{Chapter 1}
Bla bla bla...
\section*{Problems:}
\begin{enumerate}
\item \label{ch1_pr1} Prove...
\item \label{ch1_pr2} Calculate...
\item \label{ch1_pr3} Fill the details in...
\end{enumerate}
이 접근 방식의 문제는 모든 문제 섹션이 모든 장(1, 2, 3, 4 등...)에서 정확히 동일한 방식으로 번호가 매겨져 있다는 것입니다. 따라서 예를 들어 4장에서 첫 번째 문제를 인용하고 싶다면 첫 번째 장은 내 책에 '1'(숫자 1)만 넣을 것인데, 이는 내가 인용하고 있는 문제가 속한 장에 대해 어떠한 언급도 하지 않기 때문에 혼란을 야기할 것입니다.
그래서 내 질문은 다음과 같습니다문제가 속한 장을 고려하도록 문제를 어떻게 열거할 수 있습니까?
나는 1장의 문제에 대해서는 1.1, 1.2, 1.3, ..., 2장의 문제에 대해서는 2.1, 2.2, 2.3, ... 등을 생각하고 있었습니다. 그러나 어떻게 해야 할지 모르겠습니다.
나는 라텍스에 능숙하지 않기 때문에 내 문제에 대한 해결책을 가능한 한 간단하게 요청하겠습니다.
업데이트:다음은 컴파일하고 필요한 사항을 더 잘 이해할 수 있는 몇 가지 샘플 코드입니다.
\documentclass[12pt,letterpaper]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\begin{document}
\chapter{First}
Bla bla bla...
\section*{Problems:}
\begin{enumerate}
\item \label{ch1_pr1} Prove...
\item \label{ch1_pr2} Calculate...
\item \label{ch1_pr3} Fill the details in...
\end{enumerate}
\chapter{Second}
Bla bla bla....
\section*{Problems:}
\begin{enumerate}
\item \label{ch2_pr1} Prove...
\item \label{ch2_pr2} Calculate...
\item \label{ch2_pr3} Fill the details in...
\end{enumerate}
\chapter{Third}
First problem in Chapter 1:~\ref{ch1_pr1}
First problem in Chapter 2:~\ref{ch2_pr1} \\
The issue: Different problems appear to be the same when cited!
\end{document}
답변1
enumitem
다음은 새 목록과 사용자 정의 목록을 훨씬 쉽게 정의할 수 있는 패키지를 사용하는 유사한 솔루션입니다 . problems
환경 이름에도 사용했습니다 . 여기서 원래 문제 세트 내의 레이블은 1
무엇이든 상관없지만 참조 1.1
는 등 으로 나타납니다.
\label{}
나중에 항목을 삽입하거나 제거할 경우를 대비해 s 에 명시적인 숫자를 사용하지 않는 것이 가장 좋습니다 . LaTeX는 두 가지 야유를 신경 쓰지 않지만 chap3_prf5
2장의 9번 문제를 언급하면 인간을 크게 혼란스럽게 만드는 경향이 있습니다.
\documentclass{book}
\usepackage{enumitem}
\newlist{problems}{enumerate}{1}
\setlist[problems]{label={\arabic*.}, ref={\thechapter.\arabic*}}
\begin{document}
\chapter{Chapter 1}
Bla bla bla \dots
\section*{Problems:}
\begin{problems}
\item \label{pr:intro_prove} Prove \dots
\item \label{pr:intro_calc} Calculate \dots
\item \label{pr:intro_details} Fill the details in \dots
\end{problems}
\chapter{Pethau Pellach}
Fel dywedwyd ym mhroblem \ref{pr:intro_calc} \dots
\end{document}
원래 라벨에도 장 번호가 표시되도록 하려면 다음을 변경하십시오.
\setlist[problems]{label={\arabic*.}, ref={\thechapter.\arabic*}}
에게
\setlist[problems]{label={\thechapter.\arabic*}}
답변2
이를 수행하는 방법은 다음과 같습니다. 를 기반으로 하여 enumerate
제가 명명한 몇 가지 사양을 사용하여 problems
두 가지 수준이 있는 새 목록을 정의합니다.
\documentclass{report}
\usepackage{geometry}
\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{enumerate}{\everymath{\displaystyle}}
\newlist{problems}{enumerate}{2}
\setlist[problems]{wide=0pt}
\setlist[problems, 1]{label =\thechapter.\arabic*, font=\bfseries, wide=0pt}
\setlist[problems,2]{label =(\alph*), wide =0.5em, topsep=2pt, itemsep =2pt}
\begin{document}
\chapter{Chapter 1}
Bla bla bla...
\section*{Problems:}
\begin{problems}
\item \label{ch1_pr1} Prove...
\begin{problems}
\item A first question
\item Another silly question. A silly question. A silly question. A silly question. A silly question. A silly question. A silly question. A silly question. A silly question.
\end{problems}
\item \label{ch1_pr2} Calculate...
\item \label{ch1_pr3} Fill the details in...Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{problems}
\chapter{Chapter 2}
Bla bla bla...
\section*{Problems:}
\begin{problems}
\item \label{ch1_pr1} Prove...
\begin{problems}
\item A first question
\item Another silly question. A silly question. A silly question. A silly question. A silly question. A silly question. A silly question. A silly question. A silly question.
\end{problems}
\item \label{ch1_pr2} Calculate...
\item \label{ch1_pr3} Fill the details in...Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{problems}
\end{document}