summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/centeredline/centeredline.sty
blob: d1afe19f3ec941c5d9f50a934d03859b917a5281 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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