texlive[43901] Master/texmf-dist: easyformat (17apr17)

commits+karl at tug.org commits+karl at tug.org
Tue Apr 18 00:26:09 CEST 2017


Revision: 43901
          http://tug.org/svn/texlive?view=revision&revision=43901
Author:   karl
Date:     2017-04-18 00:26:09 +0200 (Tue, 18 Apr 2017)
Log Message:
-----------
easyformat (17apr17)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/easyformat/README
    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/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/easyformat/README	2017-04-17 22:25:54 UTC (rev 43900)
+++ trunk/Master/texmf-dist/doc/latex/easyformat/README	2017-04-17 22:26:09 UTC (rev 43901)
@@ -1,12 +1,14 @@
-easyformat is a package that allows the use of _ (the underscore) to add italics and bold text.
+easyformat is a package that allows the use of _ (the underscore)
+to add italics and bold text and ^ (the circumflex) to add smallcaps.
 
 Usage:
 Import the package with: \usepackage{easyformat}
 
 Now you can do the following in textmode:
-_italics_, __bold__, ___bolditalic___.
+_italics_, __bold__, ___bolditalic___ and ^smallcaps^.
 
-The underscore's (_) meaning in mathmode stays the same.
+The underscore's (_) and circumflex's (^) meaning in
+mathmode stay the same.
 
 (See easyformat.pdf for more info.)
 

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-04-17 22:25:54 UTC (rev 43900)
+++ trunk/Master/texmf-dist/doc/latex/easyformat/easyformat.tex	2017-04-17 22:26:09 UTC (rev 43901)
@@ -11,7 +11,7 @@
 \def\easyformat{\texttt{easyformat}}
 
 \title{\easyformat\\[.5em]
-		\large _the_ manual for the 2017/04/09 version (v1.1.0)}
+		\large _the_ manual for the 2017/04/17 version (v1.2.0)}
 
 \author{Evert Provoost}
 
@@ -22,10 +22,10 @@
 	\maketitle
 	
 	\begin{abstract}
-		\easyformat\ is a package that allows the use of~\_ to begin/end _italic_ or __bold__ formatting as an alternative to the standard \LaTeXe\ \verb|\textit{italic}| and/or \verb|\textbf{bold}|.
+		\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}|.
 	\end{abstract}
 
-	%\tableofcontents % NOT NEEDED
+	\tableofcontents
 	\newpage
 	
 	%% NOT NEEDED.
@@ -63,38 +63,63 @@
 		\verb|__Stop!__, you _have_ to wait!|
 	\end{quote}
 	
-	(Why underscores? See: \ref{Why?!})
+	(Why underscores? See: \ref{Why?!})\\
 	
+	And since it is good practice to add abbreviations using ^smallcaps^, \easyformat\ gives you \verb|^smallcaps^|.
+	
+	So:
+	\begin{quote}
+		\verb|^nasa^ and ^esa^ are probably the best known space agencies.|
+	\end{quote}
+
+	Results in:
+	\begin{quote}
+		^nasa^ and ^esa^ are probably the best known space agencies.
+	\end{quote}
+	
 	\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.
+	
+	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.
+	
+	\newpage
 
 	As already said, \easyformat\ uses a Markdown-like syntax, so:
 	
 	\begin{quote}
-		\verb|_italic,_ __bold,__ and ___bolditalic!___|
+		\verb|_italic,_ __bold,__, ___bolditalic___ and ^smallcaps!^|
 	\end{quote}
 
 	Gives:
 	\begin{quote}
-		_italic,_ __bold,__ and ___bolditalic!___
+		_italic,_ __bold,__, ___bolditalic___ and ^smallcaps!^
 	\end{quote}
 
 	However we can also do more complex stuff, eg.:
 	\begin{quote}
-		\verb|_Lorem __ipsum_ totalem__ da __givea _zin_ doram__ _zet_tim, liefkan.|
+		\verb|_Lorem __ipsum_ totalem__ ^da^ __givea _zin_ doram__ _zet_tim, liefkan.|
 	\end{quote}
 	
 	Becomes:
 	\begin{quote}
-		_Lorem __ipsum_ totalem__ da __givea _zin_ doram__ _zet_tim, liefkan.
+		_Lorem __ipsum_ totalem__ ^da^ __givea _zin_ doram__ _zet_tim, liefkan.
 	\end{quote}
 
-	Those with a good eye might have noticed that \easyformat\ adds italicscorrection when needed. Just like \verb|\textit{zet}tim| would have.
+	Those with a good eye might have noticed that \easyformat\ adds italics correction when needed. Just like \verb|\textit{zet}tim| would have.
 	
-	\section{Utilities}
-	%% This is solved in version 2017/04/09
+	\section{Troubleshooting}
+	\begin{quotation}
+		``For some or other reason I get some weird formatting\dots''
+	\end{quotation}
+
+	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.
+
+
+	%% This is solved in version 2017/04/09 v1.1.0
 	%\subsection{Underscore in subtitles\label{undtitles}}
 	%If you ever try something similar to \verb|\section{__Vectors:__ %$\vec{F}_g$}|: \TeX\ will shout at you. Why? I don't really know. However I %do know how to fix this. If we want to get the previous example we would use:
 	
@@ -108,18 +133,49 @@
 	
 	%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.)
 	
-	\subsection{\texttt{\textbackslash nrshape}}
-	Reverts the fontshape to the default.
+	\section{Macros}
+	\subsection{Special characters}
+	\noindent\fbox{\texttt{\textbackslash cir}}
+	Add the circumflex (\cir) character.
+
+	\subsection{Fonts}
+	\noindent\fbox{\texttt{\textbackslash nrfamily}}
+	Reverts the fontfamily to the default.\\
+
+	\noindent\fbox{\texttt{\textbackslash nrshape}}
+	Reverts the fontshape to the default.\\
+
+	\noindent\fbox{\texttt{\textbackslash nrseries}}
+	Reverts the fontseries to the default.\\
+
+	\noindent\fbox{\texttt{\textbackslash setffamily\{_fontfamily_\}}}
+	Quickly change the fontfamily.\\
+
+	\noindent\fbox{\texttt{\textbackslash setfshape\{_fontshape_\}}}
+	Quickly change the fontshape.\\
+
+	\noindent\fbox{\texttt{\textbackslash setfseries\{_fontseries_\}}}
+	Quickly change the fontseries.
 	
-	\subsection{\texttt{\textbackslash nrseries}}
-	Reverts the fontseries to the default.
+	\subsection{\easyformat\ syntax}
+	\noindent\fbox{\texttt{\textbackslash enableeasyformat}}
+	Enables the \easyformat\ syntax.\\
 	
-	\subsection{\texttt{\textbackslash setundact}}
-	Sets the catcode of \_ to 13 (active), effectively _(re-)enabling_ the \easyformat\ syntax.
+	\noindent\fbox{\texttt{\textbackslash disableeasyformat}}
+	Disables the \easyformat\ syntax.\\
 	
-	\subsection{\texttt{\textbackslash setundsub}}
-	Sets the catcode of \_ to 8 (subscript), effectively _disabling_ the \easyformat\ syntax.
+	\noindent\fbox{\texttt{\textbackslash setcaract}}
+	Sets the catcode of \cir\ to 13 (active).\\
 	
+	\noindent\fbox{\texttt{\textbackslash setcarsup}}
+	Sets the catcode of \cir\ to 7 (superscript).\\
+	
+	\noindent\fbox{\texttt{\textbackslash setundact}}
+	Sets the catcode of \_ to 13 (active).\\
+	
+	\noindent\fbox{\texttt{\textbackslash setundsub}}
+	Sets the catcode of \_ 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~*.
@@ -127,7 +183,7 @@
 	\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.)
 
-	\section{Contact}
+	\section{Contact\label{contact}}
 	If you want to make suggestions or have any questions whose answer could be included in a future version of this document, you can email to this address: \url{mailto:evert.provoost at gmail.com}
 	\newpage
 	
@@ -134,6 +190,9 @@
 	\section{Changelog}
 	We only include important changes from v1.0.0 onwards, since earlier versions barely worked.
 
+	\subsection*{2017/04/17 v1.2.0}
+	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).
 

Modified: trunk/Master/texmf-dist/tex/latex/easyformat/easyformat.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/easyformat/easyformat.sty	2017-04-17 22:25:54 UTC (rev 43900)
+++ trunk/Master/texmf-dist/tex/latex/easyformat/easyformat.sty	2017-04-17 22:26:09 UTC (rev 43901)
@@ -1,35 +1,38 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%                                                                       %
-% easyformat  Adds easier bolds and italics to LaTeX.                   %
-% Copyright (C) 2017  Evert Provoost <evert.provoost at 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/>. %
-%                                                                       %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                         %
+%  easyformat  Easily add boldface, italics and smallcaps in LaTeX.       %
+%  Copyright (C) 2017  Evert Provoost <evert.provoost at 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 at ic.
 %                  this macro might disappear in LaTeX3...
 %
-%                  If the New Font Selection Scheme would change,
+%                  If the 'New Font Selection Scheme' would change,
 %                  stuff WILL break...
 
 
+%% TODO: Rewrite to use expl3 so it'll be easier to switch to LaTeX3.
+
+
 %% 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.]
+	[2017/04/17 v1.2.0 Easily add boldface, italics and smallcaps.]
 
 
 %% Import this handy package
@@ -46,27 +49,74 @@
 	\catcode`\_=8
 }
 
+\newcommand*{\setciract}{
+	\catcode`\^=\active
+}
+
+\newcommand*{\setcirsup}{
+	\catcode`\^=7
+}
+
+\newcommand*{\enableeasyformat}{
+	\setundact
+	\setciract
+}
+
+\newcommand*{\disableeasyformat}{
+	\setundsub
+	\setcirsup
+}
+
+% Add macros which change the fontshape, fontseries and fontfamily.
+\newcommand*{\setffamily}[1]{%
+	\fontfamily{#1}%
+	\selectfont%
+}
+
+\newcommand*{\setfshape}[1]{%
+	\fontshape{#1}%
+	\selectfont%
+}
+
+\newcommand*{\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}%
+}
+
 \newcommand*{\nrshape}{%
-	\fontshape{\shapedefault}%
-	\selectfont%
+	\setfshape{\shapedefault}%
 }
 
 \newcommand*{\nrseries}{%
-	\fontseries{\seriesdefault}%
-	\selectfont%
+	\setfseries{\seriesdefault}%
 }
 
+% Add a macro LaTeX should have...
+\newcommand*{\cir}{\string^\relax}
 
+
 %% CONSTANTS
-% Yes I could use \sb but that is a dependency...
+% Yes I could use \sb and \sp but those are dependencies...
 \let\EFOR at subscript=_
+\let\EFOR at superscript=^
 
 % 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.
 
+
 %% UTILS
 % So we can remove an unnecessary undescore when starting/stopping bold.
 \newcommand*{\EFOR at util@removeChar}[1]{}
@@ -81,7 +131,7 @@
 }
 
 % Do the first when equal, the second if not (first or second of
-% what comes *after* \EFOR at util@ifx{...}{...} that is).
+% what comes _after_ \EFOR at util@ifx{...}{...} that is).
 \newcommand*{\EFOR at util@ifx}[2]{%
 	\ifx#1#2\relax
 		\expandafter\@firstoftwo
@@ -93,30 +143,53 @@
 
 %% Formating handling
 % Switch italics on or off.
-\newcommand*{\EFOR at handle@italic}{%
+\newcommand*{\EFOR at handle@italics}{%
 	\EFOR at util@ifx{\f at shape}{\EFOR at it}
-	% \maybe at ic adds italics correction if needed.
-	% (might stop working in LaTeX3?)
-	{\nrshape\maybe at ic}
-	{\itshape}%
+	{%
+		\setfshape{\EFOR at prev@shape at it}%
+		\edef\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%
+	}%
 }
 
+% 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%
+	}%
+}
+
 % Switch boldface on or off.
-\newcommand*{\EFOR at handle@bold}{%
+\newcommand*{\EFOR at handle@boldface}{%
 	\EFOR at util@ifx{\f at series}{\EFOR at bf}
-	{\nrseries}
-	{\bfseries}%
+	{%
+		\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%
+	}%
 }
 
 
 %% Activate the systems!
 % Prepare the syntax in the preamble.
-\setundact
+\enableeasyformat
 
 % Now finally add the new syntax in the document part.
 \AtBeginDocument{
 	% Just to be sure
-	\setundact
+	\enableeasyformat
 	
 	% This is where the magic happens (also differentiates between
 	% the text and math mode.)
@@ -125,18 +198,23 @@
 		{\EFOR at subscript}
 		{\ltx at ifnextchar@nospace_
 			% \EFOR at util@removeChar removes the second underscore.
-			{\EFOR at handle@bold\EFOR at util@removeChar}
-			{\EFOR at handle@italic}%
+			{\EFOR at handle@boldface\EFOR at util@removeChar}
+			{\EFOR at handle@italics}%
 		}%
 	}
+
+	\protected\def^{\EFOR at util@ifmmode
+		{\EFOR at superscript}
+		{\EFOR at handle@smallcaps}%
+	}
 }
 
 % Cleanup
 \AtEndDocument{
-	% Why no \def_\undefined?
+	% Why no \def_\undefined and \def^\undefined?
 	% Because if we use this syntax in eg. \section{},
 	% the macro should still work in the .aux file...
-	\setundsub
+	\disableeasyformat
 }
 
 
@@ -145,7 +223,7 @@
 
 
 %% IMPLEMENTATION DETAILS:
-%% Why not \textit/bf\bgroup and \egroup?
+%% Why not \textit/bf/sc\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 information about the tex-live-commits mailing list