diff --git a/c116041-redume.pdf b/c116041-redume.pdf index d83a023..04bb805 100644 --- a/c116041-redume.pdf +++ b/c116041-redume.pdf Binary files differ diff --git a/c116041-redume.tex b/c116041-redume.tex index 0f5e996..c2dea8f 100644 --- a/c116041-redume.tex +++ b/c116041-redume.tex @@ -9,6 +9,7 @@ \addtolength{\oddsidemargin}{-0.5cm} \addtolength{\evensidemargin}{0.5cm} \usepackage{ulem,color,graphicx,eclbkbox} +\usepackage{showkeys} \usepackage{multicol} \usepackage{listings} \usepackage{url} @@ -26,16 +27,16 @@ \end{flushleft} ] \section{目的} -従来のWebハザードマップは自然災害のリスクを予測でき,詳細な情報をインターネットで気軽に入手できるようになった。しかし,自然災害は回避,抑制することもできない。しかも季節変化が激しいため夏や冬の厳しい環境下で巨大地震が発生した場合,多くの人々が苦境に立たされる可能性がある。そこで季節変化によって避難場所を切り替えるハザードマップがあれば解決できると考えた。 +従来のWebハザードマップは自然災害のリスクを予測できるが,完全に予測して回避,抑制することはできない。しかも季節変化が激しいため夏や冬の厳しい環境下で巨大地震が発生した場合,多くの人々が苦境に立たされる可能性がある[1]。そこで季節変化によって避難場所を切り替えるハザードマップがあれば解決できると考えた。 \section{既存のハザードマップの問題点} ハザードマップは東日本大震災以降に大幅な見直しがなされたが,地質条件や地形に合わせた避難の仕方が未記載だったことが2016年に明らかとなった。また,行政や非営利団体による促進が上手く行かず,ハザードマップの認知度が極めて低いという問題点もある。 \begin{itemize} \item 予想が難しい \par 自然災害が相手であるため,規模や被害状況,どこで発生するかを明確に特定しにくく,対策が難しい。そのため,事前の情報を明記することができず,被害が大きくなる。 \item 見落としがある \par - これは2016年に発生した熊本地震での事例である。熊本地震では,西原村と益城町では震度7を記録した。しかし行政のハザードマップにはこの二つが震央の上にあることが明記されておらず,対策もできずに被害を被ってしまった。 + これは2016年に発生した熊本地震での事例である。熊本地震では,西原村と益城町では震度7を記録した。しかし行政のハザードマップにはこの二つが震央の上にあることが明記されておらず,対策もできずに被害を被ってしまった[2]。 \item 関心が薄い \par - ハザードマップは防災訓練や,実際に発生した場合以外は使用頻度が少ないので,主に若い年代層の認知度は低いと見られている。また,実際に地震が発生して無事だった場合,災害規模を自分勝手な判断で分析し,安心してしまう住民もいる。 + ハザードマップは防災訓練や,実際に発生した場合以外は使用頻度が少ないので,主に若い年代層の認知度は低いと見られている。また,実際に地震が発生して無事だった場合,災害規模を自分勝手な判断で分析し,安心してしまう住民もいる[3]。 \end{itemize} \section{先行のサービス} 本研究と同じくハザードマップの作成を行っている先行のサービスと本研究の比較を行う。 @@ -73,10 +74,10 @@ \item jQuery \par JavaScriptライブラリの一種で,Web上で動的な要素を加えるのに用いられる。企業のWebページ上で動的な効果が入っているページに多く使われている。本研究では,マーカーの切り替えに使用した。 \end{itemize} -\subsection{本システムの機能} +\section{本システムの機能の紹介} 本研究のシステムの機能について説明する。 \subsection{位置情報読み込み機能} -位置情報とは,携帯端末等で利用者が所在する現在地を取得した情報のことである。本研究のハザードマップには情報端末機器使用者の位置情報が分かる位置情報サービスが備わっており,図3.3では「現在地」と表示しているマーカーが現在地を表している(図1)。 +位置情報とは,携帯端末等で利用者が所在する現在地を取得した情報のことである。本研究のハザードマップにはGPSを通して位置情報を取得するサービスが備わっており,図3.3では「現在地」と表示しているマーカーが現在地を表している(図1)。 \begin{center} \begin{figure}[htp] \includegraphics[clip,scale=0.2]{gps.png} @@ -84,7 +85,7 @@ \end{figure} \end{center} \subsection{印刷機能} -計算機で扱う際に情報を簡単に印刷できるように,JavaScriptで書き込んで作成した印刷機能を実装した。スクレイピングでWebページの全体を印刷の範囲とすることで,ページ全体の印刷を可能にする。Webスクレイピングとは,Webページのデータを取得する行為である。 +計算機で扱う際に情報を簡単に印刷できるように,JavaScriptで書き込んで作成した印刷機能を実装した。 %\begin{center} % \begin{figure}[htp] % \includegraphics[clip,scale=0.5]{print4.png} @@ -95,12 +96,12 @@ 避難所や危険区域の位置がどこであるかを調べるために実装している。位置座標の表示にはlatlngクラスを用いている。latは緯度,lngは経度を表している(図2)。 \begin{center} \begin{figure}[htp] - \includegraphics[clip,scale=0.1]{capture.png} + \includegraphics[clip,scale=0.2]{capture.png} \caption{latlngを用いた座標を示す機能を用いた例。} \end{figure} \end{center} \subsection{津波到達予想範囲の可視化} -津波到達範囲を可視化にはポリゴンを用いる。可視化を行うにおいて,酒田市のハザードマップと国土交通省のハザードマップのデータを用いる。抽出されたデータはuMap\footnote[14]{WTFPLでライセンスを受けたレイヤー付きマップを埋め込むためのオープンソースソフトウェアのこと。WTFPLとは二次使用や改変,再頒布について無制限に使用してよいという許諾を得たオープンソースライセンスのことである。}を通してOpenStreetMapのデータに変換して表示している(図3)。 +津波到達範囲を可視化にはポリゴンを用いる。国土交通省から抽出されたデータはuMap\footnote[14]{二次使用や改変,再頒布について無制限に使用してよいという許諾を得たオープンソースライセンスを受けたレイヤー付きマップを埋め込むためのオープンソースソフトウェアのことである。}を通してOpenStreetMapのデータに変換して表示している(図3)。 \begin{center} \begin{figure}[htp] \includegraphics[clip,scale=0.2]{newmap2.png} @@ -148,10 +149,27 @@ \end{figure} \end{center} \section{結論} -\subsection{結論} +\subsection{本研究の結論} 本論では,巨大地震に対する庄内地域の現状とハザードマップの問題点を正確に受け止め,バリアフリーで,庄内の季節変化に合わせたサービスを提供するために,季節変化に対応したGPS読み取り機能付きWebハザードマップを作成した。本システムには,ハザードマップ特有のマーカー切り替えと位置情報読み取り機能を最大限に発揮して,スムーズで安全な避難を促す余地が十分にある。そのためには,まず,既存の紙媒体やWeb上のハザードマップの情報を鵜呑みにせず,しっかりとその地域に見合った環境,地形,歴史,地質を理解し,地震大国日本でどのように 生活していくのかを考えることが重要である。 本システムがハザードマップとしての利用価値を認められた際には,このような視点から取り組み,信頼性と安全性を向上させるために貢献する所存である。 \subsection{今後の展望} 本研究では範囲を酒田市のみと定めてハザードマップを作成したが,山形県全域を含めたハザードマップを作成していきたいと考えている。特に内陸では火災や土砂災害が二次災害として発生する傾向にあるのでこれらを考慮したマップを作成することを考えている。 +\section{本研究のURLとQRコード} +\begin{center} + \begin{figure}[htp] + \includegraphics[clip,scale=0.5]{qrcord.png} + \caption{図6:WebハザードマップのQRコード} + \end{figure} +\end{center} +\vspace{-10pt} +\url{https://koeki-soturon.github.io/hazard-map/map.html} + +\begin{thebibliography}{99} +\bibitem{1} 地震調査研究推進本部(2019)「山形県の地震活動の特徴」,地震本部, + \url{https://www.jishin.go.jp/regional-seismicity/rs-tohoku/p06-yamagata}(参照2019-11-01). +\bibitem{2} 鈴木 康弘(2018)「科学研究費助成事業 研究成果報告書」,名古屋大学,pp.3, \url{https://kaken.nii.ac.jp/ja/file/KAKENHI-PROJECT-15H02959/15H02959seika.pdf}(参照2019-12-31). +\bibitem{3} 阪本真由美(2015)「避難所の確保と質の向上に関する検討会 東日本大震災における避難所の状況」,名古屋大学減災連携研究センター, pp.1-16, + \url{ http://www.bousai.go.jp/kaigirep/kentokai/hinanzyokakuho/02/pdf/siryo2.pdf}. +\end{thebibliography} \end{document} diff --git a/refcheck.sty b/refcheck.sty new file mode 100755 index 0000000..c6f4fc2 --- /dev/null +++ b/refcheck.sty @@ -0,0 +1,294 @@ +% refcheck.sty +% checks lost and useless labels, shows `keys' of \label +% in the margins +% +% version 1.9.1 for LaTeX2e, 14 February 2013 +% (minor correction of ver. 1.9, issued on 31 March 2004) +% +% Copyright 1997--2004, 2013 by Oleg Motygin +% (mov222@gmail.com, mov@mail15.com) +% this program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License +% +% Usage is \usepackage{refcheck} with options showrefs, norefs, showcites, +% nocites, msgs, nomsgs, chkunlbld, ignoreunlbld +% +% Options showrefs and norefs, e.g. \usepackage[showrefs]{refcheck} +% sets on and off (`on' is default) writing label keys to output margins. +% '{?}' instead of a key means that the equation is not labelled. +% '?'s appear around a label name if the label is not used in references. +% +% Option showcites and nocites sets on and off (`on' is default) +% refcheck to show keys of bibitems in the margins. +% +% Options msgs (default) and nomsgs state whether refcheck writes +% its messages to .log file or not. +% The messages have the format +% Package refcheck Warning: Unused bibitem.. +% Package refcheck Warning: Unused label.. +% Package refcheck Warning: Unlabelled equation.. +% +% The check of unlabelled equations can be switched off by the option +% ignoreunlbld and on (default) by the option chkunlbld. +% +% refcheck generally works with AMS-LaTeX and HyperRef +% but amsmath and/or hyperref packages must be loaded before +% the refcheck package. +% +% refcheck can be used with the xr package. Suppose one invokes +% \usepackage{xr} \externaldocument[A:]{apps} in document foo1.tex and +% \usepackage{xr} \externaldocument[B:]{apps} in document foo2.tex. +% Then the commands \refcheckxrdoc[A:]{foo1} and \refcheckxrdoc[B:]{foo2} +% used in apps.tex allows to check usage of labels from apps.tex in the +% external files foo1.tex and foo2.tex. +% +% NOTE the problem with implicitly cited labels. +% For example, if there is a set of equations which are +% labelled by a1, a2,... an and referred in document by +% (\ref{a1})--(\ref{an}), then the labels a2, a3,...an-1 +% cannot be recognized as `used'. +% + +\def\filename{refcheck} +\def\fileversion{v1.9.1} +\def\filedate{2013/02/14} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{refcheck}[2013/02/14 v1.9.1] + +\let\mark@size=\footnotesize +\newif\if@labelled +\@labelledfalse +\newif\if@show@ref +\newif\if@show@cite +\newif\if@give@msgs +\newif\if@show@unl@bld + +\def\set@fbox@par{\fboxrule=0.01em\fboxsep=0.2em} +\def\unl@bld@mark{{\mark@size\textup{\{\textbf{?}\}}}} + +\DeclareOption{showrefs}{\@show@reftrue} +\DeclareOption{showcites}{\@show@citetrue} +\DeclareOption{msgs}{\@give@msgstrue} +\DeclareOption{chckunlbld}{\@show@unl@bldtrue} +\DeclareOption{norefs}{\@show@reffalse} +\DeclareOption{nocites}{\@show@citefalse} +\DeclareOption{nomsgs}{\@give@msgsfalse} +\DeclareOption{ignoreunlbld}{\@show@unl@bldfalse} +\ExecuteOptions{showrefs,showcites,msgs,chckunlbld} +\ProcessOptions\relax + +\def\showrefnames{\global\@show@reftrue} +\def\norefnames{\global\@show@reffalse} +\def\showcitenames{\global\@show@citetrue} +\def\nocitenames{\global\@show@citefalse} +\def\setonmsgs{\global\@give@msgstrue} +\def\setoffmsgs{\global\@give@msgsfalse} +\def\checkunlbld{\global\@show@unl@bldtrue} +\def\ignoreunlbld{\global\@show@unl@bldfalse} + +\def\@warning@rc@#1{\if@give@msgs\PackageWarning{refcheck}{#1}\else\relax\fi} + +\newif\if@unsdlbl + +\newtoks\btoks + +\AtBeginDocument{% +\typeout{Package: `refcheck' v1.9.1\space<2013/02/14>}% +\typeout{options: showrefs, showcites, msgs, chckunlbld}% +\immediate\write\@auxout{% + \string\providecommand\string{\string\usedref\string}[1]% + \string{\string\relax\string}}% +\let\@@ref@@=\ref +\let\@@pageref@@=\pageref +\let\@@bibitem@@=\bibitem +\let\@@@biblabel@@=\@biblabel +\let\@@label@@=\label +\renewcommand{\label}[1]{\@bsphack\global\@labelledtrue + \gdef\last@lbl{\@verbatim@{#1}}% + \@ifundefined{lab@#1}{\global\@unsdlbltrue + \@warning@rc@{Unused label `#1'}}% + {\global\@unsdlblfalse}% + \ifmmode\relax\else + {\setbox0=\vbox{\vss\@setnmmarginlbl}% + \wd0=0pt\ht0=0pt\dp0=0pt% + \ifvmode + \@tempdima=\prevdepth + \nointerlineskip\box0\nobreak + \prevdepth=\@tempdima + \else + \vadjust{\box0\nobreak}% + \fi}% + \fi + \@@label@@{#1}\@esphack}% +\expandafter\DeclareRobustCommand\expandafter + {\csname relax\string\ref\endcsname}[1]{\@@ref@@{#1}\wrtusdrf{#1}}% +\expandafter\let\expandafter\ref\csname relax\string\ref\endcsname +\expandafter\DeclareRobustCommand\expandafter + {\csname relax\string\pageref\endcsname}[1]{\@@pageref@@{#1}\wrtusdrf{#1}}% +\expandafter\let\expandafter\pageref\csname relax\string\pageref\endcsname +% +\def\@bibitem@proceed@#1{% +\@ifundefined{cit@#1}{\@warning@rc@{Unused bibitem `#1'}% + \if@show@cite + \gdef\@biblabel{\makebox[0pt][r]{\zero@height{{\mark@size{\bfseries\upshape?}}% + \underline{\@verbatim@{#1}}{\mark@size{\bfseries\upshape?}}$\,$}}% + \@@@biblabel@@}% + \fi + }{% + \if@show@cite + \set@fbox@par + \gdef\@biblabel{\makebox[0pt][r]{\zero@height{\fbox{\@verbatim@{#1}}$\,$}}\@@@biblabel@@}% + \fi + }}% +\def\bibitem{\@ifnextchar[\@lbibitem@rc@\@bibitem@rc@}% +\def\@lbibitem@rc@[#1]#2{% +\@bibitem@proceed@{#2}\@@bibitem@@[#1]{#2}}% +\def\@bibitem@rc@#1{% +\@bibitem@proceed@{#1}\@@bibitem@@{#1}}% +% +\@ifpackageloaded{amsmath}{% With AMS-LaTeX tags +\let\@@label@@in@@=\label@in@display +\def\label@in@display#1{\@bsphack\global\@labelledtrue + \gdef\last@lbl{\@verbatim@{#1}}% + \@ifundefined{lab@#1}{% + \global\@unsdlbltrue + \@warning@rc@{Unused label `#1'}}% + {\global\@unsdlblfalse}% + \@@label@@in@@{#1}\@esphack +}% +\let\@@eqref@@=\eqref +\let\@tagform@@@@=\tagform@ +\expandafter\DeclareRobustCommand\expandafter + {\csname relax\string\eqref\endcsname}[1]% + {{\let\tagform@=\@tagform@@@@\@@eqref@@{#1}}}% +\expandafter\let\expandafter\eqref\csname relax\string\eqref\endcsname +\def\tagform@#1{\@tagform@@@@{#1}% + \ifmeasuring@\relax\else\if@display + \if@labelled\relax\else\if@show@unl@bld + \@warning@rc@{Unlabelled equation (\theequation)}% + \fi\fi + \@setmarginlbl + \fi\fi +}% +}{\let\@@eqnnum@@=\@eqnnum +\def\@eqnnum{% + \if@labelled\relax\else\if@show@unl@bld + \@warning@rc@{Unlabelled equation (\theequation)}% + \fi\fi + \@@eqnnum@@ + \@setmarginlbl +}% +}}% + +\def\@setmarginlbl{% + \if@show@ref + \if@labelled + \set@fbox@par + \if@unsdlbl + \makebox[0pt][l]{\zero@height{$\,${\mark@size + {\bfseries\upshape?}\underline{\last@lbl}{\bfseries\upshape?}}}}% + \else + \makebox[0pt][l]{\zero@height{$\,$\fbox{{\mark@size\last@lbl}}}}% + \fi + \else + \if@show@unl@bld + \makebox[0pt][l]{\zero@height{$\,$\unl@bld@mark}}% + \fi\fi + \fi + \global\@labelledfalse +} + +\def\@setnmmarginlbl{% + \if@show@ref + \set@fbox@par + \if@unsdlbl + \hbox to \textwidth{\makebox[0pt][r]{{\mark@size{\bfseries + \upshape?}$\langle$\last@lbl$\rangle${\bfseries + \upshape?}}$\,$}\hfill}% + \else + \hbox to \textwidth{\makebox[0pt][r]{{\mark@size$\langle$% + \last@lbl$\rangle$}$\,$}\hfill}% + \fi + \fi + \global\@labelledfalse +} + +\def\zero@height#1{\setbox0=\hbox{#1}\dp0=0pt\ht0=0pt\copy0} + +\long\def\@verbatim@#1{\edef\next{#1}% + {\mark@size\ttfamily\upshape\frenchspacing\expandafter\@strip@\meaning\next}} +\def\@strip@#1>{} + +\def\usedref#1{\@ifundefined{lab@#1}{\global\@namedef{lab@#1}{}}{}} + +\let\@@citation@@=\citation + +\renewcommand{\citation}[1]{\@@citation@@{#1}% +\@for\@tempa:=#1\do{\@ifundefined{cit@\@tempa}% + {\global\@namedef{cit@\@tempa}{}}{}}% +} + +\DeclareRobustCommand{\wrtusdrf}[1]{% + \@ifundefined{la@#1}{\global\@namedef{la@#1}{}% + \used@write{#1}{\usedref}}{\null}} + +\def\used@write#1#2{% \protected@write, but \immediate + \@bsphack + \begingroup + \let\thepage\relax + \let\protect\@unexpandable@protect + \edef\reserved@a{\immediate\write\@auxout{\string#2{#1}}}% + \reserved@a + \endgroup + \if@nobreak\ifvmode\nobreak\fi\fi + \@esphack +} + +\def\refcheckxrdoc{\@ifnextchar[\rchXD@{\rchXD@[]}} +\def\rchXD@[#1]#2{{% + \makeatletter + \xdef\rchXD@prefix{#1}% + \rchXD@next#2.aux\relax\\}} +\def\rchXD@next#1\relax#2\\{% + \edef\rchXD@list{#2}% + \rchXD@loop{#1}} +\def\rchXD@aux{% + \ifx\rchXD@list\@empty\else\expandafter\rchXD@explist\fi} + +\def\rchXD@explist{\expandafter\rchXD@next\rchXD@list\\} +\def\rchXD@loop#1{\openin\@inputcheck#1\relax + \ifeof\@inputcheck + \PackageWarning{refcheck}{^^JNo file #1^^JLABELS USAGE NOT IMPORTED.^^J}% + \expandafter\rchXD@aux + \else + \PackageInfo{refcheck}{IMPORTING LABELS USAGE FROM #1}% + \expandafter\rchXD@read + \fi +} +\def\rchXD@read{% + \read\@inputcheck to\rchXD@line + \expandafter\rchXD@test\rchXD@line..\rchXD@} +\def\cleanprefix#1#2{% + \if#1\@empty \usedref{#2}\else + \def\@test##1#1##2\@nil{\edef\@tempa{##1}\edef\@tempb{##2}}% + \@test#2#1\@nil + \ifx\@tempb\@empty \relax\else \ifx\@tempa\@empty + \def\@tempb#1##1\@nil{\edef\@tempa{##1}}\@tempb#2\@nil + \ifx\@tempa\@empty \relax\else\usedref{\@tempa}\fi + \fi\fi + \fi +} +\long\def\rchXD@test#1#2#3\rchXD@{% + \ifx#1\usedref + \edef\exp@nddef{\noexpand\cleanprefix{\rchXD@prefix}{#2}}% + \exp@nddef + \else\ifx#1\@input + \edef\rchXD@list{\rchXD@list#2\relax}% + \fi\fi + \ifeof\@inputcheck\expandafter\rchXD@aux + \else\expandafter\rchXD@read\fi +} + +\endinput +%% +%% End of file `refcheck.sty'. diff --git a/refcheck/README b/refcheck/README new file mode 100644 index 0000000..94ad7f1 --- /dev/null +++ b/refcheck/README @@ -0,0 +1,8 @@ +RefCheck.sty is intended to check references. It looks for +numbered but unlabelled equations, for labels, which are not +used in the text, for unused bibliography references. Besides, +it displays label and bibitem `keys' in text margins. + +RefDemo.tex is a short description of usage of RefCheck.sty. + +Oleg Motygin, mov222@gmail.com diff --git a/refcheck/refcheck.sty b/refcheck/refcheck.sty new file mode 100755 index 0000000..c6f4fc2 --- /dev/null +++ b/refcheck/refcheck.sty @@ -0,0 +1,294 @@ +% refcheck.sty +% checks lost and useless labels, shows `keys' of \label +% in the margins +% +% version 1.9.1 for LaTeX2e, 14 February 2013 +% (minor correction of ver. 1.9, issued on 31 March 2004) +% +% Copyright 1997--2004, 2013 by Oleg Motygin +% (mov222@gmail.com, mov@mail15.com) +% this program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License +% +% Usage is \usepackage{refcheck} with options showrefs, norefs, showcites, +% nocites, msgs, nomsgs, chkunlbld, ignoreunlbld +% +% Options showrefs and norefs, e.g. \usepackage[showrefs]{refcheck} +% sets on and off (`on' is default) writing label keys to output margins. +% '{?}' instead of a key means that the equation is not labelled. +% '?'s appear around a label name if the label is not used in references. +% +% Option showcites and nocites sets on and off (`on' is default) +% refcheck to show keys of bibitems in the margins. +% +% Options msgs (default) and nomsgs state whether refcheck writes +% its messages to .log file or not. +% The messages have the format +% Package refcheck Warning: Unused bibitem.. +% Package refcheck Warning: Unused label.. +% Package refcheck Warning: Unlabelled equation.. +% +% The check of unlabelled equations can be switched off by the option +% ignoreunlbld and on (default) by the option chkunlbld. +% +% refcheck generally works with AMS-LaTeX and HyperRef +% but amsmath and/or hyperref packages must be loaded before +% the refcheck package. +% +% refcheck can be used with the xr package. Suppose one invokes +% \usepackage{xr} \externaldocument[A:]{apps} in document foo1.tex and +% \usepackage{xr} \externaldocument[B:]{apps} in document foo2.tex. +% Then the commands \refcheckxrdoc[A:]{foo1} and \refcheckxrdoc[B:]{foo2} +% used in apps.tex allows to check usage of labels from apps.tex in the +% external files foo1.tex and foo2.tex. +% +% NOTE the problem with implicitly cited labels. +% For example, if there is a set of equations which are +% labelled by a1, a2,... an and referred in document by +% (\ref{a1})--(\ref{an}), then the labels a2, a3,...an-1 +% cannot be recognized as `used'. +% + +\def\filename{refcheck} +\def\fileversion{v1.9.1} +\def\filedate{2013/02/14} +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{refcheck}[2013/02/14 v1.9.1] + +\let\mark@size=\footnotesize +\newif\if@labelled +\@labelledfalse +\newif\if@show@ref +\newif\if@show@cite +\newif\if@give@msgs +\newif\if@show@unl@bld + +\def\set@fbox@par{\fboxrule=0.01em\fboxsep=0.2em} +\def\unl@bld@mark{{\mark@size\textup{\{\textbf{?}\}}}} + +\DeclareOption{showrefs}{\@show@reftrue} +\DeclareOption{showcites}{\@show@citetrue} +\DeclareOption{msgs}{\@give@msgstrue} +\DeclareOption{chckunlbld}{\@show@unl@bldtrue} +\DeclareOption{norefs}{\@show@reffalse} +\DeclareOption{nocites}{\@show@citefalse} +\DeclareOption{nomsgs}{\@give@msgsfalse} +\DeclareOption{ignoreunlbld}{\@show@unl@bldfalse} +\ExecuteOptions{showrefs,showcites,msgs,chckunlbld} +\ProcessOptions\relax + +\def\showrefnames{\global\@show@reftrue} +\def\norefnames{\global\@show@reffalse} +\def\showcitenames{\global\@show@citetrue} +\def\nocitenames{\global\@show@citefalse} +\def\setonmsgs{\global\@give@msgstrue} +\def\setoffmsgs{\global\@give@msgsfalse} +\def\checkunlbld{\global\@show@unl@bldtrue} +\def\ignoreunlbld{\global\@show@unl@bldfalse} + +\def\@warning@rc@#1{\if@give@msgs\PackageWarning{refcheck}{#1}\else\relax\fi} + +\newif\if@unsdlbl + +\newtoks\btoks + +\AtBeginDocument{% +\typeout{Package: `refcheck' v1.9.1\space<2013/02/14>}% +\typeout{options: showrefs, showcites, msgs, chckunlbld}% +\immediate\write\@auxout{% + \string\providecommand\string{\string\usedref\string}[1]% + \string{\string\relax\string}}% +\let\@@ref@@=\ref +\let\@@pageref@@=\pageref +\let\@@bibitem@@=\bibitem +\let\@@@biblabel@@=\@biblabel +\let\@@label@@=\label +\renewcommand{\label}[1]{\@bsphack\global\@labelledtrue + \gdef\last@lbl{\@verbatim@{#1}}% + \@ifundefined{lab@#1}{\global\@unsdlbltrue + \@warning@rc@{Unused label `#1'}}% + {\global\@unsdlblfalse}% + \ifmmode\relax\else + {\setbox0=\vbox{\vss\@setnmmarginlbl}% + \wd0=0pt\ht0=0pt\dp0=0pt% + \ifvmode + \@tempdima=\prevdepth + \nointerlineskip\box0\nobreak + \prevdepth=\@tempdima + \else + \vadjust{\box0\nobreak}% + \fi}% + \fi + \@@label@@{#1}\@esphack}% +\expandafter\DeclareRobustCommand\expandafter + {\csname relax\string\ref\endcsname}[1]{\@@ref@@{#1}\wrtusdrf{#1}}% +\expandafter\let\expandafter\ref\csname relax\string\ref\endcsname +\expandafter\DeclareRobustCommand\expandafter + {\csname relax\string\pageref\endcsname}[1]{\@@pageref@@{#1}\wrtusdrf{#1}}% +\expandafter\let\expandafter\pageref\csname relax\string\pageref\endcsname +% +\def\@bibitem@proceed@#1{% +\@ifundefined{cit@#1}{\@warning@rc@{Unused bibitem `#1'}% + \if@show@cite + \gdef\@biblabel{\makebox[0pt][r]{\zero@height{{\mark@size{\bfseries\upshape?}}% + \underline{\@verbatim@{#1}}{\mark@size{\bfseries\upshape?}}$\,$}}% + \@@@biblabel@@}% + \fi + }{% + \if@show@cite + \set@fbox@par + \gdef\@biblabel{\makebox[0pt][r]{\zero@height{\fbox{\@verbatim@{#1}}$\,$}}\@@@biblabel@@}% + \fi + }}% +\def\bibitem{\@ifnextchar[\@lbibitem@rc@\@bibitem@rc@}% +\def\@lbibitem@rc@[#1]#2{% +\@bibitem@proceed@{#2}\@@bibitem@@[#1]{#2}}% +\def\@bibitem@rc@#1{% +\@bibitem@proceed@{#1}\@@bibitem@@{#1}}% +% +\@ifpackageloaded{amsmath}{% With AMS-LaTeX tags +\let\@@label@@in@@=\label@in@display +\def\label@in@display#1{\@bsphack\global\@labelledtrue + \gdef\last@lbl{\@verbatim@{#1}}% + \@ifundefined{lab@#1}{% + \global\@unsdlbltrue + \@warning@rc@{Unused label `#1'}}% + {\global\@unsdlblfalse}% + \@@label@@in@@{#1}\@esphack +}% +\let\@@eqref@@=\eqref +\let\@tagform@@@@=\tagform@ +\expandafter\DeclareRobustCommand\expandafter + {\csname relax\string\eqref\endcsname}[1]% + {{\let\tagform@=\@tagform@@@@\@@eqref@@{#1}}}% +\expandafter\let\expandafter\eqref\csname relax\string\eqref\endcsname +\def\tagform@#1{\@tagform@@@@{#1}% + \ifmeasuring@\relax\else\if@display + \if@labelled\relax\else\if@show@unl@bld + \@warning@rc@{Unlabelled equation (\theequation)}% + \fi\fi + \@setmarginlbl + \fi\fi +}% +}{\let\@@eqnnum@@=\@eqnnum +\def\@eqnnum{% + \if@labelled\relax\else\if@show@unl@bld + \@warning@rc@{Unlabelled equation (\theequation)}% + \fi\fi + \@@eqnnum@@ + \@setmarginlbl +}% +}}% + +\def\@setmarginlbl{% + \if@show@ref + \if@labelled + \set@fbox@par + \if@unsdlbl + \makebox[0pt][l]{\zero@height{$\,${\mark@size + {\bfseries\upshape?}\underline{\last@lbl}{\bfseries\upshape?}}}}% + \else + \makebox[0pt][l]{\zero@height{$\,$\fbox{{\mark@size\last@lbl}}}}% + \fi + \else + \if@show@unl@bld + \makebox[0pt][l]{\zero@height{$\,$\unl@bld@mark}}% + \fi\fi + \fi + \global\@labelledfalse +} + +\def\@setnmmarginlbl{% + \if@show@ref + \set@fbox@par + \if@unsdlbl + \hbox to \textwidth{\makebox[0pt][r]{{\mark@size{\bfseries + \upshape?}$\langle$\last@lbl$\rangle${\bfseries + \upshape?}}$\,$}\hfill}% + \else + \hbox to \textwidth{\makebox[0pt][r]{{\mark@size$\langle$% + \last@lbl$\rangle$}$\,$}\hfill}% + \fi + \fi + \global\@labelledfalse +} + +\def\zero@height#1{\setbox0=\hbox{#1}\dp0=0pt\ht0=0pt\copy0} + +\long\def\@verbatim@#1{\edef\next{#1}% + {\mark@size\ttfamily\upshape\frenchspacing\expandafter\@strip@\meaning\next}} +\def\@strip@#1>{} + +\def\usedref#1{\@ifundefined{lab@#1}{\global\@namedef{lab@#1}{}}{}} + +\let\@@citation@@=\citation + +\renewcommand{\citation}[1]{\@@citation@@{#1}% +\@for\@tempa:=#1\do{\@ifundefined{cit@\@tempa}% + {\global\@namedef{cit@\@tempa}{}}{}}% +} + +\DeclareRobustCommand{\wrtusdrf}[1]{% + \@ifundefined{la@#1}{\global\@namedef{la@#1}{}% + \used@write{#1}{\usedref}}{\null}} + +\def\used@write#1#2{% \protected@write, but \immediate + \@bsphack + \begingroup + \let\thepage\relax + \let\protect\@unexpandable@protect + \edef\reserved@a{\immediate\write\@auxout{\string#2{#1}}}% + \reserved@a + \endgroup + \if@nobreak\ifvmode\nobreak\fi\fi + \@esphack +} + +\def\refcheckxrdoc{\@ifnextchar[\rchXD@{\rchXD@[]}} +\def\rchXD@[#1]#2{{% + \makeatletter + \xdef\rchXD@prefix{#1}% + \rchXD@next#2.aux\relax\\}} +\def\rchXD@next#1\relax#2\\{% + \edef\rchXD@list{#2}% + \rchXD@loop{#1}} +\def\rchXD@aux{% + \ifx\rchXD@list\@empty\else\expandafter\rchXD@explist\fi} + +\def\rchXD@explist{\expandafter\rchXD@next\rchXD@list\\} +\def\rchXD@loop#1{\openin\@inputcheck#1\relax + \ifeof\@inputcheck + \PackageWarning{refcheck}{^^JNo file #1^^JLABELS USAGE NOT IMPORTED.^^J}% + \expandafter\rchXD@aux + \else + \PackageInfo{refcheck}{IMPORTING LABELS USAGE FROM #1}% + \expandafter\rchXD@read + \fi +} +\def\rchXD@read{% + \read\@inputcheck to\rchXD@line + \expandafter\rchXD@test\rchXD@line..\rchXD@} +\def\cleanprefix#1#2{% + \if#1\@empty \usedref{#2}\else + \def\@test##1#1##2\@nil{\edef\@tempa{##1}\edef\@tempb{##2}}% + \@test#2#1\@nil + \ifx\@tempb\@empty \relax\else \ifx\@tempa\@empty + \def\@tempb#1##1\@nil{\edef\@tempa{##1}}\@tempb#2\@nil + \ifx\@tempa\@empty \relax\else\usedref{\@tempa}\fi + \fi\fi + \fi +} +\long\def\rchXD@test#1#2#3\rchXD@{% + \ifx#1\usedref + \edef\exp@nddef{\noexpand\cleanprefix{\rchXD@prefix}{#2}}% + \exp@nddef + \else\ifx#1\@input + \edef\rchXD@list{\rchXD@list#2\relax}% + \fi\fi + \ifeof\@inputcheck\expandafter\rchXD@aux + \else\expandafter\rchXD@read\fi +} + +\endinput +%% +%% End of file `refcheck.sty'. diff --git a/refcheck/refdemo.pdf b/refcheck/refdemo.pdf new file mode 100644 index 0000000..2640d86 --- /dev/null +++ b/refcheck/refdemo.pdf Binary files differ diff --git a/refcheck/refdemo.tex b/refcheck/refdemo.tex new file mode 100644 index 0000000..a40d2c9 --- /dev/null +++ b/refcheck/refdemo.tex @@ -0,0 +1,237 @@ +\documentclass[11pt]{article} +\usepackage{refcheck} +\textwidth=360pt +\begin{document} +\baselineskip=4.5mm +\textheight=40\baselineskip +\pagestyle{myheadings} + +\parindent=1em\parskip=0.75ex +\makeatletter + +\thispagestyle{empty} + +\enlargethispage{-8mm} + +\def\RefCheck{\textsl{Refcheck\/}} +\def\AmS{\mbox{$\mathcal{A}$\kern-0.17em\raise-2.1pt\hbox{$\mathcal{M}$}% +\kern-0.115em$\mathcal{S}$}} +\renewcommand{\refname}{{\normalsize References}} +\def\curversion{1.9.1} +\def\curvertime{2013/02/14} + +\section*{\RefCheck{\tiny${}^{\mathrm{\ \ ver. +\curversion}}_{\mathrm{\curvertime}}$} for \LaTeXe} +\markboth{\hfill\bfseries\RefCheck\ for \LaTeXe\hfill}% +{\hfill\bfseries\RefCheck\ for \LaTeXe\hfill} +This short demo file describes usage of \RefCheck\ package +with \LaTeXe. The package looks for useless labels, +unlabelled equations, unused bibliography references +and puts `keys' of labels on margins. + +To start checking, one should just write +\begin{verbatim} + \documentclass{article} + \usepackage{refcheck} +\end{verbatim} +at the beginning of document and compile the file twice. +Then, comments on references could be found in \texttt{.log} file and +in the margins. + +Consider the set of equations +\begin{eqnarray} +&&a=b\label{eq.1}\\ +&&b=c\label{eq.2}\\ +&&c=d, +\end{eqnarray} +written as +\begin{verbatim} + \begin{eqnarray} + &&a=b\label{eq.1}\\ + &&b=c\label{eq.2}\\ + &&c=d, + \end{eqnarray} +\end{verbatim} +Then the \texttt{.log} file will contains the following messages: +{\small +\begin{verbatim} + Package refcheck Warning: Unused label `eq.2' on input line 44. + Package refcheck Warning: Unlabelled equation (3) on input line 46. +\end{verbatim} +} +\noindent +because the equation (\ref{eq.1}) is +referenced here by \verb#(\ref{eq.1})#, the label {\tt eq.2} of the second +equation is not used and the last equation is numbered but it is not +labelled. + +Keys of labels are written in the marginal notes when the option +\textit{showrefs\/} (default) or the command \verb#\showrefnames# are +invoked. This regime can be set off by the option \textit{norefs} or (at +any point of text) by the command \verb#\norefnames#. + +These marks include some information on labels. Namely, useless +labels are underlined and bounded by `\texttt{?}', the mark `\unl@bld@mark' +means that the equation is unlabelled. Marks are framed for +the labels which are used in text. + +\newpage + +The package is working in the same way with bibliography. +Consider the following short list of books: + +\vspace{-1\baselineskip} + +\begin{thebibliography}{9} + \bibitem{book1}A book. + \bibitem{book2}Another book. + \bibitem{book3}Third book. +\end{thebibliography} +defined as follows +\begin{verbatim} + \begin{thebibliography}{9} + \bibitem{book1}A book. + \bibitem{book2}Another book. + \bibitem{book3}Third book. + \end{thebibliography} +\end{verbatim} +Further, we use the labels of \cite{book1,book2} with the +command \verb#\cite{book1,book2}# and do not use the label +`book3'. Then, the \texttt{.log} file will contain the following message +{\small +\begin{verbatim} + Package refcheck Warning: Unused bibitem `book3' on input line 88. +\end{verbatim}} + +Commands \verb#\showcitenames# and \verb#\nocitenames# for +bibliography are analogous to the commands \verb#\showrefnames# and +\verb#\norefnames#. They set on and off \RefCheck\ to write keys of +bibitems to output. The same function is for the options +\textit{showcites\/} (default) and \textit{nocites}. + +Options \textit{msgs\/} (default) and \textit{nomsgs\/} state whether +\RefCheck\ writes its messages to \texttt{.log} file or not. + +The check of unlabelled equations can be switched off by the option +\mbox{\textit{ignoreunlbld\/}} and on (default) by the option +\textit{chkunlbld\/}. + +\medskip + +\RefCheck\ generally works with \AmS-\LaTeX\ and \textbf{hyperref}, +but the packages must be loaded \underline{before} the \RefCheck\ package. + +\medskip + +\RefCheck\ can be used with the \textbf{xr} package. Suppose one invokes\\ +\verb#\usepackage{xr}# \verb#\externaldocument[A:]{apps}#\\ in document foo1.tex and\\ +\verb#\usepackage{xr}# \verb#\externaldocument[B:]{apps}#\\ in document foo2.tex. +Then the commands \verb#\refcheckxrdoc[A:]{foo1}# and \verb#\refcheckxrdoc[B:]{foo2}# +used in apps.tex allows to check usage of labels from apps.tex in the +external files foo1.tex and foo2.tex. + +\medskip + +Note the problem with implicitly cited labels. For +example, if there is a set of equations which are labelled with +$\,$\texttt{a1,a2,...an}$\,$ and referred in document by +\verb#(\ref{a1})--(\ref{an})#, then the labels +$\,$\texttt{a2,a3,...an-1}$\,$ cannot be recognized as `used'. + +\medskip +\bigskip + +\textbf{Summary of options and commands:} +\medskip + +\noindent +\verb#\refcheckxrdoc[prefix]{foo}# to check usage of labels +of the current document in the file foo.tex where they are used +via \verb#\usepackage{xr}# and +\verb#\externaldocument[prefix]{thisdocument}# + +\medskip + +\begin{raggedright} +\begin{tabular}{|l|l|c|l|} +\hline +Option & Command & Switch & Function\\ +\hline +showrefs$^{*}$ & \verb#\showrefnames# & on & to put keys of labels\\ +\cline{1-3} +norefs & \verb#\norefnames# & off & in the marginal notes\\ +\hline +showcites$^{*}$ & \verb#\showcitenames# & on & to put bibitem keys\\ +\cline{1-3} +nocites & \verb#\nocitenames# & off & in the marginal notes\\ +\hline +msgs$^{*}$ & \verb#\setonmsgs# & on & to write \RefCheck's\\ +\cline{1-3} +nomsgs & \verb#\setoffmsgs# & off & messages to \texttt{.log}\\ +\hline +chkunlbld$^{*}$ & \verb#\checkunlbld# & on & to check unlabelled\\ +\cline{1-3} +ignoreunlbld & \verb#\ignoreunlbld# & off & equations\\ +\hline +\end{tabular} +\end{raggedright} +\par\noindent +\mbox{\qquad}$*$ default + +\bigskip + +\def\item{\noindent\mbox{\kern0.5em$\bullet$\kern0.5em}} + +\textbf{Versions of \RefCheck, acknowledgments and bugs:} + +\item +Versions \textbf{1.0--1.3} worked with \LaTeX2.09. Many +thanks to Antonio Loria for his useful comments on those versions. +Version \textbf{1.2} of \RefCheck\ can be found in +\texttt{/tex-archive/obsolete/macros/latex209/contrib/} in CTAN. + +\item +\textbf{1.4} was the first version of \RefCheck\ for \LaTeXe, it had a +few bugs in its functionality for \AmS-\LaTeXe's \verb#\eqref#, +\verb#\tag#, \verb#split# and \verb#multline#. Many thanks to +Cornelius C. Noack and Mikhail Zotov for finding the problem. + +\item +In the version~\textbf{1.5} the bugs were removed, but it was found +(thanks to Mikhail Zotov) that the version marks \AmS-\LaTeXe's +\verb#equation*# and \verb#gather*# as unlabelled. The versions +\textbf{1.6} solved the problem. + +\item The version \textbf{1.7} (optimized code of \textbf{1.6}) was +found by Adriano Pascoletti to work incorrectly in \verb#\caption# (more +generally, when \verb#\ref#, \verb#\pageref# occur in a material +processed to \verb#\write#, in particular, to be put into \texttt{.toc}, +\texttt{.lot}, \texttt{.lof} files). + +\item The version \textbf{1.8} was intended to solve the +problem. Besides, some more work was done to provide compability with +\AmS-\LaTeX\ and \textbf{hyperref}. + +\item The version \textbf{1.9} added possibility to check usage of labels in external +files. More compability with \textbf{cite} package was achieved. + +\item The current minor version \textbf{\curversion} is intended to fix the bug discussed +at \\ +{\small\texttt{http://tex.stackexchange.com/questions/88046/problem-with-refcheck}}.\\ +Besides, the format of refcheck warnings is changed. + +\bigskip + +\textbf{New options and commands:} + +\item +Version \textbf{1.5}: \textit{msgs\/} and \textit{nomsgs\/}. + +\item +Version \textbf{1.6}: \textit{ignoreunlbld\/} and +\textit{chkunlbld\/} (suggested by Miroslav Fikar). + +\item +Version \textbf{1.9}: \verb#\refcheckxrdoc#. + +\end{document}