texlive[43505] Master/texmf-dist: revquantum (15mar17)
commits+karl at tug.org
commits+karl at tug.org
Wed Mar 15 22:16:13 CET 2017
Revision: 43505
http://tug.org/svn/texlive?view=revision&revision=43505
Author: karl
Date: 2017-03-15 22:16:12 +0100 (Wed, 15 Mar 2017)
Log Message:
-----------
revquantum (15mar17)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/revquantum/README.md
trunk/Master/texmf-dist/doc/latex/revquantum/revquantum.pdf
trunk/Master/texmf-dist/source/latex/revquantum/revquantum.dtx
trunk/Master/texmf-dist/tex/latex/revquantum/revquantum.sty
Added Paths:
-----------
trunk/Master/texmf-dist/doc/latex/revquantum/Install.ps1
trunk/Master/texmf-dist/doc/latex/revquantum/example.pdf
trunk/Master/texmf-dist/doc/latex/revquantum/example.tex
Removed Paths:
-------------
trunk/Master/texmf-dist/doc/latex/revquantum/build.py
Added: trunk/Master/texmf-dist/doc/latex/revquantum/Install.ps1
===================================================================
--- trunk/Master/texmf-dist/doc/latex/revquantum/Install.ps1 (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/revquantum/Install.ps1 2017-03-15 21:16:12 UTC (rev 43505)
@@ -0,0 +1,22 @@
+param(
+ [switch] $CTAN
+)
+
+#region Bootstrap PoShTeX
+if (!(Get-Module -ListAvailable -Name posh-tex -ErrorAction SilentlyContinue)) {
+ Install-Module posh-tex -Scope CurrentUser
+}
+Import-Module posh-tex
+#endregion
+
+Out-TeXStyle revquantum
+Out-TeXStyleDocumentation revquantum
+
+Install-TeXUserResource tex/latex/revquantum revquantum.sty, revquantum.pdf
+
+Install-PandocUserResource templates pandoc/templates/revquantum.latex -ErrorAction Continue
+
+if ($CTAN) {
+ Invoke-TeXBuildEngine example.tex
+ Export-CTANArchive -ArchiveLayout Simple revquantum.ins, revquantum.pdf, README.md, example.tex, example.pdf, Install.ps1
+}
\ No newline at end of file
Modified: trunk/Master/texmf-dist/doc/latex/revquantum/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/revquantum/README.md 2017-03-15 01:02:39 UTC (rev 43504)
+++ trunk/Master/texmf-dist/doc/latex/revquantum/README.md 2017-03-15 21:16:12 UTC (rev 43505)
@@ -40,8 +40,21 @@
## Installing ##
-Installing LaTeX packages outside of CTAN is a pain, and this is no exception. I'll submit there at some point to remove that difficulty. In the meantime, I think the following works on Unix-like systems. If not, let me know or pull request with better instructions.
+### Install With PowerShell ###
+In an attempt to cut down on the pain of LaTeX package installation, ``{revquantum}`` uses [PoShTeX](https://github.com/cgranade/posh-tex/) to automate installation. If you're running PowerShell already, just run ``Install.ps1``:
+
+```powershell
+PS> Unblock-File Install.ps1 # Mark the installer as safe to run.
+PS> ./Install.ps1
+```
+
+PowerShell itself is easy to install on many macOS and Linux systems using the [provided packages](https://github.com/PowerShell/PowerShell#get-powershell).
+
+### Manual Installation ###
+
+I think the following works on Unix-like systems. If not, let me know or pull request with better instructions.
+
```bash
$ latex revquantum.ins # Makes the actual .sty from the .dtx file.
$ pdflatex revquantum.dtx # Makes documentation, such as it is.
Deleted: trunk/Master/texmf-dist/doc/latex/revquantum/build.py
===================================================================
--- trunk/Master/texmf-dist/doc/latex/revquantum/build.py 2017-03-15 01:02:39 UTC (rev 43504)
+++ trunk/Master/texmf-dist/doc/latex/revquantum/build.py 2017-03-15 21:16:12 UTC (rev 43505)
@@ -1,295 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-from __future__ import print_function, unicode_literals
-
-PACKAGE_NAME = 'revquantum'
-TEX_DIR = None
-
-import errno
-import sys
-import os
-import tempfile
-import shutil
-import zipfile
-from subprocess import Popen, PIPE
-
-from io import StringIO
-
-def print_usage():
- print("""
-Usage:
-------
-
-python build.py tds
- Builds a *.tds.zip file for this package.
-
-python build.py install
- Installs this package into the main TeX directory.
- May require administrator privileges.
-""")
- sys.exit(1)
-
-def is_writable(dir_name):
- # Technique adapted from:
- # http://stackoverflow.com/a/25868839/267841
- # We modify by not raising on other OSErrors, as
- # we don't care *why* a directory isn't writable,
- # so much as that we need to know that it isn't.
- # We also note that tempfile raises an IOError
- # on Windows if it can't write, so we catch that,
- # too.
- try:
- with tempfile.TemporaryFile(dir=dir_name):
- pass
- except (OSError, IOError) as ex:
- return False
-
- return True
-
-def mkdir_p(path):
- # Copied from http://stackoverflow.com/a/600612/267841,
- # in keeping with the CC-BY-SA 3.0 license on StackOverflow
- # user contributions.
- if os.path.isdir(path):
- return
- try:
- os.makedirs(path)
- except OSError as exc: # Python > 2.5
- if exc.errno == errno.EEXIST and os.path.isdir(path):
- pass
- else:
- raise
- except WindowsError as exc:
- if exc.errno == 183 and os.path.isdir(path):
- pass
- else:
- raise
-
-def try_until(condition, *fns):
- for fn in fns:
- retval = fn()
- if condition(retval):
- return retval
-
- # This is likely a terrible error for any poor user,
- # so we should probably catch it. Probably.
- raise RuntimeError("No candidates found matching the given condition.")
-
-def is_miktek():
- # Assume MikTeX if and only if Windows.
- # This is a bad assumption, but we can encapsulate
- # it here and generalize later.
- return os.name == 'nt'
-
-def find_tex_root():
- proc = Popen(['kpsewhich', 'article.cls'], stdout=PIPE)
- stdout, stderr = proc.communicate()
-
- head, tail = os.path.split(stdout.strip())
-
- # Note that kpsewhich returns with / characters, even
- # under Windows, so we must use str.split to override
- # os.path's behavior.
- head_parts = head.split('/')
-
- # If we're on Windows, then that destroyed the drive
- # part of the pathspec.
- if os.name == 'nt':
- head_parts = [head_parts[0] + '\\'] + head_parts[1:]
-
- # Remove "tex/latex/base" from head_parts, since that's where
- # article.cls should live.
- tex_root = os.path.join(*head_parts[:-3])
-
- return tex_root
-
-def find_tex_user():
- if is_miktek():
- # Use MikTeX's initexmf utility to find the user install
- # dir.
- # http://tex.stackexchange.com/a/69484/615
- initexmf = Popen(['initexmf', '--report'], stdout=PIPE)
- stdout, stderr = initexmf.communicate()
-
- for line in stdout.split('\n'):
- try:
- key, value = line.split(':', 1)
- if key.strip().lower() == 'userinstall':
- return value.strip()
- except:
- continue
-
- raise RuntimeError("MikTeX did not report a UserInstall directory.")
-
- else:
- return os.path.expanduser('~/texmf')
-
-def find_tex():
- global TEX_DIR
-
- if TEX_DIR is None:
- TEX_DIR = try_until(is_writable,
- find_tex_root,
- find_tex_user
- )
-
- return TEX_DIR
-
-def copy_to_tex(what, tex_path=['tex', 'latex']):
- tex_root = find_tex()
- where = os.path.join(tex_root, *tex_path)
- full_path = os.path.join(where, what)
-
- # Check if the directory exists, make it if it doesn't.
- mkdir_p(where)
-
- print("Installing: {} ---> {}".format(what, full_path))
- shutil.copyfile(what, full_path)
-
-def write_to_zip(zip_file, filename, arcname=None, normalize_crlf=None):
- """
- normalize_crlf = None: automatically detect from filename.
- """
-
- if normalize_crlf is None:
- root, ext = os.path.splitext(filename)
- if ext in ('.dtx', '.ins', '.txt', '.md', '.py', '.tex'):
- normalize_crlf = True
- else:
- normalize_crlf = False
-
- if arcname is None:
- arcname = filename
-
- if not normalize_crlf:
- print("\tPacking: {} ---> {}".format(filename, arcname))
- zip_file.write(filename, arcname=arcname)
- else:
- print("\tPacking: {} ---> {} (normalized line endings)".format(filename, arcname))
- contents = StringIO(newline='\n')
- with open(filename, 'r') as f:
- for line in f:
- contents.write(line.decode('utf-8'))
- zip_file.writestr(
- arcname,
- contents.getvalue()
- )
-
-def yes_proc(args, yes="yes"):
- proc = Popen(args, stdin=PIPE)
- while proc.returncode is None:
- proc.communicate(yes)
- proc.poll()
-
- return proc.returncode == 0
-
-class LaTeXStyleBuilder(object):
- """
- Builds a DocStrip-formatted LaTeX style by running
- the LaTeX processor on the appropriate *.dtx file.
- """
- style_name = None
- manifest = {}
- ctan_manifest = {}
-
- def __init__(self, style_name):
- self.style_name = style_name
-
- self.manifest = {
- '{}.{}'.format(style_name, ext):
- path + [style_name]
- for ext, path in
- {
- 'sty': ['tex', 'latex'],
- 'pdf': ['doc', 'latex']
- }.items()
- }
-
- self.ctan_manifest = [
- '{}.dtx'.format(style_name),
- '{}.ins'.format(style_name),
- '{}.pdf'.format(style_name),
- 'build.py',
- 'README.md'
- ]
-
- def build_sty(self):
- print("Building: {}.sty".format(self.style_name))
- if not yes_proc(['latex', '{}.ins'.format(self.style_name)]):
- raise RuntimeError
- print("\n\n\n")
- return self
-
- def build_doc_pdf(self):
- print("Building: {}.pdf".format(self.style_name))
- if not yes_proc(['pdflatex', '{}.dtx'.format(self.style_name)]):
- raise RuntimeError
- print("\n\n\n")
- return self
-
- def build_tds_zip(self):
- print("Building: {}.tds.zip".format(self.style_name))
- tds_zip = zipfile.ZipFile('{}.tds.zip'.format(self.style_name), 'w')
-
- for what, where in self.manifest.items():
- assert os.path.isfile(what)
- write_to_zip(tds_zip, what, arcname=os.path.join(*where + [what]))
-
- print("\n\n\n")
- return self
-
- def build_ctan_zip(self):
- print("Building: {}.zip".format(self.style_name))
- ctan_zip = zipfile.ZipFile('{}.zip'.format(self.style_name), 'w')
-
- for what in self.ctan_manifest:
- assert os.path.isfile(what)
- write_to_zip(ctan_zip, what, arcname=os.path.join(self.style_name, what))
-
- print("\n\n\n")
- return self
-
- def install(self):
- for what, where in self.manifest.items():
- assert os.path.isfile(what)
- copy_to_tex(what, where)
-
- # Make sure to run texhash if we're not using MikTeX.
- if not is_miktek():
- print("Rehashing...")
- texhash = Popen(['texhash'])
- texhash.wait()
-
- return self
-
-if __name__ == "__main__":
- print("""
-WARNING: This installer is still in alpha, and is provided
- as a convenience only. That said, this installer
- may cause you to say unkind words in frustration
- instead of providing the intended convenience.
-""")
-
- if len(sys.argv) < 2:
- print_usage()
-
- else:
- subcommand = sys.argv[1]
- if subcommand not in ('tds', 'install', 'ctan'):
- print("No such command {}, try either 'tds', 'install' or 'ctan'.")
- print_usage()
-
- builder = LaTeXStyleBuilder(PACKAGE_NAME)
- builder.build_sty().build_doc_pdf()
-
- if subcommand == 'tds':
- builder.build_tds_zip()
-
- elif subcommand == 'install':
- builder.install()
-
- elif subcommand == 'ctan':
- builder.build_ctan_zip()
-
- else:
- assert False
Added: trunk/Master/texmf-dist/doc/latex/revquantum/example.pdf
===================================================================
(Binary files differ)
Index: trunk/Master/texmf-dist/doc/latex/revquantum/example.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/revquantum/example.pdf 2017-03-15 01:02:39 UTC (rev 43504)
+++ trunk/Master/texmf-dist/doc/latex/revquantum/example.pdf 2017-03-15 21:16:12 UTC (rev 43505)
Property changes on: trunk/Master/texmf-dist/doc/latex/revquantum/example.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/revquantum/example.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/revquantum/example.tex (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/revquantum/example.tex 2017-03-15 21:16:12 UTC (rev 43505)
@@ -0,0 +1,52 @@
+\documentclass[pra,aps,twocolumn,superscriptaddress,10pt]{revtex4-1}
+\usepackage[pretty,uselistings]{revquantum}
+
+%=============================================================================
+% FRONT MATTER
+%=============================================================================
+
+\begin{document}
+
+\title{Example \textsf{revquantum} Document}
+
+\author{Christopher Granade}
+\email{cgranade at cgranade.com}
+\affilUSydPhys
+\affilEQuSUSyd
+
+\date{\today}
+
+\begin{abstract}
+ \TODO
+\end{abstract}
+
+\maketitle
+
+%=============================================================================
+% MAIN DOCUMENT
+%=============================================================================
+
+Lorum ipsum is kind of dated by now, but whatever. At least we can $\Tr$ its
+history.
+
+\todo{an example of a TODO, which will cause errors if present in the
+\texttt{final} version.}
+
+\bibliography{example}
+
+%=============================================================================
+% APPENDICES
+%=============================================================================
+
+\appendix
+
+%=============================================================================
+\section{Source Code}
+\label{apx:code}
+%=============================================================================
+
+\begin{lstlisting}[style=python,gobble=4,caption={Quick example of importing \cite{johansson_qutip_2013}.}]
+ >>> import qutip as qt
+\end{lstlisting}
+
+\end{document}
\ No newline at end of file
Modified: trunk/Master/texmf-dist/doc/latex/revquantum/revquantum.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/revquantum/revquantum.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/revquantum/revquantum.dtx 2017-03-15 01:02:39 UTC (rev 43504)
+++ trunk/Master/texmf-dist/source/latex/revquantum/revquantum.dtx 2017-03-15 21:16:12 UTC (rev 43505)
@@ -26,7 +26,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{revquantum}
%<*package>
- [2016/09/21 v0.10 Build script fixes for CTAN submission.]
+ [2017/03/15 v0.11 Misc. fixes and improved installer.]
%</package>
%
%<*driver>
@@ -550,6 +550,7 @@
}{}
\ifthenelse{\boolean{@bibtexhacks}}{
\RequirePackage{letltxmacro}
+ \RequirePackage{etoolbox}
}{}
% \end{macrocode}
@@ -664,17 +665,21 @@
% suggested by egreg} for a rather annoying |{revtex4-1}| bug. In particular,
% we will set up |language={en}| as an alias for |language={english}|, so that
% |{revtex4-1}| will no longer raise |{babel}| errors for the undefined language.
+% As with our unforgivable hacks, we will guard the forgivable hacks with
+% the |[nobibtexhacks]| option.
% \begin{macro}{\ORIGselectlanguage}
% \begin{macrocode}
-\LetLtxMacro{\ORIGselectlanguage}{\selectlanguage}
-\DeclareRobustCommand{\selectlanguage}[1]{%
- \@ifundefined{alias@\string#1}
- {\ORIGselectlanguage{#1}}
- {\begingroup\edef\x{\endgroup
- \noexpand\ORIGselectlanguage{\@nameuse{alias@#1}}}\x}%
-}
+\ifthenelse{\boolean{@bibtexhacks}}{
+ \LetLtxMacro{\ORIGselectlanguage}{\selectlanguage}
+ \DeclareRobustCommand{\selectlanguage}[1]{%
+ \@ifundefined{alias@\string#1}
+ {\ORIGselectlanguage{#1}}
+ {\begingroup\edef\x{\endgroup
+ \noexpand\ORIGselectlanguage{\@nameuse{alias@#1}}}\x}%
+ }
+}{}
% \end{macrocode}
% \end{macro}
@@ -697,7 +702,24 @@
% \end{macrocode}
+% We will also redefine |\doibase| to eat any newlines following it, and to
+% prefer HTTPS to HTTP. This will fix a rather annoying bug where line breaks
+% in the *.bbl source can introduce extraneous spaces into the target of
+% each citation's |\href|.
+% \begin{macro}{\doibase}
+% \begin{macrocode}
+
+\ifthenelse{\boolean{@bibtexhacks}}{
+ % Ensure that the \doibase command is defined, just in case.
+ \providecommand{\doibase}{}
+ \renewcommand{\doibase}[1]{https://dx.doi.org/\ifdefempty{#1}{}{#1}}
+}{}
+
+% \end{macrocode}
+% \end{macro}
+
+
% \subsection{TODO Support} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% These commands provide a way of marking items as needing to be done before
Modified: trunk/Master/texmf-dist/tex/latex/revquantum/revquantum.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/revquantum/revquantum.sty 2017-03-15 01:02:39 UTC (rev 43504)
+++ trunk/Master/texmf-dist/tex/latex/revquantum/revquantum.sty 2017-03-15 21:16:12 UTC (rev 43505)
@@ -22,7 +22,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{revquantum}
- [2016/09/21 v0.10 Build script fixes for CTAN submission.]
+ [2017/03/15 v0.11 Misc. fixes and improved installer.]
\usepackage{ifthen}
@@ -177,6 +177,7 @@
}{}
\ifthenelse{\boolean{@bibtexhacks}}{
\RequirePackage{letltxmacro}
+ \RequirePackage{etoolbox}
}{}
@@ -260,13 +261,15 @@
-\LetLtxMacro{\ORIGselectlanguage}{\selectlanguage}
-\DeclareRobustCommand{\selectlanguage}[1]{%
- \@ifundefined{alias@\string#1}
- {\ORIGselectlanguage{#1}}
- {\begingroup\edef\x{\endgroup
- \noexpand\ORIGselectlanguage{\@nameuse{alias@#1}}}\x}%
-}
+\ifthenelse{\boolean{@bibtexhacks}}{
+ \LetLtxMacro{\ORIGselectlanguage}{\selectlanguage}
+ \DeclareRobustCommand{\selectlanguage}[1]{%
+ \@ifundefined{alias@\string#1}
+ {\ORIGselectlanguage{#1}}
+ {\begingroup\edef\x{\endgroup
+ \noexpand\ORIGselectlanguage{\@nameuse{alias@#1}}}\x}%
+ }
+}{}
@@ -283,7 +286,16 @@
+\ifthenelse{\boolean{@bibtexhacks}}{
+ % Ensure that the \doibase command is defined, just in case.
+ \providecommand{\doibase}{}
+ \renewcommand{\doibase}[1]{https://dx.doi.org/\ifdefempty{#1}{}{#1}}
+}{}
+
+
+
+
\ifthenelse{\boolean{@final}}{
\newcommand{\todo}[1]{%
\PackageError{revquantum}{Unaddressed TODO}%
More information about the tex-live-commits
mailing list