summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/awesomebox
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-07-30 20:59:04 +0000
committerKarl Berry <karl@freefriends.org>2019-07-30 20:59:04 +0000
commit4f9282799e6b77aab5da00b68ede2cc9a7ae33e1 (patch)
tree4c79747ef71ffb2f1d4af96444d004551db321e7 /Master/texmf-dist/tex/latex/awesomebox
parentcc092956f5bc52f3152f18ae399dbd7ad172a0e4 (diff)
awesomebox (30jul19)
git-svn-id: svn://tug.org/texlive/trunk@51776 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/awesomebox')
-rw-r--r--Master/texmf-dist/tex/latex/awesomebox/awesomebox.sty54
1 files changed, 44 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/latex/awesomebox/awesomebox.sty b/Master/texmf-dist/tex/latex/awesomebox/awesomebox.sty
index db360d541f5..75bc74e6e1a 100644
--- a/Master/texmf-dist/tex/latex/awesomebox/awesomebox.sty
+++ b/Master/texmf-dist/tex/latex/awesomebox/awesomebox.sty
@@ -1,5 +1,5 @@
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{awesomebox}[2019/04/04 v0.5]
+\ProvidesPackage{awesomebox}[2019/07/27 v0.6]
% Awesome Box has been written by Étienne Deparis and is released under
% the WTFPL (http://www.wtfpl.net/txt/copying/).
@@ -15,6 +15,8 @@
% * Custom vertical rule color
% v0.5: Georger Araújo https://github.com/georgerbr
% * Horizontal rules at top and bottom, title
+% v0.6: Vincent Goulet https://github.com/vigou3
+% * Improving table cell rendering
% https://ctan.org/pkg/fontawesome5
\RequirePackage{fontawesome5}
@@ -42,10 +44,9 @@
\definecolor{abimportant}{RGB}{188,0,0}
\definecolor{abvrulecolor}{RGB}{221,221,216}
+% Customizable length
\newlength{\aweboxleftmargin}
-\setlength{\aweboxleftmargin}{0.08\linewidth}
\newlength{\aweboxcontentwidth}
-\setlength{\aweboxcontentwidth}{0.92\linewidth}
\newlength{\aweboxvskip}
\setlength{\aweboxvskip}{5mm}
\newlength{\aweboxsignraise}
@@ -53,6 +54,10 @@
\newlength{\aweboxrulewidth}
\setlength{\aweboxrulewidth}{2pt}
+\AtBeginDocument{%
+ \setlength{\aweboxleftmargin}{0.12\linewidth}%
+ \setlength{\aweboxcontentwidth}{0.88\linewidth}}
+
\RequirePackage{array}
% To allow for more than one optional argument
@@ -62,17 +67,35 @@
\def\abShortLine{\cline{2-2}}
\def\abLongLine{\hline}
+% The following commands are used to adjust and restore awesome boxes
+% content width in respect to the current environment (e.g. lists).
+\RequirePackage{ifthen}
+\newlength{\aweboxlinewidthvar}
+\setlength{\aweboxlinewidthvar}{0pt}
+\newlength{\aweboxlinewidthref}
+\AtBeginDocument{\setlength{\aweboxlinewidthref}{\linewidth}}
+\newcommand{\awesomeboxadjustcontentwidth}{%
+ \ifthenelse{\lengthtest{\linewidth=\aweboxlinewidthref}}{}{%
+ \setlength{\aweboxlinewidthvar}{\dimexpr\aweboxlinewidthref-\linewidth}%
+ \setlength{\aweboxcontentwidth}{\dimexpr\aweboxcontentwidth-\aweboxlinewidthvar}}}%
+ %\aweboxdebug}}
+\newcommand{\awesomeboxrestorecontentwidth}{%
+ \ifthenelse{\lengthtest{\linewidth=\textwidth}}{}{%
+ \setlength{\aweboxcontentwidth}{\dimexpr\aweboxcontentwidth+\aweboxlinewidthvar}%
+ \setlength{\aweboxlinewidthvar}{0pt}}}
+
% Commands API
% \awesomebox[vrulecolor][hrule][title]{vrulewidth}{icon}{iconcolor}{content}
\NewDocumentCommand \awesomebox { O{abvrulecolor} O{} o m m m +m }{%
- \vspace{\aweboxvskip}\noindent
+ {\vskip \aweboxvskip}\noindent\awesomeboxadjustcontentwidth%
\begin{tabular}%
- {p{\aweboxleftmargin}!{\color{#1}\vrule width #4}p{\aweboxcontentwidth}}
+ {@{}>{\centering\arraybackslash}%
+ p{\aweboxleftmargin}@{}!{\color{#1}\vrule width #4}%
+ p{\dimexpr\aweboxcontentwidth-#4-\tabcolsep}@{}}
\IfValueTF {#3}
{ & #3 \\ #2 \raisebox{\aweboxsignraise}{\textcolor{#6}{\Huge#5}} & #7 \\ #2}
{ #2 \raisebox{\aweboxsignraise}{\textcolor{#6}{\Huge#5}} & #7 \\ #2}
- \end{tabular}
- \vspace{\aweboxvskip}}
+ \end{tabular}{\vskip \aweboxvskip}\awesomeboxrestorecontentwidth}
\newcommand{\notebox}[1]{%
\awesomebox[abnote]{\aweboxrulewidth}{\abIconInfoCircle}{abnote}{#1}}
@@ -94,13 +117,15 @@
% content
% \end{awesomeblock}
\NewDocumentEnvironment{awesomeblock}{ O{abvrulecolor} O{} o m m m }
-{\vspace{\aweboxvskip}\noindent
+{{\vskip \aweboxvskip}\noindent\awesomeboxadjustcontentwidth%
\begin{tabular}%
- {p{\aweboxleftmargin}!{\color{#1}\vrule width #4}p{\aweboxcontentwidth}}
+ {@{}>{\centering\arraybackslash}%
+ p{\aweboxleftmargin}@{}!{\color{#1}\vrule width #4}%
+ p{\dimexpr\aweboxcontentwidth-#4-\tabcolsep}@{}}
\IfValueTF {#3}
{ & #3 \\ #2 \raisebox{\aweboxsignraise}{\textcolor{#6}{\Huge#5}} &}
{ #2 \raisebox{\aweboxsignraise}{\textcolor{#6}{\Huge#5}} &}}
-{\\ #2 \end{tabular}\vspace{\aweboxvskip}}
+{\\ #2 \end{tabular}{\vskip \aweboxvskip}\awesomeboxrestorecontentwidth}
\newenvironment{noteblock}%
{\begin{awesomeblock}[abnote]{\aweboxrulewidth}{\abIconInfoCircle}{abnote}}
@@ -122,4 +147,13 @@
{\begin{awesomeblock}[abimportant]{\aweboxrulewidth}{\abIconExclamationCircle}{abimportant}}
{\end{awesomeblock}}
+\newcommand{\aweboxdebug}{%
+ \typeout{**************************}%
+ \typeout{Line width: \the\linewidth}%
+ \typeout{Reference line width: \the\aweboxlinewidthref\space(text width: \the\textwidth)}%
+ \typeout{Width difference: \the\aweboxlinewidthvar}%
+ \typeout{Margin width: \the\aweboxleftmargin}%
+ \typeout{Content width: \the\aweboxcontentwidth}%
+ \typeout{**************************}}
+
\endinput