summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-04-09 22:40:10 +0000
committerKarl Berry <karl@freefriends.org>2017-04-09 22:40:10 +0000
commit362b2fc01b04915a3706a78c8d7072a2c4265707 (patch)
treeb1c0ec08446f33c6a8caf2dcdf5a5cb70f5bfb1c /Master/texmf-dist/tex
parent07cc5c2480421e2ca1ca9fd8e58897a4c42dc0e7 (diff)
easyformat (9apr17)
git-svn-id: svn://tug.org/texlive/trunk@43724 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/easyformat/easyformat.sty152
1 files changed, 152 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/easyformat/easyformat.sty b/Master/texmf-dist/tex/latex/easyformat/easyformat.sty
new file mode 100644
index 00000000000..922d09abd46
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/easyformat/easyformat.sty
@@ -0,0 +1,152 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% easyformat Adds easier bolds and italics to LaTeX. %
+% Copyright (C) 2017 Evert Provoost <evert.provoost@gmail.com> %
+% %
+% This program is free software: you can redistribute it and/or modify %
+% it under the terms of the GNU General Public License as published by %
+% the Free Software Foundation, either version 3 of the License, or %
+% (at your option) any later version. %
+% %
+% This program is distributed in the hope that it will be useful, %
+% but WITHOUT ANY WARRANTY; without even the implied warranty of %
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %
+% GNU General Public License for more details. %
+% %
+% You should have received a copy of the GNU General Public License %
+% along with this program. If not, see <http://www.gnu.org/licenses/>. %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%% NOTE TO FUTURE: Italics correction works because of \maybe@ic.
+% this macro might disappear in LaTeX3...
+%
+% If the New Font Selection Scheme would change,
+% stuff WILL break...
+
+
+%% Administration...
+\NeedsTeXFormat{LaTeX2e} % Why no date? We'll leave that to the imports.
+\ProvidesPackage{easyformat}
+ [2017/04/09 v1.1.0 Adds easier bolds and italics.]
+
+
+%% Import this handy package
+\RequirePackage{ltxcmds}[2011/04/18]
+
+
+%% Public macros
+% Add macros to switch the syntax on or off.
+\newcommand*{\setundact}{
+ \catcode`\_=\active
+}
+
+\newcommand*{\setundsub}{
+ \catcode`\_=8
+}
+
+% Add some macros which do small parts of what \normalfont does.
+\newcommand*{\nrshape}{%
+ \fontshape{\shapedefault}%
+ \selectfont%
+}
+
+\newcommand*{\nrseries}{%
+ \fontseries{\seriesdefault}%
+ \selectfont%
+}
+
+
+%% CONSTANTS
+% Yes I could use \sb but that is a dependency...
+\let\EFOR@subscript=_
+
+% To test what style we're currently in.
+\def\EFOR@it{it}
+\def\EFOR@bf{bx}
+
+
+%% UTILS
+% So we can remove an unnecessary undescore when starting/stopping bold.
+\newcommand*{\EFOR@util@removeChar}[1]{}
+
+% Do the first when in mathmode, the second if not.
+\newcommand*{\EFOR@util@ifmmode}{%
+ \ifmmode
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+}
+
+% Do the first when equal, the second if not (first or second of
+% what comes *after* \EFOR@util@ifx{...}{...} that is).
+\newcommand*{\EFOR@util@ifx}[2]{%
+ \ifx#1#2\relax
+ \expandafter\@firstoftwo
+ \else
+ \expandafter\@secondoftwo
+ \fi
+}
+
+
+%% Formating handling
+% Switch italics on or off.
+\newcommand*{\EFOR@handle@italic}{%
+ \EFOR@util@ifx{\f@shape}{\EFOR@it}
+ % \maybe@ic adds italics correction if needed.
+ % (might stop working in LaTeX3?)
+ {\nrshape\maybe@ic}
+ {\itshape}%
+}
+
+% Switch boldface on or off.
+\newcommand*{\EFOR@handle@bold}{%
+ \EFOR@util@ifx{\f@series}{\EFOR@bf}
+ {\nrseries}
+ {\bfseries}%
+}
+
+
+%% Activate the systems!
+% Prepare the syntax in the preamble.
+\setundact
+
+% Now finally add the new syntax in the document part.
+\AtBeginDocument{
+ % Just to be sure
+ \setundact
+
+ % This is where the magic happens (also differentiates between
+ % the text and math mode.)
+ % It is \protected because it should work in eg. \section{}
+ \protected\def_{\EFOR@util@ifmmode
+ {\EFOR@subscript}
+ {\ltx@ifnextchar@nospace_
+ % \EFOR@util@removeChar removes the second underscore.
+ {\EFOR@handle@bold\EFOR@util@removeChar}
+ {\EFOR@handle@italic}%
+ }%
+ }
+}
+
+% Cleanup
+\AtEndDocument{
+ % Why no \def_\undefined?
+ % Because if we use this syntax in eg. \section{},
+ % the macro should still work in the .aux file...
+ \setundsub
+}
+
+
+%% DONE!
+\endinput
+
+
+%% IMPLEMENTATION DETAILS:
+%% Why not \textit/bf\bgroup and \egroup?
+% Well actualy that was the original solution. Hwoever this
+% doesn't differentiate between ending itallics or ending
+% boldface. The current solution does and this makes the syntax
+% more predictable and generally more useful. \ No newline at end of file