diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-19 22:01:02 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-19 22:01:02 +0000 |
commit | ab1488b94de7c1645a36c1580b831debcad6a4f3 (patch) | |
tree | 0dd5ec70cc2fbecc24449a2a1c8acd267b21ccad /Master/texmf-dist/doc/latex | |
parent | aa1af9bcadad151bf660cb115eb938b0853a5f8e (diff) |
shortmathj (19mar20)
git-svn-id: svn://tug.org/texlive/trunk@54407 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex')
-rw-r--r-- | Master/texmf-dist/doc/latex/shortmathj/README.md | 69 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/shortmathj/biblatex-shortmathj-examples.bib | 41 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/shortmathj/index.js | 93 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/shortmathj/package.json | 26 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/shortmathj/shortmathj-biblatex-mwe.pdf | bin | 0 -> 116136 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/shortmathj/shortmathj-biblatex-mwe.tex | 28 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/shortmathj/shortmathj.template.sty | 27 |
7 files changed, 284 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/shortmathj/README.md b/Master/texmf-dist/doc/latex/shortmathj/README.md new file mode 100644 index 00000000000..8f102fc6559 --- /dev/null +++ b/Master/texmf-dist/doc/latex/shortmathj/README.md @@ -0,0 +1,69 @@ +# latex-shortmathj + +Automatically shortify titles of mathematical journals + +This small dummy package just contains a simple list of full and short journal names +([AMS standard](https://mathscinet.ams.org/msnhtml/serials.pdf)). + +## Usage +```latex +% In the preamble +\usepackage{shortmathj} + +% In the document +\shortifyAMSjournalname{Discrete \& Computational Geometry} +% Result: Discrete Comp. Geom. +``` + +### In case of any problems +Please, don't hesitate to open an [issue at GitLab](https://gitlab.com/Nickkolok/latex-shortmathj/-/issues/new) +or to mail me: nickkolok@mail.ru + +### Tweaking BibLaTex + +BibLaTeX is a great tool that does many things for you. +To ask BibLaTeX to abbreviate the journal names, do smth like +```latex +\DeclareFieldFormat[article]{titlecase}{\shortifyAMSjournalname{#1}} +``` +**Note that `shortmathj` itself does not require BibLaTeX to be used, unlike other abbreviating packages.** +`shortmathj` follows the UNIX-way: it just takes a full title and returns the shortified one. + +Tip: for more sophsticated ways, see [plk@github/biblatex/#974](https://github.com/plk/biblatex/issues/974). + +### Custom abbreviations + +Edit `custom.csv` and rebuild the package. +See also [#2](https://gitlab.com/Nickkolok/latex-shortmathj/-/issues/2). + +### Be careful! + +`shortmathj.template.sty` from this repo is NOT what you want. +You should obtain `shortmathj.sty` somehow: build it youtself or download from CTAN (see below). + +## Building + +The build process requires NodeJS and NPM. + +First of all, you may want to update the basic CSV file from +https://mathscinet.ams.org/msnhtml/annser.csv + +Make sure that no journals have been excluded (otherwise add them to `custom.csv`). +`git` is a good tool for investigating that. + +Then, run `npm install` to install all the dependencies. +Run `node index.js` to build `shortmathj.sty`. + +## Repostories + ++ [CTAN](https://ctan.org/pkg/shortmathj) + ++ [GitLab](https://gitlab.com/Nickkolok/latex-shortmathj) + +## License + +LPPL - LaTeX Project Public License v1.3c+, DFSG compat. + +## Authors + ++ Nikolai Avdeev aka @nickkolok diff --git a/Master/texmf-dist/doc/latex/shortmathj/biblatex-shortmathj-examples.bib b/Master/texmf-dist/doc/latex/shortmathj/biblatex-shortmathj-examples.bib new file mode 100644 index 00000000000..d42058017e1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/shortmathj/biblatex-shortmathj-examples.bib @@ -0,0 +1,41 @@ +@article{solymosi2010question, + title={On a question\relax ~of Erd\H{o}s and Ulam}, + author={Solymosi, Jozsef and De Zeeuw, Frank}, + archivePrefix = {arXiv}, + eprint = {0806.3095}, + journal={Discrete \& Computational Geometry}, + volume={43}, + number={2}, + pages={393--401}, + year={2010}, + publisher={Springer}, +} + +@article{halbeisen2019geometric, + title={A geometric representation of integral solutions of $x^2+ xy+ y^2= m^2$}, + author={Halbeisen, Lorenz and Hungerb{\"u}hler, Norbert}, + journal={Quaestiones Mathematicae}, + pages={1--15}, + year={2019}, + publisher={Taylor \& Francis}, +} + +@article{Kohnert2006IntegralPS, + title={Integral point sets over {$\mathbb{Z}^m_n$}}, + author={Axel Kohnert and Sascha Kurz}, + year={2006}, + journal={Discrete Applied Mathematics}, + volume={157}, + pages={2105–2117}, +} + +@article{erdos1945integral, + title={Integral distances}, + author={Erd{\H{o}}s, Paul}, + doi={10.1090/S0002-9904-1945-08490-0}, + journal={Bulletin of the American Mathematical Society}, + volume={51}, + number={12}, + pages={996}, + year={1945} +} diff --git a/Master/texmf-dist/doc/latex/shortmathj/index.js b/Master/texmf-dist/doc/latex/shortmathj/index.js new file mode 100644 index 00000000000..6a477f363bd --- /dev/null +++ b/Master/texmf-dist/doc/latex/shortmathj/index.js @@ -0,0 +1,93 @@ +const csv = require('csv-parser') +const fs = require('fs') +const results = []; + +function readCSVsimple(filename, callback){ + + fs.createReadStream(filename) + .pipe(csv()) + .on('data', (data) => results.push(data)) + .on('end', () => { + callback(); + }); +} + +readCSVsimple('annser.csv', ()=>{ + readCSVsimple('custom.csv', ()=>{ + writeSTY() + }); +}); + +function createSynonyms(results){ + for(let i = 0; i < results.length; i++) { + let res = results[i]; + if(/^The\s+/.test(res['Full Title'])){ + results.push({ + 'Full Title' : res['Full Title'].replace(/^The\s+/,''), + 'Abbrev' : res['Abbrev'] + }); + } + if(/\s*\(*New\Series\.*\)*$/.test(res['Full Title'])){ + results.push({ + 'Full Title' : res['Full Title'].replace(/\s*\(*New\Series\.*\)*$/,''), + 'Abbrev' : res['Abbrev'] + }); + } + } + +} + +function resultsToReplacementMap(results){ + const replacementMap = []; + createSynonyms(results); + results.map(res => { + if(res['Full Title'] === res['Abbrev']){ + // Full and Abbreviated titles are equal, thus do nothing + return; + } + if(!res['Full Title'] || !res['Abbrev']){ + // Nothing to replace! + return; + } + if(res['Full Title'].search(/\$/) !== -1 || res['Abbrev'].search(/\$/) !== -1){ + // Just skip journals with formulas in titles + return; + } + res['Full Title'] = res['Full Title'].replace(/&/g,'\\&'); + res['Abbrev'] = res['Abbrev'].replace(/&/g,'\\&'); + replacementMap.push([res['Full Title'],res['Abbrev']]); + }); + return replacementMap; +} + + + +function writeSTY(){ + styContent = fs.readFileSync('shortmathj.template.sty','utf8'); + + let alphabet = {}; + let replacementMap = resultsToReplacementMap(results); + replacementMap.map(rule => { + alphabet[rule[0].substr(0,1)] = []; + }); + replacementMap.map(rule => { + alphabet[rule[0].substr(0,1)].push( + "\\ifthenelse{\\equal{\\givenAMSjournalname}{\\detokenize{"+rule[0]+"}}}{\\def\\shortifiedAMSjournalname{"+rule[1]+"}}{}%\n" + ); + }); + + let replacement=""; + + for(let letter in alphabet){ + replacement += + "\\ifthenelse{\\equal{\\firstletter}{\\detokenize{"+letter+"}}}{%\n" + + alphabet[letter].join('') + + "}{}%\n"; + } + + + + styContent = styContent.replace(/\%\%\%\{\{SHORTMAP[\s\S]*\%\%\%\}\}SHORTMAP/, replacement + "%"); + + fs.writeFileSync('shortmathj.sty', styContent); +} diff --git a/Master/texmf-dist/doc/latex/shortmathj/package.json b/Master/texmf-dist/doc/latex/shortmathj/package.json new file mode 100644 index 00000000000..22c77822f5a --- /dev/null +++ b/Master/texmf-dist/doc/latex/shortmathj/package.json @@ -0,0 +1,26 @@ +{ + "name": "latex-shortmathj", + "version": "0.5.0", + "description": "Scripts for generating LaTeX package shortmathj", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://gitlab.com/Nickkolok/latex-shortmathj.git" + }, + "keywords": [ + "latex", + "AMS" + ], + "author": "Nikolai Avdeev aka @nickkolok", + "license": "LPPL-1.3c", + "bugs": { + "url": "https://gitlab.com/Nickkolok/latex-shortmathj/issues" + }, + "homepage": "https://gitlab.com/Nickkolok/latex-shortmathj#readme", + "dependencies": { + "csv-parser": "^2.3.2" + } +} diff --git a/Master/texmf-dist/doc/latex/shortmathj/shortmathj-biblatex-mwe.pdf b/Master/texmf-dist/doc/latex/shortmathj/shortmathj-biblatex-mwe.pdf Binary files differnew file mode 100644 index 00000000000..ead18119f1c --- /dev/null +++ b/Master/texmf-dist/doc/latex/shortmathj/shortmathj-biblatex-mwe.pdf diff --git a/Master/texmf-dist/doc/latex/shortmathj/shortmathj-biblatex-mwe.tex b/Master/texmf-dist/doc/latex/shortmathj/shortmathj-biblatex-mwe.tex new file mode 100644 index 00000000000..368da97a1de --- /dev/null +++ b/Master/texmf-dist/doc/latex/shortmathj/shortmathj-biblatex-mwe.tex @@ -0,0 +1,28 @@ +\documentclass[british]{article} +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} + + +\usepackage{babel} +\usepackage{csquotes} + +\usepackage{amssymb} % Just for \mathbb + +\usepackage[style=numeric, backend=biber]{biblatex} + +\addbibresource{biblatex-examples.bib} + +\addbibresource{biblatex-shortmathj-examples.bib} + +\usepackage{shortmathj} + +\DeclareFieldFormat[article]{titlecase}{\shortifyAMSjournalname{#1}} + +\begin{document} + +\cite{sigfridsson,knuth:ct:e}. + +See also \cite{solymosi2010question,halbeisen2019geometric,Kohnert2006IntegralPS,erdos1945integral}. +\printbibliography + +\end{document} diff --git a/Master/texmf-dist/doc/latex/shortmathj/shortmathj.template.sty b/Master/texmf-dist/doc/latex/shortmathj/shortmathj.template.sty new file mode 100644 index 00000000000..c5f0279f011 --- /dev/null +++ b/Master/texmf-dist/doc/latex/shortmathj/shortmathj.template.sty @@ -0,0 +1,27 @@ +\NeedsTeXFormat{LaTeX2e}[1994/06/01] +\ProvidesPackage{shortmathj} + [2020/03/18 v0.5.0 LaTeX package to shortify names of AMS journals automatically] + +\RequirePackage{ifthen} +\RequirePackage{xstring} + +\newcommand{\shortifyAMSjournalname}[1]{% +\def\shortifiedAMSjournalname{}% +\edef\givenAMSjournalname{\detokenize{#1}}% +\StrLeft{\givenAMSjournalname}{1}[\firstletter]% +%%%{{SHORTMAP +% The following rows present here only as examples +% The content of the block is generated automatically +\ifthenelse{\equal{\firstletter}{\detokenize{D}}}{% +\ifthenelse{\equal{\givenAMSjournalname}{\detokenize{Discrete \& Computational Geometry}}}{\def\shortifiedAMSjournalname{Discr. Comp. Geom.}}{}% +\ifthenelse{\equal{\givenAMSjournalname}{\detokenize{Discrete Applied Mathematics}}}{\def\shortifiedAMSjournalname{Discr. Appl. Math.}}{}% +}{}% +\ifthenelse{\equal{\firstletter}{\detokenize{B}}}{% +\ifthenelse{\equal{\givenAMSjournalname}{\detokenize{Bulletin of the American Mathematical Society}}}{\def\shortifiedAMSjournalname{Bull. Amer. Math. Soc.}}{}% +}{}% +%%%}}SHORTMAP +\ifthenelse{\equal{\shortifiedAMSjournalname}{}}{#1}{\shortifiedAMSjournalname{}}% +} + + +\endinput |