ã³ã¬ã«é¢ãã話ã
ææ¸ããããã£ã«ã¤ãã¦èªããã
ãã®è¨äºã®èª¬æï¼ãªãªã¸ãã«ã®LaTeX Newsã®å
容ãã»ã¼åãï¼ãèªãã¨ãææ¸ããããã£1ã¯å¾æ¥ã®ç¸äºåç
§ï¼\label
ï¼\ref
ï¼ã®æ©æ§ãæ¡å¼µãããã®ã§ããããå¤ãâå±éå¯è½âãªæ¹æ³ã§åå¾å¯è½ã§ããã¨èª¬æããã¦ããããããè¦ãéãããã®æ°æ©è½ã«ãã£ã¦ãé·å¹´TeXè¨èªããã°ã©ããæ©ã¾ãã¦ãããã©ãã«ã«ç´ã¥ãå¤ãåå¾ãã確å®ãªæ¹æ³ããªããã¨ããåé¡ã解決ãããããã«æããã
ãããå®éã«ãã§ãã調ã¹ã¦ã¿ãã¨ãããå°ãªãã¨ãç¾ç¶ã§ã¯ãã®å¸æç観測ã¯çå¤ãã§ãå®éã«ã¯ææ¸ããããã£ã®æ©è½ã¯ãã©ãã«ã«ç´ã¥ãå¤ã®åå¾ãã«ã¯ä½¿ããªãã£ãï¼ããããðï¼ãã¨ãã話ã
ãã©ãã«ã«ç´ã¥ãå¤ã®åå¾ããé£ãã
以ä¸ã«LaTeXã®ããã¼ã®ç¸äºåç §ãå©ç¨ããææ¸ã示ã2ã
\documentclass[a4paper]{article} \begin{document} \setcounter{section}{41}% ç¯çªå·ã42ããå§ãã \section{Duck}\label{sec:duck}% ã©ãã«ãä»ãã Quack! \section{Conclusion} Section~\ref{sec:duck} (p.~\pageref{sec:duck}) is dull. \end{document}
ãã®ææ¸ã½ã¼ã¹ä¸ã§ã\ref{sec:duck}
ã¯\label{sec:duck}
ãä»ä¸ããç¯ã®çªå·ã\pageref{sec:duck}
ã¯å½è©²ã®ç¯ã®ãããã¼ã¸ã®çªå·ãåºåããããã«ä½¿ããã¦ãããããã§æ³¨æãã¹ããªã®ã¯ãLaTeXã®ä»æ§ã¨ãã¦ã¯\ref
ã¨\pageref
ã¯ããã¾ã§çªå·ããåºåãããå½ä»¤ã§ãããçªå·ããåå¾ãããããã®æ段ã¯ç¨æããã¦ããªããã¨ãããã¨ã§ããã
ç¸äºåç §ã®ä½¿ãæ¹ã«ãã£ã¦ã¯åã«çªå·ãåºåãã以å¤ã®ä½¿ãæ¹ããããå ´åããããããã§ã¯ï¼æ¥µãã¦äººå·¥çãªä¾ã§ãããï¼æ¬¡ã®ãããªå½ä»¤ãå®è£ ãããã¨ãèãã¦ã¿ããã
\myRefSum{â¹ã©ãã«âº}
ï¼â¹ã©ãã«âº
ã«ç´ã¥ãã«ã¦ã³ã¿3ã®çªå·ï¼\ref{â¹ã©ãã«âº}
ã®å¤ï¼ã¨ãã¼ã¸çªå·ï¼\pageref{â¹ã©ãã«âº}
ã®å¤ï¼ã®åè¨ã®å¤ãåºåããã
ãã®å½ä»¤ãå®è£
ãããã¨ããã¨ã\ref
ã\pageref
ãåç´ã«ä½¿ã£ã¦çªå·ãåºåããã ãã§ã¯éã«åããã\ref
ã\pageref
ã®å¤ãï¼ãã¼ã¯ã³åãªãå
é¨æ´æ°å¤ãªãã®å½¢ã§ï¼åå¾ããå¿
è¦ãããããããLaTeXã®ä»æ§ã§ã¯ããããå¤ãåå¾ããããã®æ段ãç¨æããã¦ããªãã®ã§ãçµå±ãä»æ§ã«å¾ãéãã¯å®è£
ã¯ä¸å¯è½ã«ãªã£ã¦ãã¾ãã
ã©ããã¦ã\myRefSum
ãå®è£
ãããã®ã§ããã°ãLaTeXã«ã¼ãã«ã®å
é¨å®è£
ã«ä¾åããã³ã¼ããæ¸ããã¨ãã強硬çã«é ¼ã4ãã¨ã«ãªããããã®å ´åã§ãç¾å®åé¡ã¨ãã¦ç¸äºåç
§å¨ãã®å
é¨å®è£
ã¯æ§ã
ãªè¦å 5ã§å¤åããããããããç¹å®ã®ä»æ§éãã«ç¢ºå®ã«åä½ããããããªã³ã¼ããå®è£
ããï¼ããã¦ç¶æããï¼ã®ã¯æ¥µãã¦å°é£ãªã®ã§ããã
æ°æ©è½ã§ãã©ãã«ã«ç´ã¥ãå¤ã®åå¾ããã§ãããããã®ã«
æ°ããææ¸ããããã£æ©è½ã§ã¯\RefProperty
ã¨ããå±éå¯è½ãªå½ä»¤ã§ããããã£ã®å¤ãåå¾ã§ããã
\RefProperty{â¹ã©ãã«âº}{â¹ããããã£âº}
ï¼ï¼»å±éå¯è½ï¼½â¹ã©ãã«âº
ã«ç´ã¥ãããããã£â¹ããããã£âº
ã®å¤ã
ããããã£ãå®ç¾©åã³è¨é²ããå½ä»¤6ã¯å¾æ¥ã®\label
ï¼\ref
ã¨ã¯å¥ã«åå¨ããã®ã§ããããä¸æ¹ã§ä»æ§æ¸ï¼ltproperties-doc.pdfï¼ã«ã¯æ¬¡ã®ãããªãã¨ãæ¸ããã¦ããã
- ã«ã¼ãã«ã§äºã
label
ã¨page
ã¨ããããããã£ãå®ç¾©ããã¦ããã label
ã¯å¾æ¥ã®ç¸äºåç §ã«ããã\ref
ã®å¤ï¼ã©ãã«ã«ç´ã¥ãã«ã¦ã³ã¿çªå·åºåï¼ã«ç¸å½ãããpage
ã¯å¾æ¥ã®ç¸äºåç §ã«ããã\pageref
ã®å¤ï¼ã©ãã«ã«ç´ã¥ããã¼ã¸çªå·åºåï¼ã«ç¸å½ããã- å¾æ¥ã®
\label
ã®ãã©ãã«ãã¯ãã®ã¾ã¾ææ¸ããããã£æ©è½ã«ããããã©ãã«ãã«ããªãã
ãããèªãéãã¯ãããã«ã次ã®ãããªä»çµã¿ã«ãªã£ã¦ãããã§ããã
\RefProperty{â¹ã©ãã«âº}{label}
ã«ãã\ref{â¹ã©ãã«âº}
ã®å¤ãåå¾ã§ããã\RefProperty{â¹ã©ãã«âº}{page}
ã«ãã\pageref{â¹ã©ãã«âº}
ã®å¤ãåå¾ã§ããã
æ¬å½ã«ãããªã£ã¦ããã®ã確ããã¦ã¿ããã
\documentclass[a4paper]{article} \begin{document} \setcounter{section}{41} \section{Duck}\label{sec:duck} Quack! \section{Conclusion} label=\RefProperty{sec:duck}{label}; page=\RefProperty{sec:duck}{page}. \end{document}
ãããããã¾ããããªãï¼ããããðï¼
å¤ã®é¨åã«ã¯ããããã£ã®ãæ¢å®å¤ããåºåããã¦ãããã©ããããã©ãã«ã«ç´ã¥ãããããã£ã®å¤ãè¨é²ããã¦ããªãããã§ãããã¤ã¾ããå°ãªãã¨ãç¾ç¶ã®ä»æ§ã«ããã¦ã¯ãå¾æ¥ã®\label
å½ä»¤ã§ã¯æ°æ©è½ã®ããããã£ã®å¤ã¯è¨é²ãããªãããã«ã¿ããã
ä½è«ï¼å¤ãåå¾ã§ããªããªãè¦åãã¹ãã§ã¯
å
ã®ææ¸ã®ãã«ãã®éã«ã¯è¦åã¯åºãªãã®ã§ããããåå¾ããããããã£å¤ãè¨é²ããã¦ããªããªãï¼å¾æ¥ã®ç¸äºåç
§ã«ããã¦æå®ãã\label
ãè¦ã¤ãããªãæã¨åæ§ã«ï¼è¦åãåºã¦ã»ããæ°ããããå®ã¯è¦åãåºãå½ä»¤ã¯å¥ã«ããã
\RefUndefinedWarn{â¹ã©ãã«âº}{â¹ããããã£âº}
ï¼â¹ã©ãã«âº
ã«ç´ã¥ãããããã£â¹ããããã£âº
ã®å¤ãè¨é²ããã¦ããªããã°è¦åãåºãã
ãªãåå¾ããå½ä»¤\RefProperty
ã§è¦åãåºããªãã®ãã¨ããã¨ãããããã¨å±éå¯è½ã§ãªããªã£ã¦ãã¾ãããã§ããã\RefProperty
ã使ãããã°ã©ããâé©åãªã¿ã¤ãã³ã°âã§é©å®\RefUndefinedWarn
ãå®è¡ããå¿
è¦ãããã
å ã®ææ¸ã½ã¼ã¹ã®7è¡ç®ã«æ¬¡ã®ã³ã¼ãã追è¨ããã
\RefUndefinedWarn{sec:duck}{label} \RefUndefinedWarn{sec:duck}{page}
ããã¨ææ¸ã®ãã«ãæã«è¦åãåºãããã«ãªãã
LaTeX Warning: Property `label' undefined for reference `sec:duck' on page 1 on input line 7. LaTeX Warning: Property `page' undefined for reference `sec:duck' on page 1 on input line 8.
ãã¯ãããããã£å¤ã¯è¨é²ããã¦ããªããã¨ãå¤æããã
ã©ãã«ããã¦ãã©ãã«ã«ç´ã¥ãå¤ã®åå¾ããã¦ã¿ã
å½ç¶ã§ããããã\label
ãå®è¡ããéã«æ°æ©è½ã®ããããã£ã®å¤ãåæã«è¨é²ããããã«ãããã¨\RefProperty
ã§å¤ãåå¾ã§ããããã«ãªããä¾ãã°ã以ä¸ã®ãããªå½ä»¤\myLabel
ãå®ç¾©ãã¦ããã\label
ã®ä»£ããã«ä½¿ãã¨ããæ¹æ³ãèããããã
â»å
è¿°ã®éãç¸äºåç
§ã¨ææ¸ããããã£ã®ãã©ãã«ãã¯å
±éï¼åå空éãå
±æããï¼ãªã®ã§ãåãååã®ã©ãã«ã両æ¹ã«ä½¿ããã¨ã¯ã§ããªãï¼ã©ãã«éè¤ã«ãªã£ã¦ãã¾ãï¼ããã®ãããããããã£ã®æ¹ã®ã©ãã«ã®ååã«ã¯æ¥é è¾ï¼my/
ï¼ãä»ãã¦ããã
%% \myLabel{<ã©ãã«>}: ç¸äºåç §ã¨ææ¸ããããã£ã®ä¸¡æ¹ã®ã©ãã«ãç½®ã. % â»ããããã£ã®æ¹ã®ã©ãã«ã«ã¯"my/"ã®æ¥é è¾ãä»ãã. \NewDocumentCommand\myLabel{m}{% \label{#1}% ç¸äºåç §ã®ã©ãã«é ç½® \RecordProperties{my/#1}{label,page}% ããããã£è¨é² }
ããã«ãã\RefProperty
ã§å¤ãå®éã«åå¾ã§ããããã«ãªãã®ã§ãä»åº¦ã¯å
è¿°ã®\myRefSum
ã®å®è£
ãå¯è½ã«ãªããå®éã«\RefProperty
ã§ã®å¤ã®åå¾ã¨\myRefSum
ã®å®è¡ãããå®å
¨ãªã³ã¼ãã以ä¸ã«ç¤ºããã
â»\inteval
ã¯æ´æ°å¼ã®è¨ç®ãããå½ä»¤ã
\documentclass[a4paper]{article} %% \myLabel{<ã©ãã«>}: ç¸äºåç §ã¨ææ¸ããããã£ã®ä¸¡æ¹ã®ã©ãã«ãç½®ã. % â»ããããã£ã®æ¹ã®ã©ãã«ã«ã¯"my/"ã®æ¥é è¾ãä»ãã. \NewDocumentCommand\myLabel{m}{% \label{#1}% ç¸äºåç §ã®ã©ãã«é ç½® \RecordProperties{my/#1}{label,page}% ããããã£è¨é² } %% \myRefSum{<ã©ãã«>}: ä¾ã®ã¢ã¬. \NewDocumentCommand\myRefSum{m}{% % å¤ãè¨é²ããã¦ãªããã°è¦å \RefUndefinedWarn{my/#1}{label}% \RefUndefinedWarn{my/#1}{page}% % 両æ¹ã®å¤ãè¨é²ããã¦ããã°åè¨å¤ãåºåãã \IfPropertyRecordedTF{my/#1}{label}{% \IfPropertyRecordedTF{my/#1}{page}{% % å±éå¯è½ãªã®ã§ \inteval ä¸ã§ä½¿ç¨å¯è½ \inteval{\RefProperty{my/#1}{label}% +\RefProperty{my/#1}{page}}% }{}%else }{}%else } \begin{document} \setcounter{section}{41} \section{Duck}\myLabel{sec:duck} Quack! \section{Conclusion} % çªå·ãåå¾ããä¾ label=\RefProperty{my/sec:duck}{label}; page=\RefProperty{my/sec:duck}{page}.\par % \myRefSum ã®ä¾ sum=\myRefSum{sec:duck}. \end{document}
ãªããããªä»æ§ãªã®ã
ä»æ§æ¸ï¼ltproperties-doc.pdfï¼ã«æ¬¡ã®ãããªè¨è¿°ãããã
Currently the code has nearly no impact on the main
\label
and\ref
commands as too many external packages rely on the concrete implementation. There is one exception: the label names share the same namespace. That means that if both\label{ABC}
and\RecordProperties{ABC}{page}
are used there is a warningLabel âABCâ multiply defined.
ï¼è¨³ï¼
ç¾ç¶ã§ã¯ã大æ¬ã®\label
ããã³\ref
å½ä»¤ã¯ãã®ï¼»æ°æ©è½å®è£ ã®ï¼½ã³ã¼ãã®å½±é¿ãã»ã¼åããªããå¤é¨ããã±ã¼ã¸ã§ãã®å ·ä½çãªå®è£ ã«ä¾åãããã®ããã¾ãã«å¤ãããã§ãããä¸ã¤ã ãä¾å¤ãããï¼ã©ãã«ã®ååã¯åå空éãå ±æãã¦ãããã¤ã¾ãã\label{ABC}
ã¨\RecordProperties{ABC}{page}
ã®ä¸¡æ¹ã使ãã¨ãLabel âABCâ multiply defined
ã®è¦åãçºçããã
å¾æ¥ã®ç¸äºåç §ã¨ææ¸ããããã£ããå ¨ãç¡é¢ä¿ãªå¥åã®ãã®ãã¨ä½ç½®ä»ãããªãã°ã両è ã§ã©ãã«ã®åå空éãå ±æããã®ã¯æããã«ä¸åçãªã¯ãã§ãããå ±æããã¦ããã¨ãããã¨ã¯ãæããLaTeXãã¼ã ã¯ã究極çã«ã¯ä¸¡è ãçµ±ä¸ããããã¨èãã¦ããããã«ãæãããä»ã¯æ¢åã®ããã±ã¼ã¸ã®åé¡ããã£ã¦å®ç¾ã§ãã¦ããªãããã§ããããå°æ¥çã«ã¯ä½ãæãæã¤ã®ãããããªãã
ã¾ã¨ã
ã¨ããããä»ã®ã¨ããã¯ãããããðï¼ããããðï¼
- ãææ¸ããããã£ãã¯LaTeXã®æ¦å¿µã§ãããPDFã®ãææ¸ã®ããããã£ãã¨ã¯ç¡é¢ä¿ã§ããã↩
- ç¸äºåç §ãå©ç¨ãã¦ããã®ã§ãææ¸ã®ãã«ãã®éã«ã¯2åã¿ã¤ãã»ãããå¿ è¦ã§ããã以éã®ä¾ã®ææ¸ã§ãåæ§ã↩
- 話ãç°¡åã«ãããããå½è©²ã®ã«ã¦ã³ã¿ï¼ã¨ãã¼ã¸ã«ã¦ã³ã¿ï¼ã®è¡¨ç¤ºæ¸å¼ã¯ç®ç¨æ°åã§ãããã¨ãä»®å®ãããã¤ã¾ããã«ã¦ã³ã¿çªå·ã®ãã¼ã¯ã³åã¯ã«ã¦ã³ã¿å¤ã®æ´æ°ã¨ãã¦éç¨ããã↩
-
主ã«ã
\ref
ã\pageref
ã®ãå®è£ ã«ããã¦å±éå¯è½ã¨ãã¦åä½ããå®è¡ãã¹ããå©ç¨ãããã¨ããæ¹æ³ã¨ãç¸äºåç §æ å ±ãä¿åãããã¯ãr@â¹ã©ãã«âº
ãç´æ¥æä½ãããã¨ãã2ã¤ã®æ¹æ³ãããã↩ - hyperrefçã®ããã±ã¼ã¸ã®èªè¾¼ã«ãã£ã¦å®è£ ãç½®ãæãããã¾ããæè¿ã®LaTeXã®æ¹ä¿®ã§ãç¸äºåç §å¨ãã®å®è£ ãå¤åãã¦ãã¦ãå¾æ¥ã®å®è£ ãåä½ããªãã¨ããä¸å ·åãçºçãã¦ããã↩
-
å®ç¾©ããå½ä»¤ã
\NewProperty
ã§ãè¨é²ããå½ä»¤ã\RecoedProperties
ã↩