texlive[44486] Master/texmf-dist: easyformat (29may17)

commits+karl at tug.org commits+karl at tug.org
Tue Jun 6 01:19:32 CEST 2017


Revision: 44486
          http://tug.org/svn/texlive?view=revision&revision=44486
Author:   karl
Date:     2017-06-06 01:19:32 +0200 (Tue, 06 Jun 2017)
Log Message:
-----------
easyformat (29may17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/easyformat/easyformat.pdf
    trunk/Master/texmf-dist/doc/latex/easyformat/easyformat.tex
    trunk/Master/texmf-dist/tex/latex/easyformat/easyformat.sty

Modified: trunk/Master/texmf-dist/doc/latex/easyformat/easyformat.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/latex/easyformat/easyformat.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/easyformat/easyformat.tex	2017-06-05 23:19:00 UTC (rev 44485)
+++ trunk/Master/texmf-dist/doc/latex/easyformat/easyformat.tex	2017-06-05 23:19:32 UTC (rev 44486)
@@ -11,7 +11,7 @@
 \def\easyformat{\texttt{easyformat}}
 
 \title{\easyformat\\[.5em]
-		\large _the_ manual for the 2017/04/17 version (v1.2.0)}
+		\large _the_ manual for the 2017/05/28 version (v1.3.0)}
 
 \author{Evert Provoost}
 
@@ -22,7 +22,7 @@
 	\maketitle
 	
 	\begin{abstract}
-		\easyformat\ is a package that allows the use of~\_ to begin/end _italic_ or __bold__ and \cir\ to begin/end ^smallcaps^. As an alternative to the standard \LaTeXe\ \verb|\textit{italic}|, \verb|\textbf{bold}| and \verb|\textsc{smallcaps}|.
+		\easyformat\ is a package that allows the use of~\verb|_| to begin/end _italic_ or __bold__ and \verb|^| to begin/end ^smallcaps^. As an alternative to the standard \LaTeX\ \verb|\textit{italic}|, \verb|\textbf{bold}| and \verb|\textsc{smallcaps}|.
 	\end{abstract}
 
 	\tableofcontents
@@ -80,9 +80,9 @@
 	\section{Usage, syntax and examples}
 	Like usual you import the package with: \verb|\usepackage{easyformat}|
 
-	\easyformat\ makes \_ an active character, however it was already 'special' before so you still have to type~\verb|\_| if you want to insert an underscore.
+	\easyformat\ makes \verb|_| an active character, however it was already `special' before so you still have to type~\verb|\_| if you want to insert an underscore.
 	
-	The same can be said of \cir, however since this one is difficult to add in ordinary \LaTeX, the \easyformat\ package gives you \verb|\cir| to get \cir.
+	The same can be said of \verb|^|, however since this one is difficult to add in ordinary \LaTeX, the \easyformat\ package gives you \verb|\cir| to get \cir.
 	
 	\newpage
 
@@ -110,6 +110,8 @@
 	Those with a good eye might have noticed that \easyformat\ adds italics correction when needed. Just like \verb|\textit{zet}tim| would have.
 	
 	\section{Troubleshooting}
+	\easyformat\ tends to conflict with the loading of other packages, therefore you should probably load \easyformat\ last.
+	
 	\begin{quotation}
 		``For some or other reason I get some weird formatting\dots''
 	\end{quotation}
@@ -116,7 +118,7 @@
 
 	It could be a bug---in which case I'd love to hear from you (see \ref{contact})---however, you probably forgot to close your formatting somewhere and because of how \easyformat\ works you can get weird results.
 
-	%__Explanation:__ when you start eg. _italics_ with \_, \easyformat\ %remembers the shape (the same is true for ^smallcaps^, when you %start __boldface__ it remembers the series) of the font. When you %get out of _italics_, it resets the shape (respectively the series) %to what it was before the starting the formatting.
+	%__Explanation:__ when you start eg. _italics_ with \verb|_|, \easyformat\ %remembers the shape (the same is true for ^smallcaps^, when you %start __boldface__ it remembers the series) of the font. When you %get out of _italics_, it resets the shape (respectively the series) %to what it was before the starting the formatting.
 
 
 	%% This is solved in version 2017/04/09 v1.1.0
@@ -131,12 +133,12 @@
 	%	\hspace*{0pt}\verb|\setundact|
 	%\end{quote}
 	
-	%This first resets the \_ character so it can only be used as the start of %subscripts; then adds the subtitle and afterwards re-initiates \_ for %__bold__ and _italic_. (Obviously the \easyformat\ syntax does not work %_in_ the subtitle, so you'll have to use the \LaTeX-commands.)
+	%This first resets the \verb|_| character so it can only be used as the start of %subscripts; then adds the subtitle and afterwards re-initiates \verb|_| for %__bold__ and _italic_. (Obviously the \easyformat\ syntax does not work %_in_ the subtitle, so you'll have to use the \LaTeX-commands.)
 	
 	\section{Macros}
 	\subsection{Special characters}
 	\noindent\fbox{\texttt{\textbackslash cir}}
-	Add the circumflex (\cir) character.
+	Insert a circumflex (\cir) character.
 
 	\subsection{Fonts}
 	\noindent\fbox{\texttt{\textbackslash nrfamily}}
@@ -164,21 +166,21 @@
 	\noindent\fbox{\texttt{\textbackslash disableeasyformat}}
 	Disables the \easyformat\ syntax.\\
 	
-	\noindent\fbox{\texttt{\textbackslash setcaract}}
-	Sets the catcode of \cir\ to 13 (active).\\
+	\noindent\fbox{\texttt{\textbackslash setciract}}
+	Sets the catcode of \verb|^| to 13 (active).\\
 	
-	\noindent\fbox{\texttt{\textbackslash setcarsup}}
-	Sets the catcode of \cir\ to 7 (superscript).\\
+	\noindent\fbox{\texttt{\textbackslash setcirsup}}
+	Sets the catcode of \verb|^| to 7 (superscript).\\
 	
 	\noindent\fbox{\texttt{\textbackslash setundact}}
-	Sets the catcode of \_ to 13 (active).\\
+	Sets the catcode of \verb|_| to 13 (active).\\
 	
 	\noindent\fbox{\texttt{\textbackslash setundsub}}
-	Sets the catcode of \_ to 8 (subscript).
+	Sets the catcode of \verb|_| to 8 (subscript).
 	
 	\section{Technical details}
-	\subsection{Why \_ and not *?\label{Why?!}}
-	To make * work we would have to make it an active character, however this would break things like \verb|\section*{Art}|. The~\_ is already protected by \TeX\ because of it's meaning in mathmode. However, it has little to no use in textmode. This is why we can use~\_ for this purpose and not~*.
+	\subsection{Why \texttt{\_} and not *?\label{Why?!}}
+	To make * work we would have to make it an active character, however this would break things like \verb|\section*{Art}|. The~\verb|_| is already protected by \TeX\ because of it's meaning in mathmode. However, it has little to no use in textmode. This is why we can use~\verb|_| for this purpose and not~*.
 	
 	\subsection{Does this break mathmode?}
 	No it doesn't. It keeps behaving like before in mathmode, it's meaning only changes in textmode. (We first check whether we are in mathmode or not and behave accordingly.)
@@ -190,8 +192,15 @@
 	\section{Changelog}
 	We only include important changes from v1.0.0 onwards, since earlier versions barely worked.
 
+	\subsection*{2017/05/28 v1.3.0}
+	Removed forced re-enabling of the \easyformat-syntax at the start of the document.
+	Rewritten to use \texttt{expl3}, this makes the code shorter and a future move to \LaTeX3 easier.
+	Fixed an error that could occur with \verb|\cir|.
+	\easyformat\ now also behaves correctly when a fontpackage is loaded.
+
 	\subsection*{2017/04/17 v1.2.0}
-	Improved handling of mixed styles. Added \verb|^smallcaps^| for ^smallcaps^.
+	Improved handling of mixed styles.
+	Added \verb|^smallcaps^| for ^smallcaps^.
 
 	\subsection*{2017/04/09 v1.1.0}
 	Made usage of syntax in \verb|\section{}|, and similar macros, possible. Changed the behaviour so it works more like \verb|\emph{}| (this also simplifies the code).
@@ -199,7 +208,6 @@
 	\subsection*{2017/04/07 v1.0.0}
 	First stable version.
 
-
 	% Insert a friendly message :)
 	\vspace*{\fill}\noindent
 	Made with $\heartsuit$ in Berlaar, Belgium.

Modified: trunk/Master/texmf-dist/tex/latex/easyformat/easyformat.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/easyformat/easyformat.sty	2017-06-05 23:19:00 UTC (rev 44485)
+++ trunk/Master/texmf-dist/tex/latex/easyformat/easyformat.sty	2017-06-05 23:19:32 UTC (rev 44486)
@@ -19,197 +19,187 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
-%% NOTE TO FUTURE: Italics correction works because of \maybe at ic.
-%                  this macro might disappear in LaTeX3...
+%% NOTE TO FUTURE: Italics correction works because of \maybe at ic,
+%                  this macro might become \xfss_maybe_ic: in LaTeX3
 %
-%                  If the 'New Font Selection Scheme' would change,
-%                  stuff WILL break...
+%                  In LaTeX3 the `New Font Selection Scheme' is replaced
+%                  by xfss (xfont). Moving will require some research.
 
 
-%% TODO: Rewrite to use expl3 so it'll be easier to switch to LaTeX3.
+%% WAIT! This package doesn't use the LaTeX3 naming conventions?!
+%      Yeah, since we make _ an active character, we can't. Sorry.
 
 
 %% Administration...
-\NeedsTeXFormat{LaTeX2e} % Why no date? We'll leave that to the imports.
-\ProvidesPackage{easyformat}
-	[2017/04/17 v1.2.0 Easily add boldface, italics and smallcaps.]
+\RequirePackage{expl3}[2015/11/11]
+\ProvidesExplPackage
+	{easyformat}
+	{2017/05/28}
+	{1.3.0}
+	{Easily add boldface, italics and smallcaps.}
 
 
-%% Import this handy package
-\RequirePackage{ltxcmds}[2011/04/18]
-
-
 %% Public macros
 % Add macros to switch the syntax on or off.
-\newcommand*{\setundact}{
-	\catcode`\_=\active
+\cs_new:Npn \setundact {
+	\char_set_catcode_active:N {\_}
 }
 
-\newcommand*{\setundsub}{
-	\catcode`\_=8
+\cs_new:Npn \setundsub {
+	\char_set_catcode_math_subscript:N {\_}
 }
 
-\newcommand*{\setciract}{
-	\catcode`\^=\active
+\cs_new:Npn \setciract {
+	\char_set_catcode_active:N {\^}
 }
 
-\newcommand*{\setcirsup}{
-	\catcode`\^=7
+\cs_new:Npn \setcirsup {
+	\char_set_catcode_math_superscript:N {\^}
 }
 
-\newcommand*{\enableeasyformat}{
+\cs_new:Npn \enableeasyformat {
 	\setundact
 	\setciract
 }
 
-\newcommand*{\disableeasyformat}{
+\cs_new:Npn \disableeasyformat {
 	\setundsub
 	\setcirsup
 }
 
 % Add macros which change the fontshape, fontseries and fontfamily.
-\newcommand*{\setffamily}[1]{%
-	\fontfamily{#1}%
-	\selectfont%
+\cs_new:Npn \setffamily #1 {
+	\fontfamily{#1}
+	\selectfont
 }
 
-\newcommand*{\setfshape}[1]{%
-	\fontshape{#1}%
-	\selectfont%
+\cs_new:Npn \setfshape #1 {
+	\fontshape{#1}
+	\selectfont
 }
 
-\newcommand*{\setfseries}[1]{%
-	\fontseries{#1}%
-	\selectfont%
+\cs_new:Npn \setfseries #1 {
+	\fontseries{#1}
+	\selectfont
 }
 
 % Add some macros which do small parts of what \normalfont does.
 % Were needed in v1.1.0 but let's keep them because they are useful :)
-\newcommand*{\nrfamily}{%
-	\setffamily{\familydefault}%
+\cs_new:Npn \nrfamily {
+	\setffamily {\familydefault}
 }
 
-\newcommand*{\nrshape}{%
-	\setfshape{\shapedefault}%
+\cs_new:Npn \nrshape {
+	\setfshape {\shapedefault}
 }
 
-\newcommand*{\nrseries}{%
-	\setfseries{\seriesdefault}%
+\cs_new:Npn \nrseries {
+	\setfseries {\seriesdefault}
 }
 
 % Add a macro LaTeX should have...
-\newcommand*{\cir}{\string^\relax}
+% The protected to fix the double superscript error.
+\cs_new_protected:Npn \cir {\char_generate:nn {`^} {12}}
 
 
-%% CONSTANTS
+%% Constants & Variables
 % Yes I could use \sb and \sp but those are dependencies...
-\let\EFOR at subscript=_
-\let\EFOR at superscript=^
+\tl_const:Nx \EFOR at subscript   {\char_generate:nn {`_} {8}}
+\tl_const:Nx \EFOR at superscript {\char_generate:nn {`^} {7}}
 
-% To test what style we're currently in.
-\def\EFOR at it{it}
-\def\EFOR at sc{sc}
-\def\EFOR at bf{bx}
-
 % Remember the style before changing to italics/boldface/smallcaps.
-\edef\EFOR at prev@shape at it{\shapedefault}   % Used by italics.
-\edef\EFOR at prev@shape at sc{\shapedefault}   % Used by smallcaps.
-\edef\EFOR at prev@series at bf{\seriesdefault} % Used by boldface.
+\str_new:N \EFOR at prev@shape at it
+\str_new:N \EFOR at prev@shape at sc
+\str_new:N \EFOR at prev@series at bf
+\str_set:Nx \EFOR at prev@shape at it  {\shapedefault}  % Used by italics.
+\str_set:Nx \EFOR at prev@shape at sc  {\shapedefault}  % Used by smallcaps.
+\str_set:Nx \EFOR at prev@series at bf {\seriesdefault} % Used by boldface.
 
 
-%% UTILS
-% So we can remove an unnecessary undescore when starting/stopping bold.
-\newcommand*{\EFOR at util@removeChar}[1]{}
-
-% Do the first when in mathmode, the second if not.
-\newcommand*{\EFOR at 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 at util@ifx{...}{...} that is).
-\newcommand*{\EFOR at util@ifx}[2]{%
-	\ifx#1#2\relax
-		\expandafter\@firstoftwo
-	\else
-		\expandafter\@secondoftwo
-	\fi
-}
-
-
 %% Formating handling
 % Switch italics on or off.
-\newcommand*{\EFOR at handle@italics}{%
-	\EFOR at util@ifx{\f at shape}{\EFOR at it}
-	{%
-		\setfshape{\EFOR at prev@shape at it}%
-		\edef\EFOR at prev@shape at it{\shapedefault}%
+\cs_new:Npn \EFOR at handle@italics {
+	\str_if_eq:NNTF \f at shape \itdefault
+	{
+		\setfshape {\EFOR at prev@shape at it}
+		\str_set:Nx \EFOR at prev@shape at it {\shapedefault}
 		% \maybe at ic adds italics correction if needed.
 		% (might stop working in LaTeX3?)
-		\maybe at ic%
-	}{%
-		\edef\EFOR at prev@shape at it{\f at shape}%
-		\itshape%
-	}%
+		\maybe at ic
+	}{
+		\str_set:Nx \EFOR at prev@shape at it {\f at shape}
+		\itshape
+	}
 }
 
 % Switch smallcaps on or off.
-\newcommand*{\EFOR at handle@smallcaps}{%
-	\EFOR at util@ifx{\f at shape}{\EFOR at sc}
-	{%
-		\setfshape{\EFOR at prev@shape at sc}%
-		\edef\EFOR at prev@shape at sc{\shapedefault}%
-	}{%
-		\edef\EFOR at prev@shape at sc{\f at shape}%
-		\scshape%
-	}%
+\cs_new:Npn \EFOR at handle@smallcaps {
+	\str_if_eq:NNTF \f at shape \scdefault
+	{
+		\setfshape {\EFOR at prev@shape at sc}
+		\str_set:Nx \EFOR at prev@shape at sc {\shapedefault}
+	}{
+		\str_set:Nx \EFOR at prev@shape at sc {\f at shape}
+		\scshape
+	}
 }
 
 % Switch boldface on or off.
-\newcommand*{\EFOR at handle@boldface}{%
-	\EFOR at util@ifx{\f at series}{\EFOR at bf}
-	{%
-		\setfseries{\EFOR at prev@series at bf}%
-		\edef\EFOR at prev@series at bf{\seriesdefault}%
-	}{%
-		\edef\EFOR at prev@series at bf{\f at series}%
-		\bfseries%
-	}%
+\cs_new:Npn \EFOR at handle@boldface {
+	\str_if_eq:NNTF \f at series \bfdefault
+	{
+		\setfseries {\EFOR at prev@series at bf}
+		\str_set:Nx \EFOR at prev@series at bf {\seriesdefault}
+	}{
+		\str_set:Nx \EFOR at prev@series at bf {\f at series}
+		\bfseries
+	}
 }
 
 
+%% Aliases fo expl3
+% Make aliases for some LaTeX3 macros as _ isn't allowed later on.
+\let\Expl at mode@if at math\mode_if_math:TF
+\let\Expl at cs@gset at protected\cs_gset_protected:Npn
+\let\Expl at peek@meaning at remove\peek_meaning_remove:NTF
+
+
 %% Activate the systems!
-% Prepare the syntax in the preamble.
+% First disable the Expl3 syntax as it will only cause trouble.
+\ExplSyntaxOff
+
+% Now enable the easyformat syntax.
 \enableeasyformat
 
 % Now finally add the new syntax in the document part.
 \AtBeginDocument{
-	% Just to be sure
-	\enableeasyformat
+	% We do not re-enable easyformat here, since that could
+	% cause unexpected behaviour. We tested if this causes errors.
 	
+	% NOTE: for some reason we have to use gset instead of new, no
+	%       idea why though...
+	
 	% 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 at util@ifmmode
+	% It is protected because it should work in eg. \section{}
+
+	\Expl at cs@gset at protected_{\Expl at mode@if at math
 		{\EFOR at subscript}
-		{\ltx at ifnextchar@nospace_
-			% \EFOR at util@removeChar removes the second underscore.
-			{\EFOR at handle@boldface\EFOR at util@removeChar}
+		{\Expl at peek@meaning at remove_
+			% The second underscore is removed when true.
+			{\EFOR at handle@boldface}
 			{\EFOR at handle@italics}%
 		}%
 	}
 
-	\protected\def^{\EFOR at util@ifmmode
+	\Expl at cs@gset at protected^{\Expl at mode@if at math
 		{\EFOR at superscript}
 		{\EFOR at handle@smallcaps}%
 	}
 }
 
-% Cleanup
+
+%% Cleanup aka: Disable the systems!
 \AtEndDocument{
 	% Why no \def_\undefined and \def^\undefined?
 	% Because if we use this syntax in eg. \section{},
@@ -219,12 +209,13 @@
 
 
 %% DONE!
-\endinput
+% Unfortunately we can't add a \disableeasyformat here,
+% since that breaks more stuff than it fixes...
 
 
 %% IMPLEMENTATION DETAILS:
 %% Why not \textit/bf/sc\bgroup and \egroup?
-%      Well actualy that was the original solution. Hwoever this
+%      Well actualy that was the original solution. However 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



More information about the tex-live-commits mailing list