summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/centeredline
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/centeredline
Initial commit
Diffstat (limited to 'macros/latex/contrib/centeredline')
-rw-r--r--macros/latex/contrib/centeredline/README.md66
-rw-r--r--macros/latex/contrib/centeredline/centeredline.sty32
2 files changed, 98 insertions, 0 deletions
diff --git a/macros/latex/contrib/centeredline/README.md b/macros/latex/contrib/centeredline/README.md
new file mode 100644
index 0000000000..8be6413692
--- /dev/null
+++ b/macros/latex/contrib/centeredline/README.md
@@ -0,0 +1,66 @@
+<!-- -->
+
+ Author: Jean-Francois Burnol
+ Package: centeredline
+ Version: 1.1 (2019/05/03)
+ License: LPPL 1.3c
+ Copyright (C) 2019 Jean-Francois Burnol
+ <jfbu at free dot fr>
+
+# DESCRIPTION #
+
+After `\usepackage{centeredline}` one can use
+
+ \centeredline{....}
+
+to get the argument centered, in a better way than with `\centerline`:
+
+1. `\verb` or other catcode changes inside the argument are allowed,
+2. the centering (with respect to the surrounding text paragraph) will
+ be as expected if this all happens inside an item from a LaTeX list
+ environment.
+
+Material whose natural width exceeds the linewidth will get properly
+centered too.
+
+The macro itself may be encountered in paragraph or in vertical mode.
+It places the argument inside a `\hbox` (inside an extra simple group).
+
+
+# HISTORY #
+
+I have used this macro since 2013 and it has served me well.
+
+I am making it public as is, without any re-thinking about whether it may
+have some limitations which I somehow did not encounter in my personal usage.
+Suggestions for improvements are welcome, and will be recorded although I do
+not expect to update the package anytime soon.
+
+
+# CHANGE LOG #
+
+- v1.0 (2019/04/27): First release.
+- v1.1 (2019/05/03): Improved description (this file).
+
+
+# LICENSE #
+
+This Work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License 1.3c.
+This version of this license is in
+
+> <http://www.latex-project.org/lppl/lppl-1-3c.txt>
+
+and the latest version of this license is in
+
+> <http://www.latex-project.org/lppl.txt>
+
+and version 1.3 or later is part of all distributions of
+LaTeX version 2005/12/01 or later.
+
+The Author of this Work is:
+
+> Jean-Francois Burnol `<jfbu at free dot fr>`
+
+This Work consists of the file `centeredline.sty` and
+accompanying `README.md`.
diff --git a/macros/latex/contrib/centeredline/centeredline.sty b/macros/latex/contrib/centeredline/centeredline.sty
new file mode 100644
index 0000000000..d1afe19f3e
--- /dev/null
+++ b/macros/latex/contrib/centeredline/centeredline.sty
@@ -0,0 +1,32 @@
+%% File: centeredline.sty
+%% Version: 1.1 (2019/05/03)
+%% License: LPPL 1.3c
+%% Copyright (C) 2019 Jean-Francois Burnol <jfbu at free dot fr>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{centeredline}[2019/05/03 v1.1 centering a line the JFB way]
+% \centeredline: OUR OWN LITTLE MACRO FOR CENTERING LINES
+%
+% 7 mars 2013
+% \ignorespaces added June 9, 2013
+%
+% This macro allows to conveniently center a line inside a paragraph and still
+% allow usage therein of \verb or other macros changing catcodes.
+%
+% It works nicely in list environments (as it uses \linewidth, not \hsize...;
+% maybe there is an even better LaTeX parameter to use, but I don't know
+% LaTeX2e that well enough and never typeset in two-column mode.)
+%
+% Note: \centeredline is scope limiting for assignments done during execution
+% of its argument.
+%
+\newcommand*\centeredline{%
+ \ifhmode \\\relax
+ \def\centeredline@@{\hss\egroup\hskip\z@skip\ignorespaces}%
+ \else
+ \def\centeredline@@{\hss\egroup}%
+ \fi
+ \afterassignment\centeredline@
+ \let\next=}%
+\def\centeredline@
+ {\hbox to \linewidth \bgroup \hss \bgroup \aftergroup\centeredline@@}%
+\endinput