From 3223dc8b31952693cb552ebf58bf7b25abd0264f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 27 Oct 2016 21:22:59 +0000 Subject: latexindent (27oct16) git-svn-id: svn://tug.org/texlive/trunk@42366 c570f23f-e606-0410-a88d-b1316a301751 --- .../latexindent/documentation/latexindent.pdf | Bin 0 -> 280224 bytes .../latexindent/documentation/latexindent.tex | 1512 ++++++++++++++++++++ .../support/latexindent/documentation/manual.pdf | Bin 237320 -> 0 bytes .../support/latexindent/documentation/manual.tex | 1247 ---------------- .../success/alignmentoutsideEnvironments.tex | 24 +- .../doc/support/latexindent/success/braceTest.tex | 2 +- .../support/latexindent/success/bracketTest.tex | 6 + .../support/latexindent/success/environments.tex | 4 +- .../support/latexindent/success/filecontents1.tex | 18 + .../support/latexindent/success/filecontents2.tex | 21 + .../support/latexindent/success/ifelsefiSmall.tex | 10 + .../doc/support/latexindent/success/items1.tex | 10 + .../doc/support/latexindent/success/items2.tex | 21 + .../doc/support/latexindent/success/items3.tex | 22 + .../doc/support/latexindent/success/items4.tex | 22 + .../doc/support/latexindent/success/matrix.tex | 2 +- .../latexindent/success/nestedalignment.tex | 4 +- .../latexindent/success/nestedalignment1.tex | 2 +- .../doc/support/latexindent/success/outputfile.tex | 2 +- .../support/latexindent/success/sampleAFTER.tex | 510 +++---- .../support/latexindent/success/sampleBEFORE.tex | 510 +++---- .../doc/support/latexindent/success/stylefile.tex | 152 +- .../doc/support/latexindent/success/table4.tex | 22 + .../doc/support/latexindent/success/table5.tex | 35 + .../latexindent/success/testHeadings-simple.tex | 56 + .../doc/support/latexindent/success/testItems.tex | 2 +- .../doc/support/latexindent/success/testcls.cls | 78 +- .../doc/support/latexindent/success/theorem.tex | 4 +- .../doc/support/latexindent/success/verbatim1.tex | 21 + 29 files changed, 2428 insertions(+), 1891 deletions(-) create mode 100644 Master/texmf-dist/doc/support/latexindent/documentation/latexindent.pdf create mode 100644 Master/texmf-dist/doc/support/latexindent/documentation/latexindent.tex delete mode 100644 Master/texmf-dist/doc/support/latexindent/documentation/manual.pdf delete mode 100644 Master/texmf-dist/doc/support/latexindent/documentation/manual.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/bracketTest.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/filecontents1.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/filecontents2.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/ifelsefiSmall.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/items1.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/items2.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/items3.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/items4.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/table4.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/table5.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/testHeadings-simple.tex create mode 100644 Master/texmf-dist/doc/support/latexindent/success/verbatim1.tex (limited to 'Master/texmf-dist/doc/support') diff --git a/Master/texmf-dist/doc/support/latexindent/documentation/latexindent.pdf b/Master/texmf-dist/doc/support/latexindent/documentation/latexindent.pdf new file mode 100644 index 00000000000..4ac36f075da Binary files /dev/null and b/Master/texmf-dist/doc/support/latexindent/documentation/latexindent.pdf differ diff --git a/Master/texmf-dist/doc/support/latexindent/documentation/latexindent.tex b/Master/texmf-dist/doc/support/latexindent/documentation/latexindent.tex new file mode 100644 index 00000000000..c39b89e627e --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/documentation/latexindent.tex @@ -0,0 +1,1512 @@ +% arara: pdflatex +% arara: bibtex +% arara: pdflatex +% arara: pdflatex +% !arara: pdflatex +% !arara: indent: {overwrite: yes, trace: yes, localSettings: yes, silent: yes} +\documentclass[11pt]{article} +% 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. +% +% See . +\usepackage[left=4.5cm,right=2.5cm,showframe=false, +top=2cm,bottom=1.5cm]{geometry} % page setup +\usepackage{parskip} % paragraph skips +\usepackage{booktabs} % beautiful tables +\usepackage{listings} % nice verbatim environments +\usepackage{titlesec} % customize headings +\usepackage{changepage} % adjust width of page +\usepackage{fancyhdr} % headers & footers +\usepackage[sc,format=hang,font=small]{caption} % captions +\usepackage[backend=bibtex]{biblatex} % bibliography +\usepackage{tcolorbox} % framed environments +\usepackage[charter]{mathdesign} % changes font +\usepackage[expansion=false,kerning=true]{microtype} % better kerning +\usepackage{enumitem} % custom lists +% setup gitinfo2, as in the manual, details just above begin{document} +\usepackage[mark,grumpy]{gitinfo2} +\usepackage{examplep} +% tcolorbox libraries +\tcbuselibrary{breakable,skins,listings} +% tikz libraries +\usetikzlibrary{positioning} +\usetikzlibrary{decorations.pathmorphing} +\usetikzlibrary{decorations,shapes} +\usepackage{varioref} % clever referencing +\usepackage{hyperref} +\hypersetup{ + pdfauthor={Chris Hughes}, + pdftitle={latexindent.pl package}, + pdfkeywords={perl;beautify;indentation}, + bookmarksnumbered, + bookmarksopen, + linktocpage, + colorlinks=true, + linkcolor=blue, + citecolor=black, +} +\usepackage{cleveref} + +\addbibresource{latex-indent} +\addbibresource{contributors} + + +% http://tex.stackexchange.com/questions/122135/how-to-add-a-png-icon-on-the-right-side-of-a-tcolorbox-title +\newtcolorbox{warning}{parbox=false,breakable,enhanced,arc=0mm,colback=red!5,colframe=red,leftrule=12mm,% + overlay={\node[anchor=north west,outer sep=2pt] at (frame.north west) {\includegraphics[width=8mm]{warning}}; }} + +\makeatletter +\tcbset{ + addtolol/.style={list entry={\kvtcb@title},add to list={lol}{lstlisting}}, +} + +\newtcblisting[use counter=lstlisting]{cmhlistings}[3][]{% + width=\linewidth, + breakable, + colback=blue!5!white, + colframe=white!85!black, + top=0cm, + bottom=0cm, + left=6mm, + listing only, + listing options={#1}, + center title, + title={\color{black}{\scshape Listing \thetcbcounter}: ~#2},label={#3}, + addtolol, +} + +\lstset{% + basicstyle=\small\ttfamily,language={[LaTeX]TeX}, + % numbers=left, + numberstyle=\ttfamily%\small, + breaklines=true, + % frame=single,framexleftmargin=8mm, xleftmargin=8mm, + % prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookrightarrow}}, + % backgroundcolor=\color{green!5},frameround=fttt, + % rulecolor=\color{blue!70!black}, + keywordstyle=\color{blue}, % keywords + commentstyle=\color{purple}, % comments + tabsize=3, + %xleftmargin=1.5em, +}% +\lstdefinestyle{yaml}{% + numbers=left, + numberstyle=\color{black},} +\lstdefinestyle{demo}{ + numbers=none, + linewidth=1.25\textwidth, + columns=fullflexible, +} + +% stars around contributors +\pgfdeclaredecoration{stars}{initial}{ + \state{initial}[width=15pt] + { + \pgfmathparse{round(rnd*100)} + \pgfsetfillcolor{yellow!\pgfmathresult!orange} + \pgfsetstrokecolor{yellow!\pgfmathresult!red} + \pgfnode{star}{center}{}{}{\pgfusepath{stroke,fill}} + } + \state{final} + { + \pgfpathmoveto{\pgfpointdecoratedpathlast} + } +} + +\newtcolorbox{stars}{% + enhanced jigsaw, + breakable, % allow page breaks + left=0cm, + top=0cm, + before skip=0.2cm, + boxsep=0cm, + frame style={draw=none,fill=none}, % hide the default frame + colback=white, + overlay={ + \draw[inner sep=0,minimum size=rnd*15pt+2pt] + decorate[decoration={stars,segment length=2cm}] { + decorate[decoration={zigzag,segment length=2cm,amplitude=0.3cm}] { + ([xshift=-.5cm,yshift=0.1cm]frame.south west) -- ([xshift=-.5cm,yshift=0.4cm]frame.north west) + }}; + \draw[inner sep=0,minimum size=rnd*15pt+2pt] + decorate[decoration={stars,segment length=2cm}] { + decorate[decoration={zigzag,segment length=2cm,amplitude=0.3cm}] { + ([xshift=.75cm,yshift=0.1cm]frame.south east) -- ([xshift=.75cm,yshift=0.6cm]frame.north east) + }}; + }, + % paragraph skips obeyed within tcolorbox + parbox=false, +} + +% copied from /usr/local/texlive/2013/texmf-dist/tex/latex/biblatex/bbx/numeric.bbx +% the only modification is the \stars and \endstars +\defbibenvironment{specialbib} +{\stars\list + {\printtext[labelnumberwidth]{% + \printfield{prefixnumber}% + \printfield{labelnumber}}} + {\setlength{\labelwidth}{\labelnumberwidth}% + \setlength{\leftmargin}{\labelwidth}% + \setlength{\labelsep}{\biblabelsep}% + \addtolength{\leftmargin}{\labelsep}% + \setlength{\itemsep}{\bibitemsep}% + \setlength{\parsep}{\bibparsep}}% + \renewcommand*{\makelabel}[1]{\hss##1}} +{\endlist\endstars} +{\item} + +% see: http://tex.stackexchange.com/questions/2245/verbatim-description-list-item +\newcommand{\verbitem}[1]{\small\PVerb{#1}} +% stolen from arara.sty http://mirrors.med.harvard.edu/ctan/support/arara/doc/arara.sty +%\lstnewenvironment{yaml}[1][]{\lstset{% +% basicstyle=\ttfamily, +% numbers=left, +% xleftmargin=1.5em, +% breaklines=true, +% numberstyle=\ttfamily\small, +% columns=flexible, +% mathescape=false, +% #1, +%}} +%{} + +\newcommand{\fixthis}[1] +{% + \marginpar{\huge \color{red} \framebox{FIX}}% + \typeout{FIXTHIS: p\thepage : #1^^J}% +} +% custom section +\titleformat{\section} +{\normalfont\Large\bfseries} +{\llap{\thesection\hskip.5cm}} +{0pt} +{} +% custom subsection +\titleformat{\subsection} +{\normalfont\bfseries} +{\llap{\thesubsection\hskip.5cm}} +{0pt} +{} +% custom subsubsection +\titleformat{\subsubsection} +{\normalfont\bfseries} +{\llap{\thesubsubsection\hskip.5cm}} +{0pt} +{} + + +\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{-5pt plus 2pt minus 2pt} +\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt} +\titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt} + + +% cleveref settings +\crefname{table}{Table}{Tables} +\Crefname{table}{Table}{Tables} +\crefname{figure}{Figure}{Figures} +\Crefname{figure}{Figure}{Figures} +\crefname{section}{Section}{Sections} +\Crefname{section}{Section}{Sections} +\crefname{listing}{Listing}{Listings} +\Crefname{listing}{Listing}{Listings} + +% headers and footers +\fancyhf{} % delete current header and footer +\fancyhead[R]{\bfseries\thepage} +\fancyheadoffset[L]{3cm} +\pagestyle{fancy} + +% renew plain style +\fancypagestyle{plain}{% +\fancyhf{} % clear all header and footer fields +\renewcommand{\headrulewidth}{0pt} +\renewcommand{\footrulewidth}{0pt}} + +% sidebyside environment +\newenvironment{sidebyside}{\begin{adjustwidth}{-3cm}{1cm}}{\end{adjustwidth}} + +% gitinfo2 settings +\renewcommand{\gitMark}{\gitBranch\,@\,\gitAbbrevHash{}\,\textbullet{}\,\gitAuthorDate } + +% setting up gitinfo2: +% copy the file post-xxx-sample.txt from https://www.ctan.org/tex-archive/macros/latex/contrib/gitinfo2 +% and put it in .git/hooks/post-checkout +% then +% cd .git/hooks +% chmod g+x post-checkout +% chmod +x post-checkout +% cp post-checkout post-commit +% cp post-checkout post-merge +% cd ../.. +% git checkout master +% git checkout develop +% ls .git +% and you should see gitHeadInfo.gin +\begin{document} +% \begin{noindent} + \title{\lstinline[basicstyle=\huge\ttfamily]!latexindent.pl!\\[1cm] + Version 2.2} +% \end{noindent} +\author{Chris Hughes \footnote{and contributors! (See \vref{sec:contributors}.)}} +\maketitle +\begin{abstract} + \lstinline!latexindent.pl! is a \lstinline!Perl! script that indents \lstinline!.tex! (and other) + files according to an indentation scheme that the user can modify to suit their + taste. Environments, including those with alignment delimiters (such as \lstinline!tabular!), + and commands, including those that can split braces and brackets across lines, + are \emph{usually} handled correctly by the script. Options for \lstinline!verbatim!-like + environments and indentation after headings (such as \lstinline!\chapter!, \lstinline!\section!, etc) + are also available. +\end{abstract} + +\tableofcontents +\lstlistoflistings + +\section{Before we begin} +\subsection{Thanks} +I first created \lstinline!latexindent.pl! to help me format chapter files +in a big project. After I blogged about it on the +\TeX{} stack exchange \cite{cmhblog} I received some positive feedback and +follow-up feature requests. A big thank you to Harish Kumar who has really +helped to drive the script forward and has put it through a number of challenging +tests--I look forward to more challenges in the future Harish! + +The \lstinline!yaml!-based interface of \lstinline!latexindent.pl! was inspired +by the wonderful \lstinline!arara! tool; any similarities are deliberate, and +I hope that it is perceived as the compliment that it is. Thank you to Paulo Cereda and the +team for releasing this awesome tool; I initially worried that I was going to +have to make a GUI for \lstinline!latexindent.pl!, but the release of \lstinline!arara! +has meant there is no need. Thank you to Paulo for all of your advice and +encouragement. + +There have been several contributors to the project so far (and hopefully more in +the future!); thank you very much to the people detailed in \vref{sec:contributors} +for their valued contributions. + +\subsection{License} +\lstinline!latexindent.pl! is free and open source, and it always will be. +Before you start using it on any important files, bear in mind that \lstinline!latexindent.pl! has the option to overwrite your \lstinline!.tex! files. +It will always make at least one backup (you can choose how many it makes, see \cpageref{page:onlyonebackup}) +but you should still be careful when using it. The script has been tested on many +files, but there are some known limitations (see \cref{sec:knownlimitations}). +You, the user, are responsible for ensuring that you maintain backups of your files +before running \lstinline!latexindent.pl! on them. I think it is important at this +stage to restate an important part of the license here: +\begin{quote}\itshape + 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. +\end{quote} +There is certainly no malicious intent in releasing this script, and I do hope +that it works as you expect it to--if it does not, please first of all +make sure that you have the correct settings, and then feel free to let me know with a +complete minimum working example as I would like to improve the code as much as possible. + +\begin{warning} + Before you try the script on anything important (like your thesis), test it + out on the sample files that come with it in the \lstinline!success! directory. +\end{warning} + + +\section{Demonstration: before and after} +Let's give a demonstration of some before and after code--after all, you probably +won't want to try the script if you don't much like the results. You might also +like to watch the video demonstration I made on youtube \cite{cmh:videodemo} + +As you look at \crefrange{lst:filecontentsbefore}{lst:pstricksafter}, remember +that \lstinline!latexindent.pl! is just following its rules--there is nothing +particular about these code snippets. All of the rules can be modified +so that each user can personalize their indentation scheme. + +In each of the samples given in \crefrange{lst:filecontentsbefore}{lst:pstricksafter} +the `before' case is a `worst case scenario' with no effort to make indentation. The `after' +result would be the same, regardless of the leading white space at the beginning of +each line which is stripped by \lstinline!latexindent.pl! (unless a \lstinline!verbatim!-like +environment or \lstinline!noIndentBlock! is specified--more on this in \cref{sec:defuseloc}). + + \begin{sidebyside} + \noindent + \begin{minipage}{.6\textwidth} + \begin{cmhlistings}[style=demo]{\lstinline!filecontents! before}{lst:filecontentsbefore} +\begin{filecontents}{mybib.bib} +@online{strawberryperl, +title="Strawberry Perl", +url="http://strawberryperl.com/"} +@online{cmhblog, +title="A Perl script ... +url="... +\end{filecontents} + \end{cmhlistings} + \end{minipage}% + \noindent + \begin{minipage}{.6\textwidth} + \begin{cmhlistings}[style=demo]{\lstinline!filecontents! after}{lst:filecontentsafter} +\begin{filecontents}{mybib.bib} + @online{strawberryperl, + title="Strawberry Perl", + url="http://strawberryperl.com/"} + @online{cmhblog, + title="A Perl script for ... + url="... +\end{filecontents} + \end{cmhlistings} + \end{minipage} + \begin{minipage}{.6\textwidth} + \begin{cmhlistings}[style=demo]{\lstinline!tikzset! before}{lst:tikzsetbefore} +\tikzset{ +shrink inner sep/.code={ +\pgfkeysgetvalue... +\pgfkeysgetvalue... +} +} + \end{cmhlistings} + \end{minipage}% + \begin{minipage}{.6\textwidth} + \begin{cmhlistings}[style=demo]{\lstinline!tikzset! after}{lst:tikzsetafter} +\tikzset{ + shrink inner sep/.code={ + \pgfkeysgetvalue... + \pgfkeysgetvalue... + } +} + \end{cmhlistings} + \end{minipage} + \begin{minipage}{.6\textwidth} + \begin{cmhlistings}[style=demo]{\lstinline!pstricks! before}{lst:pstricksbefore} +\def\Picture#1{% +\def\stripH{#1}% +\begin{pspicture}[showgrid... +\psforeach{\row}{% +{{3,2.8,2.7,3,3.1}},% <=== Only this +{2.8,1,1.2,2,3},% +... +}{% +\expandafter... +} +\end{pspicture}} + \end{cmhlistings} + \end{minipage}% + \begin{minipage}{.6\textwidth} + \begin{cmhlistings}[style=demo]{\lstinline!pstricks! after}{lst:pstricksafter} +\def\Picture#1{% + \def\stripH{#1}% + \begin{pspicture}[showgrid... + \psforeach{\row}{% + {{3,2.8,2.7,3,3.1}},% <=== + {2.8,1,1.2,2,3},% + ... + }{% + \expandafter... + } + \end{pspicture}} + \end{cmhlistings} + \end{minipage} + \end{sidebyside} + +\section{How to use the script} +\lstinline!latexindent.pl! ships as part of the \TeX Live distribution for +Linux and Mac users; \lstinline!latexindent.exe! ships as part of the \TeX Live +and MiK\TeX distributions for Windows users. These files are also available +from github \cite{latexindent-home} should you wish to use them without +a \TeX{} distribution; in this case, you may like to read \vref{sec:updating-path} +which details how the \lstinline!path! variable can be updated. + +In what follows, we will always refer to \lstinline!latexindent.pl!, but depending on +your operating system and preference, you might substitute \lstinline!latexindent.exe! or +simply \lstinline!latexindent!. + +There are two ways to use \lstinline!latexindent.pl!: from the command line, +and using \lstinline!arara!; we discuss these in \cref{sec:commandline} and +\cref{sec:arara} respectively. We will discuss how to change the settings and +behaviour of the script in \vref{sec:defuseloc}. + +\lstinline!latexindent.pl! ships with \lstinline!latexindent.exe! for Windows +users, so that you can use the script with or without a Perl distribution. +If you plan to use \lstinline!latexindent.pl! (i.e, the original Perl script) then you will +need a few standard Perl modules--see \vref{sec:requiredmodules} for details. + +\subsection{From the command line}\label{sec:commandline} +\lstinline!latexindent.pl! has a number of different switches/flags/options, which +can be combined in any way that you like, either in short or long form as detailed below. +\lstinline!latexindent.pl! produces a \lstinline!.log! file, \lstinline!indent.log! every time it +is run. There is a base of information that is written to \lstinline!indent.log!, +but other additional information will be written depending +on which of the following options are used. + +\begin{itemize}[labelsep=.25cm] + \item[] \lstinline!latexindent.pl! + + This will output a welcome message to the terminal, including the version number + and available options. + \item[\verbitem{-h, --help}] \lstinline!latexindent.pl -h! + + As above this will output a welcome message to the terminal, including the version number + and available options. + \item[] \lstinline!latexindent.pl myfile.tex! + + This will operate on \lstinline!myfile.tex!, but will simply output to your terminal; \lstinline!myfile.tex! will not be changed in any way using this command. + \item[\verbitem{-w, --overwrite}] \lstinline!latexindent.pl -w myfile.tex! + + This \emph{will} overwrite \lstinline!myfile.tex!, but it will + make a copy of \lstinline!myfile.tex! first. You can control the name of + the extension (default is \lstinline!.bak!), and how many different backups are made-- + more on this in \cref{sec:defuseloc}; see \lstinline!backupExtension! and \lstinline!onlyOneBackUp!. + + Note that if \lstinline!latexindent.pl! can not create the backup, then it + will exit without touching your original file; an error message will be given + asking you to check the permissions of the backup file. + \item[\verbitem{-o,--outputfile}] \lstinline!latexindent.pl -o myfile.tex outputfile.tex! + + This will indent \lstinline!myfile.tex! and output it to \lstinline!outputfile.tex!, + overwriting it (\lstinline!outputfile.tex!) if it already exists. Note that if \lstinline!latexindent.pl! is called with both + the \lstinline!-w! and \lstinline!-o! switches, then \lstinline!-w! will + be ignored and \lstinline!-o! will take priority (this seems safer than the + other way round). + + Note that using \lstinline!-o! is equivalent to using \lstinline!latexindent.pl myfile.tex > outputfile.tex! + \item[\verbitem{-s, --silent}] \lstinline!latexindent.pl -s myfile.tex! + + Silent mode: no output will be given to the terminal. + \item[\verbitem{-t, --trace}] \lstinline!latexindent.pl -t myfile.tex! + + \label{page:traceswitch} + Tracing mode: verbose output will be given to \lstinline!indent.log!. This + is useful if \lstinline!latexindent.pl! has made a mistake and you're + trying to find out where and why. You might also be interested in learning + about \lstinline!latexindent.pl!'s thought process--if so, this + switch is for you. + \item[\verbitem{-tt, --ttrace}] \lstinline!latexindent.pl -tt myfile.tex! + + \emph{More detailed} tracing mode: this option gives more details to \lstinline!indent.log! + than the standard \lstinline!trace! option. + \item[\verbitem{-l, --local[=myyaml.yaml]}] \lstinline!latexindent.pl -l myfile.tex! + +\lstinline!latexindent.pl -l=myyaml.yaml myfile.tex! + +\lstinline!latexindent.pl -l myyaml.yaml myfile.tex! + + + \label{page:localswitch} + Local settings: you might like to read \cref{sec:defuseloc} before + using this switch. \lstinline!latexindent.pl! will always load \lstinline!defaultSettings.yaml! + and if it is called with the \lstinline!-l! switch and it finds \lstinline!localSettings.yaml! + in the same directory as \lstinline!myfile.tex! then these settings will be + added to the indentation scheme. Information will be given in \lstinline!indent.log! on + the success or failure of loading \lstinline!localSettings.yaml!. + +The \lstinline!-l! flag can take an \emph{optional} parameter which details the name of a \lstinline!yaml! file +that resides in the same directory as \lstinline!myfile.tex!; you can use this option if you would +like to load a settings file in the current working directory that is \emph{not} called \lstinline!localSettings.yaml!. + + \item[\verbitem{-d, --onlydefault}] \lstinline!latexindent.pl -d myfile.tex! + + Only \lstinline!defaultSettings.yaml!: you might like to read \cref{sec:defuseloc} before + using this switch. By default, \lstinline!latexindent.pl! will always search for + \lstinline!indentconfig.yaml! or \lstinline!.indentconfig.yaml! in your home directory. If you would prefer it not to do so + then (instead of deleting or renaming \lstinline!indentconfig.yaml!/\lstinline!.indentconfig.yaml!) you can simply + call the script with the \lstinline!-d! switch; note that this will also tell + the script to ignore \lstinline!localSettings.yaml! even if it has been called with the + \lstinline!-l! switch. + + \item[\verbitem{-c, --cruft=}]\lstinline!latexindent.pl -c=/path/to/directory/ myfile.tex! + + If you wish to have backup files and \lstinline!indent.log! written to a directory + other than the current working directory, then you can send these `cruft' files + to another directory. + % this switch was made as a result of http://tex.stackexchange.com/questions/142652/output-latexindent-auxiliary-files-to-a-different-directory +\end{itemize} + +\lstinline!latexindent.pl! can also be called on a file without the file extension, for +example \lstinline[breaklines=true,breakatwhitespace=true,]!latexindent.pl myfile! and in which case, you can specify +the order in which extensions are searched for; see \vref{lst:fileExtensionPreference} +for full details. + +\subsection{From \lstinline!arara!}\label{sec:arara} +Using \lstinline!latexindent.pl! from the command line is fine for some folks, but +others may find it easier to use from \lstinline!arara!. \lstinline!latexindent.pl! +ships with an \lstinline!arara! rule, \lstinline!indent.yaml!, which can be copied +to the directory of +your other \lstinline!arara! rules; otherwise you can add the directory in which \lstinline!latexindent.pl! +resides to your \lstinline!araraconfig.yaml! file. + +Once you have told \lstinline!arara! where to find your \lstinline!indent! rule, +you can use it any of the ways described in \cref{lst:arara} (or combinations thereof). +In fact, \lstinline!arara! allows yet greater flexibility--you can use \lstinline!yes/no!, \lstinline!true/false!, or \lstinline!on/off! to toggle the various options. + +\begin{cmhlistings}[style=demo,escapeinside={(*@}{@*)}]{\lstinline!arara! sample usage}{lst:arara} +%(*@@*) arara: indent +%(*@@*) arara: indent: {overwrite: yes} +%(*@@*) arara: indent: {output: myfile.tex} +%(*@@*) arara: indent: {silent: yes} +%(*@@*) arara: indent: {trace: yes} +%(*@@*) arara: indent: {localSettings: yes} +%(*@@*) arara: indent: {onlyDefault: on} +%(*@@*) arara: indent: { cruft: /home/cmhughes/Desktop } +\documentclass{article} +... +\end{cmhlistings} + +Hopefully the use of these rules is fairly self-explanatory, but for completeness +\cref{tab:orbsandswitches} shows the relationship between \lstinline!arara! directive arguments and the +switches given in \cref{sec:commandline}. + +\begin{table}[!ht] + \centering + \caption{\lstinline!arara! directive arguments and corresponding switches} + \label{tab:orbsandswitches} + \begin{tabular}{lc} + \toprule + \lstinline!arara! directive argument & switch \\ + \midrule + \lstinline!overwrite! & \lstinline!-w! \\ + \lstinline!output! & \lstinline!-o! \\ + \lstinline!silent! & \lstinline!-s! \\ + \lstinline!trace! & \lstinline!-t! \\ + \lstinline!localSettings! & \lstinline!-l! \\ + \lstinline!onlyDefault! & \lstinline!-d! \\ + \lstinline!cruft! & \lstinline!-c! \\ + \bottomrule + \end{tabular} +\end{table} + +The \lstinline!cruft! directive does not work well when used with +directories that contain spaces. + +\section{default, user, and local settings}\label{sec:defuseloc} +\lstinline!latexindent.pl! loads its settings from \lstinline!defaultSettings.yaml! +(rhymes with camel). The idea is to separate the behaviour of the script +from the internal working--this is very similar to the way that we separate content +from form when writing our documents in \LaTeX. + +\subsection{\lstinline!defaultSettings.yaml!} +If you look in \lstinline!defaultSettings.yaml! you'll find the switches +that govern the behaviour of \lstinline!latexindent.pl!. If you're not sure where +\lstinline!defaultSettings.yaml! resides on your computer, don't worry as \lstinline!indent.log! +will tell you where to find it. +\lstinline!defaultSettings.yaml! is commented, +but here is a description of what each switch is designed to do. The default +value is given in each case. + +You can certainly feel free to edit \lstinline!defaultSettings.yaml!, but +this is not ideal as it may be overwritten when you update your \TeX{} distribution -- +all of your hard work tweaking the script would be undone! Don't worry, +there's a solution, feel free to peek ahead to \cref{sec:indentconfig} if you like. +\begin{itemize} + \item[\verbitem{defaultIndent}] \lstinline!"\t"! + + This is the default indentation (\lstinline!\t! means a tab) used in the absence of other details + for the command or environment we are working with--see \lstinline!indentRules! + for more details (\cpageref{page:indentRules}). + + If you're interested in experimenting with \lstinline!latexindent.pl! then you + can \emph{remove} all indentation by setting \lstinline!defaultIndent: ""! + \item[\verbitem{backupExtension}] \lstinline!.bak! + + If you call \lstinline!latexindent.pl! with the \lstinline!-w! switch (to overwrite + \lstinline!myfile.tex!) then it will create a backup file before doing + any indentation: \lstinline!myfile.bak0! + + By default, every time you call \lstinline!latexindent.pl! after this with + the \lstinline!-w! switch it will create \lstinline!myfile.bak1!, \lstinline!myfile.bak2!, + etc. + \item[\verbitem{onlyOneBackUp}] \lstinline!0! + + \label{page:onlyonebackup} + If you don't want a backup for every time that you call \lstinline!latexindent.pl! (so + you don't want \lstinline!myfile.bak1!, \lstinline!myfile.bak2!, etc) and you simply + want \lstinline!myfile.bak! (or whatever you chose \lstinline!backupExtension! to be) + then change \lstinline!onlyOneBackUp! to \lstinline!1!. + + \item[\verbitem{maxNumberOfBackUps}]\lstinline!0! + + Some users may only want a finite number of backup files, + say at most $3$, in which case, they can change this switch. + The smallest value of \lstinline!maxNumberOfBackUps! is $0$ which will \emph{not} + prevent backup files being made--in this case, the behaviour will be dictated + entirely by \lstinline!onlyOneBackUp!. + %\footnote{This was a feature request made on \href{https://github.com/cmhughes/latexindent.plx}{github}} + \item[\verbitem{cycleThroughBackUps}]\lstinline!0! + + Some users may wish to cycle through backup files, by deleting the + oldest backup file and keeping only the most recent; for example, + with \lstinline!maxNumberOfBackUps: 4!, and \lstinline!cycleThroughBackUps! + set to \lstinline!1! then the \lstinline!copy! procedure given in \cref{lst:cycleThroughBackUps} + would be obeyed. + + \begin{cmhlistings}[language=Perl]{\lstinline!cycleThroughBackUps!}{lst:cycleThroughBackUps} +copy myfile.bak1 to myfile.bak0 +copy myfile.bak2 to myfile.bak1 +copy myfile.bak3 to myfile.bak2 +copy myfile.bak4 to myfile.bak3 + \end{cmhlistings} + + \item[\verbitem{indentPreamble}] \lstinline!0! + + The preamble of a document can sometimes contain some trickier code + for \lstinline!latexindent.pl! to work with. By default, \lstinline!latexindent.pl! + won't try to operate on the preamble, but if you'd like it to try then + change \lstinline!indentPreamble! to \lstinline!1!. + \item[\verbitem{alwaysLookforSplitBraces}] \lstinline!1! + + This switch tells \lstinline!latexindent.pl! to look for commands that + can split \emph{braces} across lines, such as \lstinline!parbox!, \lstinline!tikzset!, etc. In older + versions of \lstinline!latexindent.pl! you had to specify each one in \lstinline!checkunmatched!--this + clearly became tedious, hence the introduction of \lstinline!alwaysLookforSplitBraces!. + + \emph{As long as you leave this switch on (set to 1) you don't need to specify which + commands can split braces across lines--you can ignore the + fields \lstinline!checkunmatched! and \lstinline!checkunmatchedELSE! described + later on \cpageref{lst:checkunmatched}}. + \item[\verbitem{alwaysLookforSplitBrackets}] \lstinline!1! + + This switch tells \lstinline!latexindent.pl! to look for commands that + can split \emph{brackets} across lines, such as \lstinline!psSolid!, \lstinline!pgfplotstabletypeset!, + etc. In older versions of \lstinline!latexindent.pl! you had to specify each one in \lstinline!checkunmatchedbracket!-- + this clearly became tedious, hence the introduction of \lstinline!alwaysLookforSplitBraces!. + + \emph{As long as you leave this switch on (set to 1) you don't need to specify which + commands can split brackets across lines--you can ignore \lstinline!checkunmatchedbracket! described later on + \cpageref{lst:checkunmatched}}. + + \item[\verbitem{removeTrailingWhitespace}] \lstinline!0! + + By default \lstinline!latexindent.pl! indents every line (including empty lines) + which creates `trailing white space' feared by most version control systems. If + this option is set to \lstinline!1!, trailing white space is removed from all + lines, also non-empty ones. In general this should not create any problems, but + by precaution this option is turned off by default. Thanks to \cite{vosskuhle} for + providing this feature. + + \item[\verbitem{lookForAlignDelims}] This is the first example of a field + in \lstinline!defaultSettings.yaml! that has more than one line; \cref{lst:aligndelims:basic} + shows more details. In fact, the fields in \verbitem{lookForAlignDelims} can actually + take two different forms: the \emph{basic} version is shown in \cref{lst:aligndelims:basic} + and the \emph{advanced} version in \cref{lst:aligndelims:advanced}; we will discuss each in turn. + + \begin{cmhlistings}[style=yaml]{\lstinline!lookForAlignDelims! (basic)}{lst:aligndelims:basic} +lookForAlignDelims: + tabular: 1 + tabularx: 1 + longtable: 1 + array: 1 + matrix: 1 + bmatrix: 1 + pmatrix: 1 + align: 1 + align*: 1 + alignat: 1 + alignat*: 1 + aligned: 1 + cases: 1 + dcases: 1 + pmatrix: 1 + listabla: 1 + \end{cmhlistings} + + The environments specified in this field will be operated on in a special way by \lstinline!latexindent.pl!. In particular, it will try and align each column by its alignment + tabs. It does have some limitations (discussed further in \cref{sec:knownlimitations}), + but in many cases it will produce results such as those in \cref{lst:tabularbefore:basic,lst:tabularafter:basic}. + + \begin{minipage}{.5\textwidth} + \begin{cmhlistings}[style=demo,columns=fixed]{\lstinline!tabular! before}{lst:tabularbefore:basic} +\begin{tabular}{cccc} +1& 2 &3 &4\\ +5& &6 &\\ +\end{tabular} + \end{cmhlistings} + \end{minipage}% + \begin{minipage}{.5\textwidth} + \begin{cmhlistings}[style=demo,columns=fixed]{\lstinline!tabular! after (basic)}{lst:tabularafter:basic} +\begin{tabular}{cccc} + 1 & 2 & 3 & 4 \\ + 5 & & 6 & \\ +\end{tabular} + \end{cmhlistings} + \end{minipage} + + If you find that \lstinline!latexindent.pl! does not perform satisfactorily on such + environments then you can either remove them from \lstinline!lookForAlignDelims! altogether, or set the relevant key to \lstinline!0!, for example \lstinline!tabular: 0!, or if you just want to ignore \emph{specific} + instances of the environment, you could wrap them in something from \lstinline!noIndentBlock! (see \cref{lst:noIndentBlock}). + + If you wish to remove the alignment of the \lstinline!\\! within a delimiter-aligned block, then the + advanced form of \lstinline!lookForAlignDelims! shown in \cref{lst:aligndelims:advanced} is for you. + \begin{cmhlistings}[style=yaml]{\lstinline!lookForAlignDelims! (advanced)}{lst:aligndelims:advanced} +lookForAlignDelims: + tabular: + delims: 1 + alignDoubleBackSlash: 0 + spacesBeforeDoubleBackSlash: 0 + tabularx: + delims: 1 + longtable: 1 + \end{cmhlistings} + + Note that you can use a mixture of the basic and advanced form: in \cref{lst:aligndelims:advanced} \lstinline!tabular! and \lstinline!tabularx! + are advanced and \lstinline!longtable! is basic. When using the advanced form, each field should receive at least 1 sub-field, and \emph{can} (but does not have to) receive up to 3 fields: + \begin{itemize} + \item \lstinline!delims!: switch equivalent to simply specifying, for example, \lstinline!tabular: 1! in + the basic version shown in \cref{lst:aligndelims:basic} (default: 1); + \item \lstinline!alignDoubleBackSlash!: switch to determine if \lstinline!\\! should be aligned (default: 1); + \item \lstinline!spacesBeforeDoubleBackSlash!: optionally, specifies the number of spaces to be inserted + before (non-aligned) \lstinline!\\!. In order to use this field, \lstinline!alignDoubleBackSlash! needs + to be set to 0 (default: 0). + \end{itemize} + + With the settings shown in \cref{lst:aligndelims:advanced} we receive the before-and-after results shown in + \cref{lst:tabularbefore:advanced,lst:tabularafter:advanced}; note that the ampersands have been aligned, but + the \lstinline!\\! have not (compare the alignment of \lstinline!\\! in \cref{lst:tabularafter:basic,lst:tabularafter:advanced}). + + \begin{minipage}{.5\textwidth} + \begin{cmhlistings}[style=demo,columns=fixed]{\lstinline!tabular! before }{lst:tabularbefore:advanced} +\begin{tabular}{cccc} +1& 2 &3 &4\\ +5& &6 &\\ +\end{tabular} + \end{cmhlistings} + \end{minipage}% + \begin{minipage}{.5\textwidth} + \begin{cmhlistings}[style=demo,columns=fixed]{\lstinline!tabular! after (advanced)}{lst:tabularafter:advanced} +\begin{tabular}{cccc} + 1 & 2 & 3 & 4\\ + 5 & & 6 &\\ +\end{tabular} + \end{cmhlistings} + \end{minipage} + + Using \lstinline!spacesBeforeDoubleBackSlash: 3! gives \cref{lst:tabularbefore:spacing,lst:tabularafter:spacing}, + note the spacing before the \lstinline!\\! in \cref{lst:tabularafter:spacing}. + + \begin{minipage}{.5\textwidth} + \begin{cmhlistings}[style=demo,columns=fixed]{\lstinline!tabular! before}{lst:tabularbefore:spacing} +\begin{tabular}{cccc} +1& 2 &3 &4\\ +5& &6 &\\ +\end{tabular} + \end{cmhlistings} + \end{minipage}% + \begin{minipage}{.5\textwidth} + \begin{cmhlistings}[style=demo,columns=fixed]{\lstinline!tabular! after (spacing)}{lst:tabularafter:spacing} +\begin{tabular}{cccc} + 1 & 2 & 3 & 4 \\ + 5 & & 6 & \\ +\end{tabular} + \end{cmhlistings} + \end{minipage} + + + + + If you have blocks of code that you wish to align at the \& character that + are \emph{not} wrapped in, for example, \lstinline!\begin{tabular}...\end{tabular}!, then you use the mark up + illustrated in \cref{lst:alignmentmarkup}. Note that the \lstinline!%*! must be next to + each other, but that there can be any number of spaces (possibly none) between the + \lstinline!*! and \lstinline!\begin{tabular}!; note also that you may use any + environment name that you have specified in \lstinline!lookForAlignDelims!. + \begin{cmhlistings}[style=demo,columns=fixed]{Mark up for aligning delimiters outside of environments}{lst:alignmentmarkup} +\matrix{% +%* \begin{tabular} + 1 & 2 & 3 & 4 \\ + 5 & & 6 & \\ +%* \end{tabular} +} + \end{cmhlistings} + + \item[\verbitem{verbatimEnvironments}] A field that contains a list of environments + that you would like left completely alone--no indentation will be done + to environments that you have specified in this field--see \cref{lst:verbatimEnvironments}. + + + \begin{cmhlistings}[style=yaml]{\lstinline!verbatimEnvironments!}{lst:verbatimEnvironments} +verbatimEnvironments: + verbatim: 1 + lstlisting: 1 + \end{cmhlistings} + Note that if you put an environment in \lstinline!verbatimEnvironments! + and in other fields such as \lstinline!lookForAlignDelims! or \lstinline!noAdditionalIndent! + then \lstinline!latexindent.pl! will \emph{always} prioritize \lstinline!verbatimEnvironments!. + + \item[\verbitem{noIndentBlock}] If you have a block of code that you don't + want \lstinline!latexindent.pl! to touch (even if it is \emph{not} a verbatim-like + environment) then you can wrap it in an environment from \lstinline!noIndentBlock!; + you can use any name you like for this, provided you populate it as demonstrate in + \cref{lst:noIndentBlock}. + + \begin{cmhlistings}[style=yaml]{\lstinline!noIndentBlock!}{lst:noIndentBlock} +noIndentBlock: + noindent: 1 + cmhtest: 1 + \end{cmhlistings} + + Of course, you don't want to have to specify these as null environments + in your code, so you use them with a comment symbol, \lstinline!%!, followed + by as many spaces (possibly none) as you like; see \cref{lst:noIndentBlockdemo} for + example. + \begin{cmhlistings}[style=demo,escapeinside={(*@}{@*)}]{\lstinline!noIndentBlock! demonstration}{lst:noIndentBlockdemo} +%(*@@*) \begin{noindent} + this code + won't + be touched + by + latexindent.pl! +%(*@@*)\end{noindent} + \end{cmhlistings} + + \item[\verbitem{noAdditionalIndent}] If you would prefer some of your + environments or commands not to receive any additional indent, then + populate \lstinline!noAdditionalIndent!; see \cref{lst:noAdditionalIndent}. + Note that these environments will still receive the \emph{current} level + of indentation unless they belong to \lstinline!verbatimEnvironments!, or \lstinline!noIndentBlock!. + + \begin{cmhlistings}[style=yaml]{\lstinline!noAdditionalIndent!}{lst:noAdditionalIndent} +noAdditionalIndent: + document: 1 + myexample: 1 + mydefinition: 1 + problem: 1 + exercises: 1 + mysolution: 1 + foreach: 0 + widepage: 1 + comment: 1 + \[: 1 + \]: 1 + frame: 0 + \end{cmhlistings} + Note in particular from \cref{lst:noAdditionalIndent} that if you wish content within + \lstinline!\[! and \lstinline!\]! to receive no additional indentation then + you have to specify \emph{both} as \lstinline!1! (the default is \lstinline!0!). + If you do not specify both as the same value you may get some interesting results! + \item[\verbitem{indentRules}] If\label{page:indentRules} you would prefer to specify + individual rules for certain environments or commands, just + populate \lstinline!indentRules!; see \cref{lst:indentRules} + + \begin{cmhlistings}[style=yaml]{\lstinline!indentRules!}{lst:indentRules} +indentRules: + myenvironment: "\t\t" + anotherenvironment: "\t\t\t\t" + \[: "\t" + \end{cmhlistings} %%%%%\] just here to stop vim from colouring the rest of my code + Note that in contrast to \lstinline!noAdditionalIndent! you do \emph{not} + need to specify both \lstinline!\[! and \lstinline!\]! in this field. + + If you put an environment in both \lstinline!noAdditionalIndent! and in + \lstinline!indentRules! then \lstinline!latexindent.pl! will resolve the conflict + by ignoring \lstinline!indentRules! and prioritizing \lstinline!noAdditionalIndent!. + You will get a warning message in \lstinline!indent.log!; note that you will only + get one warning message per command or environment. Further discussion + is given in \cref{sec:fieldhierachy}. + + \item[\verbitem{indentAfterHeadings}] This field enables the user to specify + indentation rules that take effect after heading commands such as \lstinline!\part!, \lstinline!\chapter!, + \lstinline!\section!, \lstinline!\subsection*! etc. This field is slightly different from most + of the fields that we have considered previously, because each element is + itself a field which has two elements: \lstinline!indent! and \lstinline!level!. (Similar + in structure to the advanced form of \lstinline!lookForAlignDelims! in \cref{lst:aligndelims:advanced}.) + \begin{cmhlistings}[style=yaml]{\lstinline!indentAfterHeadings!}{lst:indentAfterHeadings} +indentAfterHeadings: + part: + indent: 0 + level: 1 + chapter: + indent: 0 + level: 2 + section: + indent: 0 + level: 3 + ... + \end{cmhlistings} + The default settings do \emph{not} place indentation after a heading--you + can easily switch them on by changing \lstinline!indent: 0! to \lstinline!indent: 1!. + The \lstinline!level! field tells \lstinline!latexindent.pl! the hierarchy of the heading + structure in your document. You might, for example, like to have both \lstinline!section! + and \lstinline!subsection! set with \lstinline!level: 3! because you do not want the indentation to go too deep. + + You can add any of your own custom heading commands to this field, specifying the \lstinline!level! + as appropriate. You can also specify your own indentation in \lstinline!indentRules!-- + you will find the default \lstinline!indentRules! contains \lstinline!chapter: " "! which + tells \lstinline!latexindent.pl! simply to use a space character after \lstinline!\chapter! headings + (once \lstinline!indent! is set to \lstinline!1! for \lstinline!chapter!). + + \item[\verbitem{indentAfterItems}] The environments specified in \lstinline!indentAfterItems! tell + \lstinline!latexindent.pl! to look for \lstinline!\item! commands; if these switches are set to \lstinline!1! + then indentation will be performed so as indent the code after each \lstinline!item!. + \begin{cmhlistings}{\lstinline!indentAfterItems!}{lst:indentafteritems} +indentAfterItems: + itemize: 1 + enumerate: 1 + \end{cmhlistings} + A demonstration is given in \cref{lst:itemsbefore,lst:itemsafter} + + \begin{minipage}{.5\textwidth} + \begin{cmhlistings}[style=demo,xleftmargin=-3mm,columns=fixed]{\lstinline!items! before}{lst:itemsbefore} +\begin{itemize} +\item some text here +some more text here +some more text here +\item another item +\end{itemize} + \end{cmhlistings} + \end{minipage}% + \begin{minipage}{.5\textwidth} + \begin{cmhlistings}[style=demo,xleftmargin=-3mm,columns=fixed]{\lstinline!items! after}{lst:itemsafter} +\begin{itemize} + \item some text here + some more text here + some more text here + \item another item +\end{itemize} + \end{cmhlistings} + \end{minipage} + + \item[\verbitem{itemNames}] If you have your own \lstinline!item! commands (perhaps you + prefer to use \lstinline!myitem!, for example) + then you can put populate them in \lstinline!itemNames!. + For example, users of the \lstinline!exam! document class might like to add + \lstinline!parts! to \lstinline!indentAfterItems! and \lstinline!part! to \lstinline!itemNames! + to their user settings--see \vref{sec:indentconfig} for details of how to configure user settings, + and \vref{lst:mysettings} in particular.\label{page:examsettings} + + \item[\verbitem{constructIfElseFi}] The commands specified in this field + will tell \lstinline!latexindent.pl! to look for constructs that + have the form \lstinline!\if...! \lstinline!\else...! \lstinline!\fi!, such as, + for example, \lstinline!\ifnum!; see \cref{lst:iffibefore,lst:iffiafter} for + a before-and-after demonstration. + + \begin{minipage}{.5\textwidth} + \begin{cmhlistings}[style=demo,xleftmargin=-3mm,columns=fixed]{\lstinline!if-else-fi! construct before}{lst:iffibefore} +\ifnum\radius>5 +\ifnum\radius<16 +\draw[decorate,... +\fi +\fi + \end{cmhlistings} + \end{minipage}% + \begin{minipage}{.5\textwidth} + \begin{cmhlistings}[style=demo,xleftmargin=-3mm,columns=fixed]{\lstinline!if-else-fi! construct after}{lst:iffiafter} +\ifnum\radius>5 + \ifnum\radius<16 + \draw[decorate,... + \fi +\fi + \end{cmhlistings} + \end{minipage} + + \item[\verbitem{fileExtensionPreference}] \lstinline!latexindent.pl! can be called to + act on a file without + specifying the file extension. For example we can call \lstinline!latexindent.pl myfile! + in which case the script will look for \lstinline!myfile! with the extensions + specified in \lstinline!fileExtensionPreference! in their numeric order. If + no match is found, the script will exit. As with all of the fields, you should + change and/or add to this as necessary. + \begin{cmhlistings}[style=yaml]{\lstinline!fileExtensionPreference!}{lst:fileExtensionPreference} +fileExtensionPreference: + .tex: 1 + .sty: 2 + .cls: 3 + .bib: 4 + \end{cmhlistings} + Calling \lstinline!latexindent.pl myfile! with the details specified in \cref{lst:fileExtensionPreference} + means that the script will first look for \lstinline!myfile.tex!, then \lstinline!myfile.sty!, \lstinline!myfile.cls!, + and finally \lstinline!myfile.bib! in order. +\item[\verbitem{logFilePreferences}] + \lstinline!latexindent.pl! writes information to \lstinline!indent.log!, some + of which can be customised by changing \lstinline!logFilePreferences!; see \cref{lst:logFilePreferences}. +\begin{cmhlistings}[style=yaml]{\lstinline!logFilePreferences!}{lst:logFilePreferences} +logFilePreferences: + showEveryYamlRead: 1 + showAlmagamatedSettings: 0 + endLogFileWith: '--------------' + traceModeIncreaseIndent: '>>' + traceModeAddCurrentIndent: '||' + traceModeDecreaseIndent: '<<' + traceModeBetweenLines: "\n" + \end{cmhlistings} +If you load your own user settings (see \vref{sec:indentconfig}) then \lstinline!latexindent.pl! will +detail them in \lstinline!indent.log!; you can choose not to have the details logged by switching +\lstinline!showEveryYamlRead! to \lstinline!0!. Once all of your settings have +been loaded, you can see the amalgamated settings by switching \lstinline!showAlmagamatedSettings! +to \lstinline!1!, if you wish. The log file will end with the characters +given in \lstinline!endLogFileWith!. + +When \lstinline!trace! mode is active (see \cpageref{page:traceswitch}) verbose information is written +to \lstinline!indent.log!. The decoration of this information can be customised through the remaining +fields given in \cref{lst:logFilePreferences}; note, in particular, the use of \lstinline!"\n"! for +escaped characters (using single quotes will not produce the same results). + +\item[\verbitem{fileContentsEnvironments}] + \lstinline!latexindent.pl! determines when the main document begins by looking for \lstinline!\begin{document}!; + it will not do so when inside any of the environments specified in \lstinline!fileContentsEnvironments!, see + \cref{lst:fileContentsEnvironments}. +\begin{cmhlistings}[style=yaml]{\lstinline!fileContentsEnvironments!}{lst:fileContentsEnvironments} +fileContentsEnvironments: + filecontents: 1 + filecontents*: 1 + \end{cmhlistings} + + \begin{warning} + \emph{The following fields are marked in red, as they are not necessary + unless you wish to micro-manage your indentation scheme. + Note that in each case, you should \emph{not} use the backslash.} + \end{warning} + + % to anyone reading the source code- I know the next line isn't the + % correct way to do it :) + \item[\color{red}\verbitem{checkunmatched}] Assuming you keep \lstinline!alwaysLookforSplitBraces! set to \lstinline!1! (which + is the default) then you don't need to worry about \lstinline!checkunmatched!. + + Should you wish to deactivate \lstinline!alwaysLookforSplitBraces! by setting it to \lstinline!0!, then + you can populate \lstinline!checkunmatched! with commands that can split braces across + lines--see \cref{lst:checkunmatched}. + + \begin{cmhlistings}[style=yaml]{\lstinline!checkunmatched!}{lst:checkunmatched} +checkunmatched: + parbox: 1 + vbox: 1 + \end{cmhlistings} + \item[\color{red}\verbitem{checkunmatchedELSE}] Similarly, assuming you keep \lstinline!alwaysLookforSplitBraces! set to \lstinline!1! (which + is the default) then you don't need to worry about \lstinline!checkunmatchedELSE!. + + As in \lstinline!checkunmatched!, should you wish to deactivate \lstinline!alwaysLookforSplitBraces! by setting it to \lstinline!0!, then + you can populate \lstinline!checkunmatchedELSE! with commands that can split braces across + lines \emph{and} have an `else' statement--see \cref{lst:checkunmatchedELSE}. + + \begin{cmhlistings}[style=yaml]{\lstinline!checkunmatchedELSE!}{lst:checkunmatchedELSE} +checkunmatchedELSE: + pgfkeysifdefined: 1 + DTLforeach: 1 + ifthenelse: 1 + \end{cmhlistings} + \item[\color{red}\verbitem{checkunmatchedbracket}] Assuming you keep \lstinline!alwaysLookforSplitBrackets! + set to \lstinline!1! (which is the default) then you don't need to worry about \lstinline!checkunmatchedbracket!. + + Should you wish to deactivate \lstinline!alwaysLookforSplitBrackets! by setting it + to \lstinline!0!, then you can populate \lstinline!checkunmatchedbracket! with commands that can + split \emph{brackets} across lines--see \cref{lst:checkunmatchedbracket}. + + \begin{cmhlistings}[style=yaml]{\lstinline!checkunmatchedbracket!}{lst:checkunmatchedbracket} +checkunmatchedbracket: + psSolid: 1 + pgfplotstablecreatecol: 1 + pgfplotstablesave: 1 + pgfplotstabletypeset: 1 + mycommand: 1 + \end{cmhlistings} +\end{itemize} + +\subsubsection{Hierarchy of fields}\label{sec:fieldhierachy} +After reading the previous section, it should sound reasonable that +\lstinline!noAdditionalIndent!, \lstinline!indentRules!, and +\lstinline!verbatim! all serve mutually exclusive tasks. Naturally, you may +well wonder what happens if you choose to ask \lstinline!latexindent.pl! to +prioritize one above the other. + +For example, let's say that (after reading \cref{sec:indentconfig}) you put the fields in \cref{lst:conflict} into +one of your settings files. +\begin{cmhlistings}[style=yaml]{Conflicting ideas}{lst:conflict} +indentRules: + myenvironment: "\t\t" +noAdditionalIndent: + myenvironment: 1 +\end{cmhlistings} + +Clearly these fields conflict: first of all +you are telling \lstinline!latexindent.pl! that \lstinline!myenvironment! should +receive two tabs of indentation, and then you are telling it +not to put any indentation in the environment. \lstinline!latexindent.pl! +will always make the decision to prioritize \lstinline!noAdditionalIndent! above +\lstinline!indentRules! regardless of the order that you load them in +your settings file. The first +time it encounters \lstinline!myenvironment! it will put a warning in \lstinline!indent.log! +and delete the offending key from \lstinline!indentRules! so that any future +conflicts will not have to be addressed. + +Let's consider another conflicting example in \cref{lst:bigconflict} +\begin{cmhlistings}[style=yaml]{More conflicting ideas}{lst:bigconflict} +lookForAlignDelims: + myenvironment: 1 +verbatimEnvironments: + myenvironment: 1 +\end{cmhlistings} +This is quite a significant conflict--we are first of all telling \lstinline!latexindent.pl! +to look for alignment delimiters in \lstinline!myenvironment! and then +telling it that actually we would like \lstinline!myenvironment! to be considered +as a \lstinline!verbatim!-like environment. Regardless of the order that we +state \cref{lst:bigconflict} the \lstinline!verbatim! instruction will always win. +As in \cref{lst:conflict} you will only receive a warning in \lstinline!indent.log! the +first time \lstinline!latexindent.pl! encounters \lstinline!myenvironment! as the +offending key is deleted from \lstinline!lookForAlignDelims!. + +To summarize, \lstinline!latexindent.pl! will prioritize the various fields in the +following order: +\begin{enumerate} + \item \lstinline!verbatimEnvironments! + \item \lstinline!noAdditionalIndent! + \item \lstinline!indentRules! +\end{enumerate} +\subsection{\lstinline!indentconfig.yaml! and \lstinline!.indentconfig.yaml! (for user settings)}\label{sec:indentconfig} +Editing \lstinline!defaultSettings.yaml! is not ideal as it may be overwritten when +updating your distribution--a better way to customize the settings to your liking +is to set up your own settings file, +\lstinline!mysettings.yaml! (or any name you like, provided it ends with \lstinline!.yaml!). +The only thing you have to do is tell \lstinline!latexindent.pl! where to find it. + +\lstinline!latexindent.pl! will always check your home directory for \lstinline!indentconfig.yaml! +and \lstinline!.indentconfig.yaml! (unless +it is called with the \lstinline!-d! switch), +which is a plain text file you can create that contains the \emph{absolute} +paths for any settings files that you wish \lstinline!latexindent.pl! to load. There is no difference +between \lstinline!indentconfig.yaml! and \lstinline!.indentconfig.yaml!, other than the +fact that \lstinline!.indentconfig.yaml! is a `hidden' file; thank you to \cite{jacobo-diaz-hidden-config} +for providing this feature. In what follows, we will use \lstinline!indentconfig.yaml!, but it +is understood that this equally represents \lstinline!.indentconfig.yaml! as well. If you +have both files in existence, \lstinline!indentconfig.yaml! takes priority. + +For Mac and Linux users, their home directory is \lstinline!~/username! while +Windows (Vista onwards) is \lstinline!C:\Users\username! \footnote{If you're not sure + where to put \lstinline!indentconfig.yaml!, don't + worry \lstinline!latexindent.pl! will tell you in the log file exactly where to +put it assuming it doesn't exist already.} +\Cref{lst:indentconfig} shows a sample \lstinline!indentconfig.yaml! file. + +\begin{cmhlistings}[style=yaml]{\lstinline!indentconfig.yaml! (sample)}{lst:indentconfig} +# Paths to user settings for latexindent.pl +# +# Note that the settings will be read in the order you +# specify here- each successive settings file will overwrite +# the variables that you specify + +paths: +- /home/cmhughes/Documents/yamlfiles/mysettings.yaml +- /home/cmhughes/folder/othersettings.yaml +- /some/other/folder/anynameyouwant.yaml +- C:\Users\chughes\Documents\mysettings.yaml +- C:\Users\chughes\Desktop\test spaces\more spaces.yaml +\end{cmhlistings} + +Note that the \lstinline!.yaml! files you specify in \lstinline!indentconfig.yaml! +will be loaded in the order that you write them in. Each file doesn't have +to have every switch from \lstinline!defaultSettings.yaml!; in fact, I recommend +that you only keep the switches that you want to \emph{change} in these +settings files. + +To get started with your own settings file, you might like to save a copy of +\lstinline!defaultSettings.yaml! in another directory and call it, for +example, \lstinline!mysettings.yaml!. Once you have added the path to \lstinline!indentconfig.yaml! +feel free to start changing the switches and adding more environments to it +as you see fit--have a look at \cref{lst:mysettings} for an example +that uses four tabs for the default indent, adds the \lstinline!tabbing! +environment to the list of environments that contains alignment delimiters, +and adds the changes we described on \cpageref{page:examsettings}. + +\begin{cmhlistings}[style=yaml]{\lstinline!mysettings.yaml! (example)}{lst:mysettings} +# Default value of indentation +defaultIndent: "\t\t\t\t" + +# environments that have tab delimiters, add more +# as needed +lookForAlignDelims: + tabbing: 1 + +# If you use the exam documentclass, you might +# like the following settings +# environments that have \item commands +indentAfterItems: + parts: 1 + +# commands to be treated like \item +itemNames: + part: 1 +\end{cmhlistings} + +You can make sure that your settings are loaded by checking \lstinline!indent.log! +for details--if you have specified a path that \lstinline!latexindent.pl! doesn't +recognize then you'll get a warning, otherwise you'll get confirmation that +\lstinline!latexindent.pl! has read your settings file \footnote{Windows users + may find that they have to end \lstinline!.yaml! files with a blank line}. + +\begin{warning} + When editing \lstinline!.yaml! files it is \emph{extremely} important + to remember how sensitive they are to spaces. I highly recommend copying + and pasting from \lstinline!defaultSettings.yaml! when you create your + first \lstinline!whatevernameyoulike.yaml! file. + + If \lstinline!latexindent.pl! can not read your \lstinline!.yaml! file it + will tell you so in \lstinline!indent.log!. +\end{warning} + +\subsection{\lstinline!localSettings.yaml!}\label{sec:localsettings} +You may remember on \cpageref{page:localswitch} we discussed the \lstinline!-l! switch +that tells \lstinline!latexindent.pl! to look for \lstinline!localSettings.yaml! in the +\emph{same directory} as \lstinline!myfile.tex!. This settings file will +be read \emph{after} \lstinline!defaultSettings.yaml! and, assuming they exist, +user settings. + +The \emph{local} settings file may be called \lstinline!localSettings.yaml!, and +it can contain any switches that you'd +like to change--a sample is shown in \cref{lst:localSettings}. + +\begin{cmhlistings}[style=yaml]{\lstinline!localSettings.yaml! (example)}{lst:localSettings} +# Default value of indentation +defaultIndent: " " + +# environments that have tab delimiters, add more +# as needed +lookForAlignDelims: + tabbing: 0 + +# verbatim environments- environments specified +# in this hash table will not be changed at all! +verbatimEnvironments: + cmhenvironment: 0 +\end{cmhlistings} + +You can make sure that your local settings are loaded by checking \lstinline!indent.log! +for details--if \lstinline!localSettings.yaml! can not be read then you will +get a warning, otherwise you'll get confirmation that +\lstinline!latexindent.pl! has read \lstinline!localSettings.yaml!. + +If you'd prefer to name your \lstinline!localSettings.yaml! file something different, (say, \lstinline!myyaml.yaml!) then +you can call \lstinline!latexindent.pl! using, for example, \lstinline[breaklines=true]!latexindent.pl -l=myyaml.yaml myfile.tex!. + +\subsection{Settings load order}\label{sec:loadorder} +\lstinline!latexindent.pl! loads the settings files in the following order: +\begin{enumerate} + \item \lstinline!defaultSettings.yaml! is always loaded, and can not be renamed; + \item \lstinline!anyUserSettings.yaml! and any other arbitrarily-named files specified in \lstinline!indentconfig.yaml!; + \item \lstinline!localSettings.yaml! but only if found in the same directory as \lstinline!myfile.tex! and called + with \lstinline!-l! switch; this file can be renamed, provided that the call to \lstinline!latexindent.pl! is adjusted + accordingly (see \cref{sec:localsettings}). +\end{enumerate} +A visual representation of this is given in \cref{fig:loadorder}. + +\begin{figure} + \centering + \begin{tikzpicture}[ + needed/.style={very thick, draw=blue,fill=blue!20, + text centered, minimum height=2.5em,rounded corners=1ex}, + optional/.style={draw=black, very thick,scale=0.8, + text centered, minimum height=2.5em,rounded corners=1ex}, + optionalfill/.style={fill=black!10}, + connections/.style={draw=black!30,dotted,line width=3pt,text=red}, + ] + % Draw diagram elements + \node (latexindent) [needed,circle] {\lstinline!latexindent.pl!}; + \node (default) [needed,above right=.5cm of latexindent] {\lstinline!defaultSettings.yaml!}; + \node (indentconfig) [optional,right=of latexindent] {\lstinline!indentconfig.yaml!}; + \node (any) [optional,optionalfill,above right=of indentconfig] {\lstinline!any.yaml!}; + \node (name) [optional,optionalfill,right=of indentconfig] {\lstinline!name.yaml!}; + \node (you) [optional,optionalfill,below right=of indentconfig] {\lstinline!you.yaml!}; + \node (want) [optional,optionalfill,below=of indentconfig] {\lstinline!want.yaml!}; + \node (local) [optional,below=of latexindent] {\lstinline!localSettings.yaml!}; + % Draw arrows between elements + \draw[connections,solid] (latexindent) to[in=-90]node[pos=0.5,anchor=north]{1} (default.south) ; + \draw[connections,optional] (latexindent) -- node[pos=0.5,anchor=north]{2} (indentconfig) ; + \draw[connections,optional] (indentconfig) to[in=-90] (any.south) ; + \draw[connections,optional] (indentconfig) -- (name) ; + \draw[connections,optional] (indentconfig) to[out=-45,in=90] (you) ; + \draw[connections,optional] (indentconfig) -- (want) ; + \draw[connections,optional] (latexindent) -- node[pos=0.5,anchor=west]{3} (local) ; + \end{tikzpicture} + \caption{Schematic of the load order described in \cref{sec:loadorder}; solid lines represent + mandatory files, dotted lines represent optional files. \lstinline!indentconfig.yaml! can + contain as many files as you like--the files will be loaded in order; if you specify + settings for the same field in more than one file, the most recent takes priority. } + \label{fig:loadorder} +\end{figure} + +\subsection{An important example} +I was working on a document that had the text shown in \cref{lst:casestudy}. +\begin{cmhlistings}[style=demo,escapeinside={(*@}{@*)}]{When to set \lstinline!alwaysLookforSplitBrackets=0!}{lst:casestudy} +Hence determine how many zeros the function $h(x)=f(x)-g(x)$ +has on the interval $[0,9)$.(*@\label{line:interval1}@*) +\begin{shortsolution} + The function $h$ has $10$ zeros on the interval $[0,9)$.(*@\label{line:interval2}@*) +\end{shortsolution} +\end{cmhlistings} +I had allowed \lstinline!alwaysLookforSplitBrackets=1!, which is the default setting. +Unfortunately, this caused undesired results, as \lstinline!latexindent.pl! thought that the opening +\lstinline![! in the interval notation (\cref{line:interval1,line:interval2}) +was an opening brace that needed to be closed (with a corresponding \lstinline!]!). Clearly +this was inappropriate, but also expected since \lstinline!latexindent.pl! was simply +following its matching rules. + +In this particular instance, I set up \lstinline!localSettings.yaml! +to contain \lstinline!alwaysLookforSplitBrackets: 0! and then specified the commands +that could split brackets across lines (such as \lstinline!begin{axis}!) individually +in \lstinline!checkunmatchedbracket!. Another option would have been to wrap the +the line in an environment from \lstinline!noIndentBlock! which treats its contents +as a verbatim environment. + + +\section{Known limitations}\label{sec:knownlimitations} +There are a number of known limitations of the script, and almost certainly quite a +few that are \emph{unknown}! + +The main limitation is to do with the alignment routine of environments that contain +delimiters--in other words, environments that are entered in \lstinline!lookForAlignDelims!. +Indeed, this is the only part of the script that can \emph{potentially} remove +lines from \lstinline!myfile.tex!. Note that \lstinline!indent.log! will always +finish with a comparison of line counts before and after. + +The routine works well for `standard' blocks of code that have the same number of \lstinline!&! +per line, but it will not do anything for lines that do not--such examples +include \lstinline!tabular! environments that use \lstinline!\multicolumn! or +perhaps spread cell contents across multiple lines. For each alignment block (\lstinline!tabular!, +\lstinline!align!, etc) \lstinline!latexindent.pl! first of all makes a record +of the maximum number of \lstinline!&!; if each row does not have that +number of \lstinline!&! then it will not try to format that row. Details +will be given in \lstinline!indent.log! assuming that \lstinline!trace! mode +is active. + +If you have a \lstinline!verbatim!-like environment inside a \lstinline!tabular!-like +environment, the \lstinline!verbatim! environment \emph{will} be formatted, which +is probably not what you want. I hope to address this in future versions, but for the +moment wrap it in a \lstinline!noIndentBlock! (see \cpageref{lst:noIndentBlockdemo}). + +You can run \lstinline!latexindent! on \lstinline!.sty!, \lstinline!.cls! and any filetypes +that you specify in \lstinline[breaklines=true]!fileExtensionPreference! (see \vref{lst:fileExtensionPreference}); +if you find a case in which the script struggles, please feel free +to report it at \cite{latexindent-home}, and +in the meantime, consider using a \lstinline!noIndentBlock! (see \cpageref{lst:noIndentBlockdemo}). + +I hope that this script is useful to some; if you find an example where the +script does not behave as you think it should, the best way to contact me is to +report an issue on \cite{latexindent-home}; otherwise, feel free to find me on +the \url{http://tex.stackexchange.com} site; I'm often around +and in the chat room. + +\nocite{*} +\section{References} +\printbibliography[heading=subbibnumbered,title={External links},notkeyword=contributor] +\printbibliography[env=specialbib,heading=subbibnumbered,title={Contributors\label{sec:contributors}},keyword=contributor] + +\appendix +\section{Required \lstinline!Perl! modules}\label{sec:requiredmodules} +If you intend to use \lstinline!latexindent.pl! and \emph{not} one of the supplied standalone executable files, then you will need a few standard Perl modules--if you can run the +minimum code in \cref{lst:helloworld} (\lstinline!perl helloworld.pl!) then you will be able to run \lstinline!latexindent.pl!, otherwise you may +need to install the missing modules. + +\begin{cmhlistings}[language=Perl]{\lstinline!helloworld.pl!}{lst:helloworld} +#!/usr/bin/perl + +use strict; +use warnings; +use FindBin; +use YAML::Tiny; +use File::Copy; +use File::Basename; +use Getopt::Long; +use File::HomeDir; + +print "hello world"; +exit; +\end{cmhlistings} +My default installation on Ubuntu 12.04 did \emph{not} come +with all of these modules as standard, but Strawberry Perl for Windows \cite{strawberryperl} +did. + +Installing the modules given in \cref{lst:helloworld} will vary depending on your +operating system and \lstinline!Perl! distribution. For example, Ubuntu users +might visit the software center, or else run +\begin{lstlisting}[numbers=none] +sudo perl -MCPAN -e 'install "File::HomeDir"' +\end{lstlisting} + +Linux users may be interested in exploring Perlbrew \cite{perlbrew}; possible installation and setup +options follow for Ubuntu (other distributions will need slightly different commands). +\begin{lstlisting}[numbers=none] +sudo apt-get install perlbrew +perlbrew install perl-5.20.1 +perlbrew switch perl-5.20.1 +sudo apt-get install curl +curl -L http://cpanmin.us | perl - App::cpanminus +cpanm YAML::Tiny +cpanm File::HomeDir +\end{lstlisting} + +Strawberry Perl users on Windows might use +\lstinline!CPAN client!. All of the modules are readily available on CPAN \cite{cpan}. + +As of Version 2.1, \lstinline!indent.log! will contain details of the location +of the Perl modules on your system. \lstinline!latexindent.exe! is a standalone +executable for Windows (and therefore does not require a Perl distribution) and caches copies of the Perl modules onto your system; if you +wish to see where they are cached, use the \lstinline!trace! option, e.g \lstinline!latexindent.exe -t myfile.tex!. + +\section{The \lstinline!arara! rule} +The \lstinline!arara! rule (\lstinline!indent.yaml!) contains lines such as those +given in \cref{lst:arararule}. With this setup, the user \emph{always} has +to specify whether or not they want (in this example) to use the \lstinline!trace! +identifier. +\begin{cmhlistings}[style=yaml,numbers=none]{The \lstinline!arara! rule}{lst:arararule} +... +arguments: +- identifier: trace + flag: @{ isTrue( parameters.trace, "-t" ) } +... +\end{cmhlistings} + +If you would like to have the \lstinline!trace! option on by default every time you +call \lstinline!latexindent.pl! from \lstinline!arara! (without having to write \lstinline!% arara: indent: {trace: yes}!), then simply +amend \cref{lst:arararule} so that it looks like \cref{lst:arararulemod}. +\begin{cmhlistings}[style=yaml,numbers=none]{The \lstinline!arara! rule (modified)}{lst:arararulemod} +... +arguments: +- identifier: trace + flag: @{ isTrue( parameters.trace, "-t" ) } + default: "-t" +... +\end{cmhlistings} + +With this modification in place, you now simply to write \lstinline!% arara: indent! and +\lstinline!trace! mode will be activated by default. If you wish to turn off \lstinline!trace! +mode then you can write \lstinline!% arara: indent: {trace: off}!. + +Of course, you can apply these types of modifications to \emph{any} of the identifiers, +but proceed with caution if you intend to do this for \lstinline!overwrite!. + +\section{Updating the \lstinline!path! variable}\label{sec:updating-path} +\lstinline!latexindent.pl! ships with a few scripts that can update the \lstinline!path! variables +\footnote{Thanks to \cite{jasjuang} for this feature!}. If you're +on a Linux or Mac machine, then you'll want \lstinline!CMakeLists.txt! from \cite{latexindent-home}. +\subsection{Add to path for Linux} +To add \lstinline!latexindent.pl! to the path for Linux, follow these steps: +\begin{enumerate} + \item download \lstinline!latexindent.pl!, \lstinline!defaultSettings.yaml!, to your + chosen directory from \cite{latexindent-home} ; + \item within your directory, create a directory called \lstinline!path-helper-files! and + download \lstinline!CMakeLists.txt! and \lstinline!cmake_uninstall.cmake.in! + from \cite{latexindent-home}/path-helper-files to this directory; + \item run \lstinline!ls /usr/local/bin! to see what is \emph{currently} in there; + \item run the commands given in \cref{linux-add-to-path}; + \item run \lstinline!ls /usr/local/bin! again to check that \lstinline!latexindent.pl! and \lstinline!defaultSettings.yaml! + have been added. +\end{enumerate} +\begin{cmhlistings}[style=yaml,numbers=none]{Add to path from a Linux terminal}{linux-add-to-path} +sudo apt-get install cmake +sudo apt-get update && sudo apt-get install build-essential +mkdir build && cd build +cmake ../path-helper-files +sudo make install +\end{cmhlistings} +To \emph{remove} the files, run \lstinline!sudo make uninstall!. +\subsection{Add to path for Windows} +To add \lstinline!latexindent.exe! to the path for Windows, follow these steps: +\begin{enumerate} + \item download \lstinline!latexindent.exe!, \lstinline!defaultSettings.yaml!, \lstinline!add-to-path.bat! + from \cite{latexindent-home} to your chosen directory; + \item open a command prompt and run \lstinline!echo %path%! to see what is \emph{currently} in your \lstinline!%path%! variable; + \item right click on \lstinline!add-to-path.bat! and \emph{Run as administrator}; + \item log out, and log back in; + \item open a command prompt and run \lstinline!echo %path%! to check that the appropriate directory has been added to your + \lstinline!%path%!. +\end{enumerate} +To \emph{remove} the directory from your \lstinline!%path%!, run \lstinline!remove-from-path.bat! as administrator. +\end{document} diff --git a/Master/texmf-dist/doc/support/latexindent/documentation/manual.pdf b/Master/texmf-dist/doc/support/latexindent/documentation/manual.pdf deleted file mode 100644 index 0fec7c336b1..00000000000 Binary files a/Master/texmf-dist/doc/support/latexindent/documentation/manual.pdf and /dev/null differ diff --git a/Master/texmf-dist/doc/support/latexindent/documentation/manual.tex b/Master/texmf-dist/doc/support/latexindent/documentation/manual.tex deleted file mode 100644 index a34339c06cd..00000000000 --- a/Master/texmf-dist/doc/support/latexindent/documentation/manual.tex +++ /dev/null @@ -1,1247 +0,0 @@ -% arara: pdflatex -% !arara: bibtex -% !arara: pdflatex -% !arara: pdflatex -% !arara: pdflatex -% !arara: indent: {overwrite: no, trace: yes, localSettings: yes, silent: yes} -% http://tex.stackexchange.com/questions/122135/how-to-add-a-png-icon-on-the-right-side-of-a-tcolorbox-title -\begin{filecontents}{mybib.bib} - @online{cmh:videodemo, - title="Video demonstration of latexindet.pl on youtube", - url="http://www.youtube.com/watch?v=s_AMmNVg5WM"} - @online{cpan, - title="CPAN: Comprehensive Perl Archive Network", - url="http://www.cpan.org/"} - @online{strawberryperl, - title="Strawberry Perl", - url="http://strawberryperl.com/"} - @online{cmhblog, - title="A Perl script for indenting tex files", - url="http://tex.blogoverflow.com/2012/08/a-perl-script-for-indenting-tex-files/"} -\end{filecontents} -\documentclass[11pt]{article} -% 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. -% -% See . -\usepackage[left=4.5cm,right=2.5cm,showframe=false, -top=2cm,bottom=1.5cm]{geometry} % page setup -\usepackage{parskip} % paragraph skips -\usepackage{booktabs} % beautiful tables -\usepackage{listings} % nice verbatim environments -\usepackage{titlesec} % customize headings -\usepackage{changepage} % adjust width of page -\usepackage{fancyhdr} % headers & footers -\usepackage[sc,format=hang,font=small]{caption} % captions -\usepackage[backend=bibtex]{biblatex} % bibliography -\usepackage{tcolorbox} % framed environments -\usepackage[charter]{mathdesign} % changes font -\usepackage[expansion=false,kerning=true]{microtype} % better kerning -\usepackage{enumitem} % custom lists -\usepackage{tikz} % so so much -\usepackage{tcolorbox} -% tcolorbox libraries -\tcbuselibrary{breakable,skins,listings} -\usetikzlibrary{positioning} -\usepackage{varioref} % clever referencing -\usepackage[colorlinks=true,linkcolor=blue,citecolor=black]{hyperref} -\usepackage{cleveref} - -\addbibresource{mybib} - -%\newmdenv[linecolor=red,innertopmargin=.5cm,linewidth=3pt, -% splittopskip=\topskip,skipbelow=0pt,% -%]{warning} - - -\newtcolorbox{warning}{parbox=false,breakable,enhanced,arc=0mm,colback=red!5,colframe=red,leftrule=12mm,% - overlay={\node[anchor=north west,outer sep=2pt] at (frame.north west) {\includegraphics[width=8mm]{warning}}; }} - -\makeatletter -\tcbset{ - addtolol/.style={list entry={\kvtcb@title},add to list={lol}{lstlisting}}, -} - -\newtcblisting[use counter=lstlisting]{cmhlistings}[3][]{% - width=\linewidth, - breakable, - colback=blue!5!white, - colframe=white!85!black, - top=0cm, - bottom=0cm, - left=6mm, - listing only, - listing options={#1}, - center title, - title={\color{black}{\scshape Listing \thetcbcounter}: ~#2},label={#3}, - addtolol, -} - -\lstset{% - basicstyle=\small\ttfamily,language={[LaTeX]TeX}, - % numbers=left, - numberstyle=\ttfamily%\small, - breaklines=true, - % frame=single,framexleftmargin=8mm, xleftmargin=8mm, - % prebreak = \raisebox{0ex}[0ex][0ex]{\ensuremath{\hookrightarrow}}, - % backgroundcolor=\color{green!5},frameround=fttt, - % rulecolor=\color{blue!70!black}, - keywordstyle=\color{blue}, % keywords - commentstyle=\color{purple}, % comments - tabsize=3, - %xleftmargin=1.5em, -}% -\lstdefinestyle{yaml}{% - numbers=left, - numberstyle=\color{black},} -\lstdefinestyle{demo}{ - numbers=none, - linewidth=1.25\textwidth, - columns=fullflexible, -} -\newcommand{\verbitem}[1]{\small\ttfamily{#1}} -% stolen from arara.sty http://mirrors.med.harvard.edu/ctan/support/arara/doc/arara.sty -%\lstnewenvironment{yaml}[1][]{\lstset{% -% basicstyle=\ttfamily, -% numbers=left, -% xleftmargin=1.5em, -% breaklines=true, -% numberstyle=\ttfamily\small, -% columns=flexible, -% mathescape=false, -% #1, -%}} -%{} - -\newcommand{\fixthis}[1] -{% - \marginpar{\huge \color{red} \framebox{FIX}}% - \typeout{FIXTHIS: p\thepage : #1^^J}% -} -% custom section -\titleformat{\section} -{\normalfont\Large\bfseries} -{\llap{\thesection\hskip.5cm}} -{0pt} -{} -% custom subsection -\titleformat{\subsection} -{\normalfont\bfseries} -{\llap{\thesubsection\hskip.5cm}} -{0pt} -{} -% custom subsubsection -\titleformat{\subsubsection} -{\normalfont\bfseries} -{\llap{\thesubsubsection\hskip.5cm}} -{0pt} -{} - - -\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{-5pt plus 2pt minus 2pt} -\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt} -\titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{-6pt plus 2pt minus 2pt} - - -% cleveref settings -\crefname{table}{Table}{Tables} -\Crefname{table}{Table}{Tables} -\crefname{figure}{Figure}{Figures} -\Crefname{figure}{Figure}{Figures} -\crefname{section}{Section}{Sections} -\Crefname{section}{Section}{Sections} -\crefname{listing}{Listing}{Listings} -\Crefname{listing}{Listing}{Listings} - -\begin{document} - -% \begin{noindent} - \title{\lstinline[basicstyle=\huge\ttfamily]!latexindent.pl!\\[1cm] - Version 2.1R} -% \end{noindent} -\author{Chris Hughes \footnote{smr01cmh AT users.sourceforge.net}} -\maketitle -\begin{abstract} - \lstinline!latexindent.pl! is a \lstinline!Perl! script that indents \lstinline!.tex! - files according to an indentation scheme that the user can modify to suit their - taste. Environments, including those with alignment delimiters (such as \lstinline!tabular!), - and commands, including those that can split braces and brackets across lines, - are \emph{usually} handled correctly by the script. Options for \lstinline!verbatim!-like - environments and indentation after headings (such as \lstinline!\chapter!, \lstinline!\section!, etc) - are also available. -\end{abstract} - -\tableofcontents -\lstlistoflistings - -\section{Before we begin} -\subsection{Thanks} -I first created \lstinline!latexindent.pl! to help me format chapter files -in a big project. After I blogged about it on the -\TeX{} stack exchange \cite{cmhblog} I received some positive feedback and -follow-up feature requests. A big thank you to Harish Kumar who has really -helped to drive the script forward and has put it through a number of challenging -tests--I look forward to more challenges in the future Harish! - -The \lstinline!yaml!-based interface of \lstinline!latexindent.pl! was inspired -by the wonderful \lstinline!arara! tool; any similarities are deliberate, and -I hope that it is perceived as the compliment that it is. Thank you to Paulo Cereda and the -team for releasing this awesome tool; I initially worried that I was going to -have to make a GUI for \lstinline!latexindent.pl!, but the release of \lstinline!arara! -has meant there is no need. Thank you to Paulo for all of your advice and -encouragement. - -\subsection{License} -\lstinline!latexindent.pl! is free and open source, and it always will be. -Before you start using it on any important files, bear in mind that \lstinline!latexindent.pl! has the option to overwrite your \lstinline!.tex! files. -It will always make at least one backup (you can choose how many it makes, see \cpageref{page:onlyonebackup}) -but you should still be careful when using it. The script has been tested on many -files, but there are some known limitations (see \cref{sec:knownlimitations}). -You, the user, are responsible for ensuring that you maintain backups of your files -before running \lstinline!latexindent.pl! on them. I think it is important at this -stage to restate an important part of the license here: -\begin{quote}\itshape - 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. -\end{quote} -There is certainly no malicious intent in releasing this script, and I do hope -that it works as you expect it to--if it does not, please first of all -make sure that you have the correct settings, and then feel free to let me know with a -complete minimum working example as I would like to improve the code as much as possible. - -\begin{warning} - Before you try the script on anything important (like your thesis), test it - out on the sample files that come with it in the \lstinline!success! directory. -\end{warning} - - -\section{Demonstration: before and after} -Let's give a demonstration of some before and after code--after all, you probably -won't want to try the script if you don't much like the results. You might also -like to watch the video demonstration I made on youtube \cite{cmh:videodemo} - -As you look at \crefrange{lst:filecontentsbefore}{lst:pstricksafter}, remember -that \lstinline!latexindent.pl! is just following its rules--there is nothing -particular about these code snippets. All of the rules can be modified -so that each user can personalize their indentation scheme. - -In each of the samples given in \crefrange{lst:filecontentsbefore}{lst:pstricksafter} -the `before' case is a `worst case scenario' with no effort to make indentation. The `after' -result would be the same, regardless of the leading white space at the beginning of -each line which is stripped by \lstinline!latexindent.pl! (unless a \lstinline!verbatim!-like -environment or \lstinline!noIndentBlock! is specified--more on this in \cref{sec:defuseloc}). - -\begin{adjustwidth}{-2cm}{2cm} - \noindent - \begin{minipage}{.6\textwidth} - \begin{cmhlistings}[style=demo]{\lstinline!filecontents! before}{lst:filecontentsbefore} -\begin{filecontents}{mybib.bib} -@online{strawberryperl, -title="Strawberry Perl", -url="http://strawberryperl.com/"} -@online{cmhblog, -title="A Perl script ... -url="... -\end{filecontents} - \end{cmhlistings} - \end{minipage}% - \noindent - \begin{minipage}{.6\textwidth} - \begin{cmhlistings}[style=demo]{\lstinline!filecontents! after}{lst:filecontentsafter} -\begin{filecontents}{mybib.bib} - @online{strawberryperl, - title="Strawberry Perl", - url="http://strawberryperl.com/"} - @online{cmhblog, - title="A Perl script for ... - url="... -\end{filecontents} - \end{cmhlistings} - \end{minipage} - \begin{minipage}{.6\textwidth} - \begin{cmhlistings}[style=demo]{\lstinline!tikzset! before}{lst:tikzsetbefore} -\tikzset{ -shrink inner sep/.code={ -\pgfkeysgetvalue... -\pgfkeysgetvalue... -} -} - \end{cmhlistings} - \end{minipage}% - \begin{minipage}{.6\textwidth} - \begin{cmhlistings}[style=demo]{\lstinline!tikzset! after}{lst:tikzsetafter} -\tikzset{ - shrink inner sep/.code={ - \pgfkeysgetvalue... - \pgfkeysgetvalue... - } -} - \end{cmhlistings} - \end{minipage} - \begin{minipage}{.6\textwidth} - \begin{cmhlistings}[style=demo]{\lstinline!pstricks! before}{lst:pstricksbefore} -\def\Picture#1{% -\def\stripH{#1}% -\begin{pspicture}[showgrid... -\psforeach{\row}{% -{{3,2.8,2.7,3,3.1}},% <=== Only this -{2.8,1,1.2,2,3},% -... -}{% -\expandafter... -} -\end{pspicture}} - \end{cmhlistings} - \end{minipage}% - \begin{minipage}{.6\textwidth} - \begin{cmhlistings}[style=demo]{\lstinline!pstricks! after}{lst:pstricksafter} -\def\Picture#1{% - \def\stripH{#1}% - \begin{pspicture}[showgrid... - \psforeach{\row}{% - {{3,2.8,2.7,3,3.1}},% <=== - {2.8,1,1.2,2,3},% - ... - }{% - \expandafter... - } - \end{pspicture}} - \end{cmhlistings} - \end{minipage} -\end{adjustwidth} - -\section{How to use the script} -There are two ways to use \lstinline!latexindent.pl!: from the command line, -and using \lstinline!arara!. We will discuss how to change the settings and behaviour -of the script in \cref{sec:defuseloc}. - -\lstinline!latexindent.pl! ships with \lstinline!latexindent.exe! for Windows -users, so that you can use the script with or without a Perl distribution. -If you plan to use \lstinline!latexindent.pl! (i.e, the original Perl script) then you will -need a few standard Perl modules--see \vref{sec:requiredmodules} for details. - -In what follows, we will always refer to \lstinline!latexindent.pl!, but depending on -your operating system and preference, you might substitute \lstinline!latexindent.exe! or -simply \lstinline!latexindent!. - -\subsection{From the command line}\label{sec:commandline} -\lstinline!latexindent.pl! has a number of different switches/flags/options, which -can be combined in any way that you like. \lstinline!latexindent.pl! -produces a \lstinline!.log! file, \lstinline!indent.log! every time it -is run. There is a base of information that is written to \lstinline!indent.log!, -but other additional information will be written depending -on which of the following options are used. - -\begin{itemize}[labelsep=.5cm] - \item[] \lstinline!latexindent.pl! - - This will output a welcome message to the terminal, including the version number - and available options. - \item[\verbitem{-h}] \lstinline!latexindent.pl -h! - - As above this will output a welcome message to the terminal, including the version number - and available options. - \item[] \lstinline!latexindent.pl myfile.tex! - - This will operate on \lstinline!myfile.tex!, but will simply output to your terminal; \lstinline!myfile.tex! will not be changed in any way using this command. - \item[\verbitem{-w}] \lstinline!latexindent.pl -w myfile.tex! - - This \emph{will} overwrite \lstinline!myfile.tex!, but it will - make a copy of \lstinline!myfile.tex! first. You can control the name of - the extension (default is \lstinline!.bak!), and how many different backups are made-- - more on this in \cref{sec:defuseloc}; see \lstinline!backupExtension! and \lstinline!onlyOneBackUp!. - - Note that if \lstinline!latexindent.pl! can not create the backup, then it - will exit without touching your original file; an error message will be given - asking you to check the permissions of the backup file. - \item[\verbitem{-o}] \lstinline!latexindent.pl -o myfile.tex outputfile.tex! - - This will indent \lstinline!myfile.tex! and output it to \lstinline!outputfile.tex!, - overwriting it (\lstinline!outputfile.tex!) if it already exists. Note that if \lstinline!latexindent.pl! is called with both - the \lstinline!-w! and \lstinline!-o! switches, then \lstinline!-w! will - be ignored and \lstinline!-o! will take priority (this seems safer than the - other way round). - - Note that using \lstinline!-o! is equivalent to using \lstinline!latexindent.pl myfile.tex > outputfile.tex! - \item[\verbitem{-s}] \lstinline!latexindent.pl -s myfile.tex! - - Silent mode: no output will be given to the terminal. - \item[\verbitem{-t}] \lstinline!latexindent.pl -t myfile.tex! - - Tracing mode: verbose output will be given to \lstinline!indent.log!. This - is useful if \lstinline!latexindent.pl! has made a mistake and you're - trying to find out where and why. You might also be interested in learning - about \lstinline!latexindent.pl!'s thought process--if so, this - switch is for you. - \item[\verbitem{-l}] \lstinline!latexindent.pl -l myfile.tex! - - \label{page:localswitch} - Local settings: you might like to read \cref{sec:defuseloc} before - using this switch. \lstinline!latexindent.pl! will always load \lstinline!defaultSettings.yaml! - and if it is called with the \lstinline!-l! switch and it finds \lstinline!localSettings.yaml! - in the same directory as \lstinline!myfile.tex! then these settings will be - added to the indentation scheme. Information will be given in \lstinline!indent.log! on - the success or failure of loading \lstinline!localSettings.yaml!. - \item[\verbitem{-d}] \lstinline!latexindent.pl -d myfile.tex! - - Only \lstinline!defaultSettings.yaml!: you might like to read \cref{sec:defuseloc} before - using this switch. By default, \lstinline!latexindent.pl! will always search for - \lstinline!indentconfig.yaml! or \lstinline!.indentconfig.yaml! in your home directory. If you would prefer it not to do so - then (instead of deleting or renaming \lstinline!indentconfig.yaml!/\lstinline!.indentconfig.yaml!) you can simply - call the script with the \lstinline!-d! switch; note that this will also tell - the script to ignore \lstinline!localSettings.yaml! even if it has been called with the - \lstinline!-l! switch. - - \item[\verbitem{-c}]\lstinline!latexindent.pl -c=/path/to/directory/ myfile.tex! - - If you wish to have backup files and \lstinline!indent.log! written to a directory - other than the current working directory, then you can send these `cruft' files - to another directory. - % this switch was made as a result of http://tex.stackexchange.com/questions/142652/output-latexindent-auxiliary-files-to-a-different-directory -\end{itemize} - -\subsection{From \lstinline!arara!} -Using \lstinline!latexindent.pl! from the command line is fine for some folks, but -others may find it easier to use from \lstinline!arara!. \lstinline!latexindent.pl! -ships with an \lstinline!arara! rule, \lstinline!indent.yaml!, which can be copied -to the directory of -your other \lstinline!arara! rules; otherwise you can add the directory in which \lstinline!latexindent.pl! -resides to your \lstinline!araraconfig.yaml! file. - -Once you have told \lstinline!arara! where to find your \lstinline!indent! rule, -you can use it any of the ways described in \cref{lst:arara} (or combinations thereof). -In fact, \lstinline!arara! allows yet greater flexibility--you can use \lstinline!yes/no!, \lstinline!true/false!, or \lstinline!on/off! to toggle the various options. - -\begin{cmhlistings}[style=demo,escapeinside={(*@}{@*)}]{\lstinline!arara! sample usage}{lst:arara} -%(*@@*) arara: indent -%(*@@*) arara: indent: {overwrite: yes} -%(*@@*) arara: indent: {output: myfile.tex} -%(*@@*) arara: indent: {silent: yes} -%(*@@*) arara: indent: {trace: yes} -%(*@@*) arara: indent: {localSettings: yes} -%(*@@*) arara: indent: {onlyDefault: on} -%(*@@*) arara: indent: { cruft: /home/cmhughes/Desktop } -\documentclass{article} -... -\end{cmhlistings} - -Hopefully the use of these rules is fairly self-explanatory, but for completeness -\cref{tab:orbsandswitches} shows the relationship between \lstinline!arara! directive arguments and the -switches given in \cref{sec:commandline}. - -\begin{table}[!ht] - \centering - \caption{\lstinline!arara! directive arguments and corresponding switches} - \label{tab:orbsandswitches} - \begin{tabular}{lc} - \toprule - \lstinline!arara! directive argument & switch \\ - \midrule - \lstinline!overwrite! & \lstinline!-w! \\ - \lstinline!output! & \lstinline!-o! \\ - \lstinline!silent! & \lstinline!-s! \\ - \lstinline!trace! & \lstinline!-t! \\ - \lstinline!localSettings! & \lstinline!-l! \\ - \lstinline!onlyDefault! & \lstinline!-d! \\ - \lstinline!cruft! & \lstinline!-c! \\ - \bottomrule - \end{tabular} -\end{table} - -The \lstinline!cruft! directive does not work well when used with -directories that contain spaces. - -\section{default, user, and local settings}\label{sec:defuseloc} -\lstinline!latexindent.pl! loads its settings from \lstinline!defaultSettings.yaml! -(rhymes with camel). The idea is to separate the behaviour of the script -from the internal working--this is very similar to the way that we separate content -from form when writing our documents in \LaTeX. - -\subsection{\lstinline!defaultSettings.yaml!} -If you look in \lstinline!defaultSettings.yaml! you'll find the switches -that govern the behaviour of \lstinline!latexindent.pl!. If you're not sure where -\lstinline!defaultSettings.yaml! resides on your computer, don't worry as \lstinline!indent.log! -will tell you where to find it. -\lstinline!defaultSettings.yaml! is commented, -but here is a description of what each switch is designed to do. The default -value is given in each case. - -You can certainly feel free to edit \lstinline!defaultSettings.yaml!, but -this is not ideal as it may be overwritten when you update your distribution-- -all of your hard work tweaking the script would be undone! Don't worry, -there's a solution--feel free to peek ahead to \cref{sec:indentconfig} if you like. -\begin{itemize} - \item[\verbitem{defaultIndent}] \lstinline!"\t"! - - This is the default indentation (\lstinline!\t! means a tab) used in the absence of other details - for the command or environment we are working with--see \lstinline!indentRules! - for more details (\cpageref{page:indentRules}). - - If you're interested in experimenting with \lstinline!latexindent.pl! then you - can \emph{remove} all indentation by setting \lstinline!defaultIndent: ""! - \item[\verbitem{backupExtension}] \lstinline!.bak! - - If you call \lstinline!latexindent.pl! with the \lstinline!-w! switch (to overwrite - \lstinline!myfile.tex!) then it will create a backup file before doing - any indentation: \lstinline!myfile.bak0! - - By default, every time you call \lstinline!latexindent.pl! after this with - the \lstinline!-w! switch it will create \lstinline!myfile.bak1!, \lstinline!myfile.bak2!, - etc. - \item[\verbitem{onlyOneBackUp}] \lstinline!0! - - \label{page:onlyonebackup} - If you don't want a backup for every time that you call \lstinline!latexindent.pl! (so - you don't want \lstinline!myfile.bak1!, \lstinline!myfile.bak2!, etc) and you simply - want \lstinline!myfile.bak! (or whatever you chose \lstinline!backupExtension! to be) - then change \lstinline!onlyOneBackUp! to \lstinline!1!. - - \item[\verbitem{maxNumberOfBackUps}]\lstinline!0! - - Some users may only want a finite number of backup files, - say at most $3$, in which case, they can change this switch. - The smallest value of \lstinline!maxNumberOfBackUps! is $0$ which will \emph{not} - prevent backup files being made--in this case, the behaviour will be dictated - entirely by \lstinline!onlyOneBackUp!. - %\footnote{This was a feature request made on \href{https://github.com/cmhughes/latexindent.plx}{github}} - \item[\verbitem{cycleThroughBackUps}]\lstinline!0! - - Some users may wish to cycle through backup files, by deleting the - oldest backup file and keeping only the most recent; for example, - with \lstinline!maxNumberOfBackUps: 4!, and \lstinline!cycleThroughBackUps! - set to \lstinline!1! then the \lstinline!copy! procedure given in \cref{lst:cycleThroughBackUps} - would be obeyed. - - \begin{cmhlistings}[language=Perl]{\lstinline!cycleThroughBackUps!}{lst:cycleThroughBackUps} -copy myfile.bak1 to myfile.bak0 -copy myfile.bak2 to myfile.bak1 -copy myfile.bak3 to myfile.bak2 -copy myfile.bak4 to myfile.bak3 - \end{cmhlistings} - - \item[\verbitem{indentPreamble}] \lstinline!0! - - The preamble of a document can sometimes contain some trickier code - for \lstinline!latexindent.pl! to work with. By default, \lstinline!latexindent.pl! - won't try to operate on the preamble, but if you'd like it to try then - change \lstinline!indentPreamble! to \lstinline!1!. - \item[\verbitem{alwaysLookforSplitBraces}] \lstinline!1! - - This switch tells \lstinline!latexindent.pl! to look for commands that - can split \emph{braces} across lines, such as \lstinline!parbox!, \lstinline!tikzset!, etc. In older - versions of \lstinline!latexindent.pl! you had to specify each one in \lstinline!checkunmatched!--this - clearly became tedious, hence the introduction of \lstinline!alwaysLookforSplitBraces!. - - \emph{As long as you leave this switch on (set to 1) you don't need to specify which - commands can split braces across lines--you can ignore the - fields \lstinline!checkunmatched! and \lstinline!checkunmatchedELSE! described - later on \cpageref{lst:checkunmatched}}. - \item[\verbitem{alwaysLookforSplitBrackets}] \lstinline!1! - - This switch tells \lstinline!latexindent.pl! to look for commands that - can split \emph{brackets} across lines, such as \lstinline!psSolid!, \lstinline!pgfplotstabletypeset!, - etc. In older versions of \lstinline!latexindent.pl! you had to specify each one in \lstinline!checkunmatchedbracket!-- - this clearly became tedious, hence the introduction of \lstinline!alwaysLookforSplitBraces!. - - \emph{As long as you leave this switch on (set to 1) you don't need to specify which - commands can split brackets across lines--you can ignore \lstinline!checkunmatchedbracket! described later on - \cpageref{lst:checkunmatched}}. - - \item[\verbitem{removeTrailingWhitespace}] \lstinline!0! - - By default \lstinline!latexindent.pl! indents every line (including empty lines) - which creates `trailing whitespace' feared by most version control systems. If - this option is set to \lstinline!1!, trailing whitespace is removed from all - lines, also non-empty ones. In general this should not create any problems, but - by precaution this option is turned off by default. Thanks to \href{https://github.com/vosskuhle}{vosskuhle} for - providing this feature. - - \item[\verbitem{lookForAlignDelims}] This is the first example of a field - in \lstinline!defaultSettings.yaml! that has more than one line; \cref{lst:aligndelims} - shows more details. - - \begin{cmhlistings}[style=yaml]{\lstinline!lookForAlignDelims!}{lst:aligndelims} -lookForAlignDelims: - tabular: 1 - tabularx: 1 - longtable: 1 - array: 1 - matrix: 1 - bmatrix: 1 - pmatrix: 1 - align: 1 - align*: 1 - alignat: 1 - alignat*: 1 - aligned: 1 - cases: 1 - dcases: 1 - pmatrix: 1 - listabla: 1 - \end{cmhlistings} - - The environments specified in this field will be operated on in a special way by \lstinline!latexindent.pl!. In particular, it will try and align each column by its alignment - tabs. It does have some limitations (discussed further in \cref{sec:knownlimitations}), - but in many cases it will produce results such as those in \cref{lst:tabularbefore,lst:tabularafter}. - - \begin{minipage}{.5\textwidth} - \begin{cmhlistings}[style=demo,columns=fixed]{\lstinline!tabular! before}{lst:tabularbefore} -\begin{tabular}{cccc} -1& 2 &3 &4\\ -5& &6 &\\ -\end{tabular} - \end{cmhlistings} - \end{minipage} - \begin{minipage}{.5\textwidth} - \begin{cmhlistings}[style=demo,columns=fixed]{\lstinline!tabular! after}{lst:tabularafter} -\begin{tabular}{cccc} - 1 & 2 & 3 & 4 \\ - 5 & & 6 & \\ -\end{tabular} - \end{cmhlistings} - \end{minipage} - - If you find that \lstinline!latexindent.pl! does not perform satisfactorily on such - environments then you can either remove them from \lstinline!lookForAlignDelims! altogether, or set the relevant key to \lstinline!0!, for example \lstinline!tabular: 0!, or if you just want to ignore \emph{specific} - instances of the environment, you could wrap them in something from \lstinline!noIndentBlock! (see \cref{lst:noIndentBlock}). - - \item If you have blocks of code that you wish to align at the \& character that - are \emph{not} wrapped in, for example, \lstinline!\begin{tabular}...\end{tabular}!, then you use the mark up - illustrated in \cref{lst:alignmentmarkup}. Note that the \lstinline!%*! must be next to - each other, but that there can be any number of spaces (possibly none) between the - \lstinline!*! and \lstinline!\begin{tabular}!; note also that you may use any - environment name that you have specified in \lstinline!lookForAlignDelims!. - \begin{cmhlistings}[style=demo,columns=fixed]{Mark up for aligning delimiters outside of environments}{lst:alignmentmarkup} -\matrix{% -%* \begin{tabular} - 1 & 2 & 3 & 4 \\ - 5 & & 6 & \\ -%* \end{tabular} -} - \end{cmhlistings} - - \item[\verbitem{verbatimEnvironments}] A field that contains a list of environments - that you would like left completely alone--no indentation will be done - to environments that you have specified in this field--see \cref{lst:verbatimEnvironments}. - - - \begin{cmhlistings}[style=yaml]{\lstinline!verbatimEnvironments!}{lst:verbatimEnvironments} -verbatimEnvironments: - verbatim: 1 - lstlisting: 1 - \end{cmhlistings} - Note that if you put an environment in \lstinline!verbatimEnvironments! - and in other fields such as \lstinline!lookForAlignDelims! or \lstinline!noAdditionalIndent! - then \lstinline!latexindent.pl! will \emph{always} prioritize \lstinline!verbatimEnvironments!. - - \item[\verbitem{noIndentBlock}] If you have a block of code that you don't - want \lstinline!latexindent.pl! to touch (even if it is \emph{not} a verbatim-like - environment) then you can wrap it in an environment from \lstinline!noIndentBlock!; - you can use any name you like for this, provided you populate it as demonstrate in - \cref{lst:noIndentBlock}. - - \begin{cmhlistings}[style=yaml]{\lstinline!noIndentBlock!}{lst:noIndentBlock} -noIndentBlock: - noindent: 1 - cmhtest: 1 - \end{cmhlistings} - - Of course, you don't want to have to specify these as null environments - in your code, so you use them with a comment symbol, \lstinline!%!, followed - by as many spaces (possibly none) as you like; see \cref{lst:noIndentBlockdemo} for - example. - \begin{cmhlistings}[style=demo,escapeinside={(*@}{@*)}]{\lstinline!noIndentBlock! demonstration}{lst:noIndentBlockdemo} -%(*@@*) \begin{noindent} - this code - won't - be touched - by - latexindent.pl! -%(*@@*)\end{noindent} - \end{cmhlistings} - - \item[\verbitem{noAdditionalIndent}] If you would prefer some of your - environments or commands not to receive any additional indent, then - populate \lstinline!noAdditionalIndent!; see \cref{lst:noAdditionalIndent}. - Note that these environments will still receive the \emph{current} level - of indentation unless they belong to \lstinline!verbatimEnvironments!, or \lstinline!noIndentBlock!. - - \begin{cmhlistings}[style=yaml]{\lstinline!noAdditionalIndent!}{lst:noAdditionalIndent} -noAdditionalIndent: - document: 1 - myexample: 1 - mydefinition: 1 - problem: 1 - exercises: 1 - mysolution: 1 - foreach: 0 - widepage: 1 - comment: 1 - \[: 1 - \]: 1 - frame: 0 - \end{cmhlistings} - Note in particular from \cref{lst:noAdditionalIndent} that if you wish content within - \lstinline!\[! and \lstinline!\]! to receive no additional indentation then - you have to specify \emph{both} as \lstinline!1! (the default is \lstinline!0!). - If you do not specify both as the same value you may get some interesting results! - \item[\verbitem{indentRules}] If\label{page:indentRules} you would prefer to specify - individual rules for certain environments or commands, just - populate \lstinline!indentRules!; see \cref{lst:indentRules} - - \begin{cmhlistings}[style=yaml]{\lstinline!indentRules!}{lst:indentRules} -indentRules: - myenvironment: "\t\t" - anotherenvironment: "\t\t\t\t" - \[: "\t" - \end{cmhlistings} %%%%%\] just here to stop vim from colouring the rest of my code - Note that in contrast to \lstinline!noAdditionalIndent! you do \emph{not} - need to specify both \lstinline!\[! and \lstinline!\]! in this field. - - If you put an environment in both \lstinline!noAdditionalIndent! and in - \lstinline!indentRules! then \lstinline!latexindent.pl! will resolve the conflict - by ignoring \lstinline!indentRules! and prioritizing \lstinline!noAdditionalIndent!. - You will get a warning message in \lstinline!indent.log!; note that you will only - get one warning message per command or environment. Further discussion - is given in \cref{sec:fieldhierachy}. - - \item[\verbitem{indentAfterHeadings}] This field enables the user to specify - indentation rules that take effect after heading commands such as \lstinline!\part!, \lstinline!\chapter!, - \lstinline!\section!, \lstinline!\subsection*! etc. This field is slightly different from all - of the fields that we have considered previously, because each element is - itself a field which has two elements: \lstinline!indent! and \lstinline!level!. - \begin{cmhlistings}[style=yaml]{\lstinline!indentAfterHeadings!}{lst:indentAfterHeadings} -indentAfterHeadings: - part: - indent: 0 - level: 1 - chapter: - indent: 0 - level: 2 - section: - indent: 0 - level: 3 - ... - \end{cmhlistings} - The default settings do \emph{not} place indentation after a heading--you - can easily switch them on by changing \lstinline!indent: 0! to \lstinline!indent: 1!. - The \lstinline!level! field tells \lstinline!latexindent.pl! the hierarchy of the heading - structure in your document. You might, for example, like to have both \lstinline!section! - and \lstinline!subsection! set with \lstinline!level: 3! because you do not want the indentation to go too deep. - - You can add any of your own custom heading commands to this field, specifying the \lstinline!level! - as appropriate. You can also specify your own indentation in \lstinline!indentRules!-- - you will find the default \lstinline!indentRules! contains \lstinline!chapter: " "! which - tells \lstinline!latexindent.pl! simply to use a space character after \lstinline!\chapter! headings - (once \lstinline!indent! is set to \lstinline!1! for \lstinline!chapter!). - - \item[\verbitem{indentAfterItems}] The environments specified in \lstinline!indentAfterItems! tell -\lstinline!latexindent.pl! to look for \lstinline!\item! commands; if these switches are set to \lstinline!1! -then indentation will be performed so as indent the code after each \lstinline!item!. - \begin{cmhlistings}{\lstinline!indentAfterItems!}{lst:indentafteritems} -indentAfterItems: - itemize: 1 - enumerate: 1 - \end{cmhlistings} -A demonstration is given in \cref{lst:itemsbefore,lst:itemsafter} - - \begin{minipage}{.5\textwidth} - \begin{cmhlistings}[style=demo,xleftmargin=-3mm,columns=fixed]{\lstinline!items! before}{lst:itemsbefore} -\begin{itemize} -\item some text here -some more text here -some more text here -\item another item -\end{itemize} - \end{cmhlistings} - \end{minipage} - \begin{minipage}{.5\textwidth} - \begin{cmhlistings}[style=demo,xleftmargin=-3mm,columns=fixed]{\lstinline!items! after}{lst:itemsafter} -\begin{itemize} - \item some text here - some more text here - some more text here - \item another item -\end{itemize} - \end{cmhlistings} - \end{minipage} - - \item[\verbitem{itemNames}] If you have your own \lstinline!item! commands (perhaps you - prefer to use \lstinline!myitem!, for example) - then you can put populate them in \lstinline!itemNames!. - For example, users of the \lstinline!exam! document class might like to add -\lstinline!parts! to \lstinline!indentAfterItems! and \lstinline!part! to \lstinline!itemNames! -to their user settings--see \vref{sec:indentconfig} for details of how to configure user settings, -and \vref{lst:mysettings} in particular.\label{page:examsettings} - -\item[\verbitem{constructIfElseFi}] The commands specified in this field - will tell \lstinline!latexindent.pl! to look for constructs that - have the form \lstinline!\if...! \lstinline!\else...! \lstinline!\fi!, such as, - for example, \lstinline!\ifnum!; see \cref{lst:iffibefore,lst:iffiafter} for - a before-and-after demonstration. - - \begin{minipage}{.5\textwidth} - \begin{cmhlistings}[style=demo,xleftmargin=-3mm,columns=fixed]{\lstinline!if-else-fi! construct before}{lst:iffibefore} -\ifnum\radius>5 -\ifnum\radius<16 -\draw[decorate,... -\fi -\fi -\end{cmhlistings} - \end{minipage} - \begin{minipage}{.5\textwidth} - \begin{cmhlistings}[style=demo,xleftmargin=-3mm,columns=fixed]{\lstinline!if-else-fi! construct after}{lst:iffiafter} -\ifnum\radius>5 - \ifnum\radius<16 - \draw[decorate,... - \fi -\fi -\end{cmhlistings} - \end{minipage} - \begin{warning} - \emph{The following fields are marked in red, as they are not necessary - unless you wish to micro-manage your indentation scheme. - Note that in each case, you should \emph{not} use the backslash.} - \end{warning} - - % to anyone reading the source code- I know the next line isn't the - % correct way to do it :) - \item[\color{red}\verbitem{checkunmatched}] Assuming you keep \lstinline!alwaysLookforSplitBraces! set to \lstinline!1! (which - is the default) then you don't need to worry about \lstinline!checkunmatched!. - - Should you wish to deactivate \lstinline!alwaysLookforSplitBraces! by setting it to \lstinline!0!, then - you can populate \lstinline!checkunmatched! with commands that can split braces across - lines--see \cref{lst:checkunmatched}. - - \begin{cmhlistings}[style=yaml]{\lstinline!checkunmatched!}{lst:checkunmatched} -checkunmatched: - parbox: 1 - vbox: 1 - \end{cmhlistings} - \item[\color{red}\verbitem{checkunmatchedELSE}] Similarly, assuming you keep \lstinline!alwaysLookforSplitBraces! set to \lstinline!1! (which - is the default) then you don't need to worry about \lstinline!checkunmatchedELSE!. - - As in \lstinline!checkunmatched!, should you wish to deactivate \lstinline!alwaysLookforSplitBraces! by setting it to \lstinline!0!, then - you can populate \lstinline!checkunmatchedELSE! with commands that can split braces across - lines \emph{and} have an `else' statement--see \cref{lst:checkunmatchedELSE}. - - \begin{cmhlistings}[style=yaml]{\lstinline!checkunmatchedELSE!}{lst:checkunmatchedELSE} -checkunmatchedELSE: - pgfkeysifdefined: 1 - DTLforeach: 1 - ifthenelse: 1 - \end{cmhlistings} - \item[\color{red}\verbitem{checkunmatchedbracket}] Assuming you keep \lstinline!alwaysLookforSplitBrackets! - set to \lstinline!1! (which is the default) then you don't need to worry about \lstinline!checkunmatchedbracket!. - - Should you wish to deactivate \lstinline!alwaysLookforSplitBrackets! by setting it - to \lstinline!0!, then you can populate \lstinline!checkunmatchedbracket! with commands that can - split \emph{brackets} across lines--see \cref{lst:checkunmatchedbracket}. - - \begin{cmhlistings}[style=yaml]{\lstinline!checkunmatchedbracket!}{lst:checkunmatchedbracket} -checkunmatchedbracket: - psSolid: 1 - pgfplotstablecreatecol: 1 - pgfplotstablesave: 1 - pgfplotstabletypeset: 1 - mycommand: 1 - \end{cmhlistings} -\end{itemize} - -\subsubsection{Hierarchy of fields}\label{sec:fieldhierachy} -After reading the previous section, it should sound reasonable that -\lstinline!noAdditionalIndent!, \lstinline!indentRules!, and -\lstinline!verbatim! all serve mutually exclusive tasks. Naturally, you may -well wonder what happens if you choose to ask \lstinline!latexindent.pl! to -prioritize one above the other. - -For example, let's say that (after reading \cref{sec:indentconfig}) you put the fields in \cref{lst:conflict} into -one of your settings files. -\begin{cmhlistings}[style=yaml]{Conflicting ideas}{lst:conflict} -indentRules: - myenvironment: "\t\t" -noAdditionalIndent: - myenvironment: 1 -\end{cmhlistings} - -Clearly these fields conflict: first of all -you are telling \lstinline!latexindent.pl! that \lstinline!myenvironment! should -receive two tabs of indentation, and then you are telling it -not to put any indentation in the environment. \lstinline!latexindent.pl! -will always make the decision to prioritize \lstinline!noAdditionalIndent! above -\lstinline!indentRules! regardless of the order that you load them in -your settings file. The first -time it encounters \lstinline!myenvironment! it will put a warning in \lstinline!indent.log! -and delete the offending key from \lstinline!indentRules! so that any future -conflicts will not have to be addressed. - -Let's consider another conflicting example in \cref{lst:bigconflict} -\begin{cmhlistings}[style=yaml]{More conflicting ideas}{lst:bigconflict} -lookForAlignDelims: - myenvironment: 1 -verbatimEnvironments: - myenvironment: 1 -\end{cmhlistings} -This is quite a significant conflict--we are first of all telling \lstinline!latexindent.pl! -to look for alignment delimiters in \lstinline!myenvironment! and then -telling it that actually we would like \lstinline!myenvironment! to be considered -as a \lstinline!verbatim!-like environment. Regardless of the order that we -state \cref{lst:bigconflict} the \lstinline!verbatim! instruction will always win. -As in \cref{lst:conflict} you will only receive a warning in \lstinline!indent.log! the -first time \lstinline!latexindent.pl! encounters \lstinline!myenvironment! as the -offending key is deleted from \lstinline!lookForAlignDelims!. - -To summarize, \lstinline!latexindent.pl! will prioritize the various fields in the -following order: -\begin{enumerate} - \item \lstinline!verbatimEnvironments! - \item \lstinline!noAdditionalIndent! - \item \lstinline!indentRules! -\end{enumerate} -\subsection{\lstinline!indentconfig.yaml! and \lstinline!.indentconfig.yaml! (for user settings)}\label{sec:indentconfig} -Editing \lstinline!defaultSettings.yaml! is not ideal as it may be overwritten when -updating your distribution--a better way to customize the settings to your liking -is to set up your own settings file, -\lstinline!mysettings.yaml! (or any name you like, provided it ends with \lstinline!.yaml!). -The only thing you have to do is tell \lstinline!latexindent.pl! where to find it. - -\lstinline!latexindent.pl! will always check your home directory for \lstinline!indentconfig.yaml! -and \lstinline!.indentconfig.yaml! (unless -it is called with the \lstinline!-d! switch), -which is a plain text file you can create that contains the \emph{absolute} -paths for any settings files that you wish \lstinline!latexindent.pl! to load. There is no difference -between \lstinline!indentconfig.yaml! and \lstinline!.indentconfig.yaml!, other than the -fact that \lstinline!.indentconfig.yaml! is a `hidden' file; thank you to \href{https://github.com/cmhughes/latexindent.pl/pull/23}{Jacobo Diaz} -for providing this feature. In what follows, we will use \lstinline!indentconfig.yaml!, but it -is understood that this equally represents \lstinline!.indentconfig.yaml! as well. If you -have both files in existence, \lstinline!indentconfig.yaml! takes priority. - -For Mac and Linux users, their home directory is \lstinline!~/username! while -Windows (Vista onwards) is \lstinline!C:\Users\username! \footnote{If you're not sure - where to put \lstinline!indentconfig.yaml!, don't - worry \lstinline!latexindent.pl! will tell you in the log file exactly where to -put it assuming it doesn't exist already.} -\Cref{lst:indentconfig} shows a sample \lstinline!indentconfig.yaml! file. - -\begin{cmhlistings}[style=yaml]{\lstinline!indentconfig.yaml! (sample)}{lst:indentconfig} -# Paths to user settings for latexindent.pl -# -# Note that the settings will be read in the order you -# specify here- each successive settings file will overwrite -# the variables that you specify - -paths: -- /home/cmhughes/Documents/yamlfiles/mysettings.yaml -- /home/cmhughes/folder/othersettings.yaml -- /some/other/folder/anynameyouwant.yaml -- C:\Users\chughes\Documents\mysettings.yaml -- C:\Users\chughes\Desktop\test spaces\more spaces.yaml -\end{cmhlistings} - -Note that the \lstinline!.yaml! files you specify in \lstinline!indentconfig.yaml! -will be loaded in the order that you write them in. Each file doesn't have -to have every switch from \lstinline!defaultSettings.yaml!; in fact, I recommend -that you only keep the switches that you want to \emph{change} in these -settings files. - -To get started with your own settings file, you might like to save a copy of -\lstinline!defaultSettings.yaml! in another directory and call it, for -example, \lstinline!mysettings.yaml!. Once you have added the path to \lstinline!indentconfig.yaml! -feel free to start changing the switches and adding more environments to it -as you see fit--have a look at \cref{lst:mysettings} for an example -that uses four tabs for the default indent, adds the \lstinline!tabbing! -environment to the list of environments that contains alignment delimiters, -and adds the changes we described on \cpageref{page:examsettings}. - -\begin{cmhlistings}[style=yaml]{\lstinline!mysettings.yaml! (example)}{lst:mysettings} -# Default value of indentation -defaultIndent: "\t\t\t\t" - -# environments that have tab delimiters, add more -# as needed -lookForAlignDelims: - tabbing: 1 - -# If you use the exam documentclass, you might -# like the following settings -# environments that have \item commands -indentAfterItems: - parts: 1 - -# commands to be treated like \item -itemNames: - part: 1 -\end{cmhlistings} - -You can make sure that your settings are loaded by checking \lstinline!indent.log! -for details--if you have specified a path that \lstinline!latexindent.pl! doesn't -recognize then you'll get a warning, otherwise you'll get confirmation that -\lstinline!latexindent.pl! has read your settings file \footnote{Windows users - may find that they have to end \lstinline!.yaml! files with a blank line}. - -\begin{warning} - When editing \lstinline!.yaml! files it is \emph{extremely} important - to remember how sensitive they are to spaces. I highly recommend copying - and pasting from \lstinline!defaultSettings.yaml! when you create your - first \lstinline!whatevernameyoulike.yaml! file. - - If \lstinline!latexindent.pl! can not read your \lstinline!.yaml! file it - will tell you so in \lstinline!indent.log!. -\end{warning} - -\subsection{\lstinline!localSettings.yaml!} -You may remember on \cpageref{page:localswitch} we discussed the \lstinline!-l! switch -that tells \lstinline!latexindent.pl! to look for \lstinline!localSettings.yaml! in the -\emph{same directory} as \lstinline!myfile.tex!. This settings file will -be read \emph{after} \lstinline!defaultSettings.yaml! and, assuming they exist, -user settings. - -In contrast to the \emph{user} settings which can be named anything you like (provided that -they are detailed in \lstinline!indentconfig.yaml!), the \emph{local} settings file -must be called \lstinline!localSettings.yaml!. It can contain any switches that you'd -like to change--a sample is shown in \cref{lst:localSettings}. - -\begin{cmhlistings}[style=yaml]{\lstinline!localSettings.yaml! (example)}{lst:localSettings} -# Default value of indentation -defaultIndent: " " - -# environments that have tab delimiters, add more -# as needed -lookForAlignDelims: - tabbing: 0 - -# verbatim environments- environments specified -# in this hash table will not be changed at all! -verbatimEnvironments: - cmhenvironment: 0 -\end{cmhlistings} - -You can make sure that your local settings are loaded by checking \lstinline!indent.log! -for details--if \lstinline!localSettings.yaml! can not be read then you will -get a warning, otherwise you'll get confirmation that -\lstinline!latexindent.pl! has read \lstinline!localSettings.yaml!. - -\subsection{Settings load order}\label{sec:loadorder} -\lstinline!latexindent.pl! loads the settings files in the following order: -\begin{enumerate} - \item \lstinline!defaultSettings.yaml! (always loaded, can not be renamed) - \item \lstinline!anyUserSettings.yaml! (and any other arbitrarily-named files specified in \lstinline!indentconfig.yaml!) - \item \lstinline!localSettings.yaml! (if found in same directory as \lstinline!myfile.tex! and called - with \lstinline!-l! switch; can not be renamed) -\end{enumerate} -A visual representation of this is given in \cref{fig:loadorder}. - -\begin{figure} - \centering - \begin{tikzpicture}[ - needed/.style={very thick, draw=blue,fill=blue!20, - text centered, minimum height=2.5em,rounded corners=1ex}, - optional/.style={draw=black, very thick,scale=0.8, - text centered, minimum height=2.5em,rounded corners=1ex}, - optionalfill/.style={fill=black!10}, - connections/.style={draw=black!30,dotted,line width=3pt,text=red}, - ] - % Draw diagram elements - \node (latexindent) [needed,circle] {\lstinline!latexindent.pl!}; - \node (default) [needed,above right=.5cm of latexindent] {\lstinline!defaultSettings.yaml!}; - \node (indentconfig) [optional,right=of latexindent] {\lstinline!indentconfig.yaml!}; - \node (any) [optional,optionalfill,above right=of indentconfig] {\lstinline!any.yaml!}; - \node (name) [optional,optionalfill,right=of indentconfig] {\lstinline!name.yaml!}; - \node (you) [optional,optionalfill,below right=of indentconfig] {\lstinline!you.yaml!}; - \node (want) [optional,optionalfill,below=of indentconfig] {\lstinline!want.yaml!}; - \node (local) [optional,below=of latexindent] {\lstinline!localSettings.yaml!}; - % Draw arrows between elements - \draw[connections,solid] (latexindent) to[in=-90]node[pos=0.5,anchor=north]{1} (default.south) ; - \draw[connections,optional] (latexindent) -- node[pos=0.5,anchor=north]{2} (indentconfig) ; - \draw[connections,optional] (indentconfig) to[in=-90] (any.south) ; - \draw[connections,optional] (indentconfig) -- (name) ; - \draw[connections,optional] (indentconfig) to[out=-45,in=90] (you) ; - \draw[connections,optional] (indentconfig) -- (want) ; - \draw[connections,optional] (latexindent) -- node[pos=0.5,anchor=west]{3} (local) ; - \end{tikzpicture} - \caption{Schematic of the load order described in \cref{sec:loadorder}; solid lines represent - mandatory files, dotted lines represent optional files. \lstinline!indentconfig.yaml! can - contain as many files as you like--the files will be loaded in order; if you specify - settings for the same field in more than one file, the most recent takes priority. } - \label{fig:loadorder} -\end{figure} - -\subsection{An important example} -I was working on a document that had the text shown in \cref{lst:casestudy}. -\begin{cmhlistings}[style=demo,escapeinside={(*@}{@*)}]{When to set \lstinline!alwaysLookforSplitBrackets=0!}{lst:casestudy} -Hence determine how many zeros the function $h(x)=f(x)-g(x)$ -has on the interval $[0,9)$.(*@\label{line:interval1}@*) -\begin{shortsolution} - The function $h$ has $10$ zeros on the interval $[0,9)$.(*@\label{line:interval2}@*) -\end{shortsolution} -\end{cmhlistings} -I had allowed \lstinline!alwaysLookforSplitBrackets=1!, which is the default setting. -Unfortunately, this caused undesired results, as \lstinline!latexindent.pl! thought that the opening -\lstinline![! in the interval notation (\cref{line:interval1,line:interval2}) -was an opening brace that needed to be closed (with a corresponding \lstinline!]!). Clearly -this was inappropriate, but also expected since \lstinline!latexindent.pl! was simply -following its matching rules. - -In this particular instance, I set up \lstinline!localSettings.yaml! -to contain \lstinline!alwaysLookforSplitBrackets: 0! and then specified the commands -that could split brackets across lines (such as \lstinline!begin{axis}!) individually -in \lstinline!checkunmatchedbracket!. Another option would have been to wrap the -the line in an environment from \lstinline!noIndentBlock! which treats its contents -as a verbatim environment. - - -\section{Known limitations}\label{sec:knownlimitations} -There are a number of known limitations of the script, and almost certainly quite a -few that are \emph{unknown}! - -The main limitation is to do with the alignment routine of environments that contain -delimiters--in other words, environments that are entered in \lstinline!lookForAlignDelims!. -Indeed, this is the only part of the script that can \emph{potentially} remove -lines from \lstinline!myfile.tex!. Note that \lstinline!indent.log! will always -finish with a comparison of line counts before and after. - -The routine works well for `standard' blocks of code that have the same number of \lstinline!&! -per line, but it will not do anything for lines that do not--such examples -include \lstinline!tabular! environments that use \lstinline!\multicolumn! or -perhaps spread cell contents across multiple lines. For each alignment block (\lstinline!tabular!, -\lstinline!align!, etc) \lstinline!latexindent.pl! first of all makes a record -of the maximum number of \lstinline!&!; if each row does not have that -number of \lstinline!&! then it will not try to format that row. Details -will be given in \lstinline!indent.log! assuming that \lstinline!trace! mode -is active. - -If you have a \lstinline!verbatim!-like environment inside a \lstinline!tabular!-like -environment, the \lstinline!verbatim! environment \emph{will} be formatted, which -is probably not what you want. I hope to address this in future versions, but for the -moment wrap it in a \lstinline!noIndentBlock! (see \cpageref{lst:noIndentBlockdemo}). - -You can run \lstinline!latexindent! on \lstinline!.sty! and \lstinline!.cls! files, but it may -struggle with some of the pattern matching; if you find such a case in which it struggles, please feel free -to report it at \href{https://github.com/cmhughes/latexindent.pl}{https://github.com/cmhughes/latexindent.pl}, and -in the meantime, use a \lstinline!noIndentBlock! (see \cpageref{lst:noIndentBlockdemo}). - -I hope that this script is useful to some--if you find an example where the -script does not behave as you think it should, feel free to e-mail me or else -come and find me on the \url{http://tex.stackexchange.com} site; I'm often around -and in the chat room. - -\printbibliography[heading=bibintoc] - -\appendix -\section{Required \lstinline!Perl! modules}\label{sec:requiredmodules} -If you intend to use \lstinline!latexindent.pl! and \emph{not} one of the supplied standalone executable files, then you will need a few standard Perl modules--if you can run the -minimum code in \cref{lst:helloworld} (\lstinline!perl helloworld.pl!) then you will be able to run \lstinline!latexindent.pl!, otherwise you may -need to install the missing modules. - -\begin{cmhlistings}[language=Perl]{\lstinline!helloworld.pl!}{lst:helloworld} -#!/usr/bin/perl - -use strict; -use warnings; -use FindBin; -use YAML::Tiny; -use File::Copy; -use File::Basename; -use Getopt::Long; -use File::HomeDir; - -print "hello world"; -exit; -\end{cmhlistings} -My default installation on Ubuntu 12.04 did \emph{not} come -with all of these modules as standard, but Strawberry Perl for Windows \cite{strawberryperl} -did. - -Installing the modules given in \cref{lst:helloworld} will vary depending on your -operating system and \lstinline!Perl! distribution. For example, Ubuntu users -might visit the software center, or else run -\begin{lstlisting}[numbers=none] -sudo perl -MCPAN -e 'install "File::HomeDir"' -\end{lstlisting} -Strawberry Perl users on Windows might use -\lstinline!CPAN client!. All of the modules are readily available on CPAN \cite{cpan}. - -As of Version 2.1R, \lstinline!indent.log! will contain details of the location -of the Perl modules on your system. \lstinline!latexindent.exe! is a standalone -executable for Windows (and therefore does not require a Perl distribution) and caches copies of the Perl modules onto your system; if you -wish to see where they are cached, use the \lstinline!trace! option, e.g \lstinline!latexindent.exe -t myfile.tex!. - -\section{The \lstinline!arara! rule} -The \lstinline!arara! rule (\lstinline!indent.yaml!) contains lines such as those -given in \cref{lst:arararule}. With this setup, the user \emph{always} has -to specify whether or not they want (in this example) to use the \lstinline!trace! -identifier. -\begin{cmhlistings}[style=yaml,numbers=none]{The \lstinline!arara! rule}{lst:arararule} -... -arguments: -- identifier: trace - flag: @{ isTrue( parameters.trace, "-t" ) } -... -\end{cmhlistings} - -If you would like to have the \lstinline!trace! option on by default every time you -call \lstinline!latexindent.pl! from \lstinline!arara! (without having to write \lstinline!% arara: indent: {trace: yes}!), then simply -amend \cref{lst:arararule} so that it looks like \cref{lst:arararulemod}. -\begin{cmhlistings}[style=yaml,numbers=none]{The \lstinline!arara! rule (modified)}{lst:arararulemod} -... -arguments: -- identifier: trace - flag: @{ isTrue( parameters.trace, "-t" ) } - default: "-t" -... -\end{cmhlistings} - -With this modification in place, you now simply to write \lstinline!% arara: indent! and -\lstinline!trace! mode will be activated by default. If you wish to turn off \lstinline!trace! -mode then you can write \lstinline!% arara: indent: {trace: off}!. - -Of course, you can apply these types of modifications to \emph{any} of the identifiers, -but proceed with caution if you intend to do this for \lstinline!overwrite!. - -\end{document} - -set local settings to include psset as an item -\documentclass[pstricks,border=30pt,12pt]{standalone} -\usepackage{pst-eucl} -\psset{opacity=.2} -\begin{document} -\begin{pspicture}(7,7) - \pstGeonode[PosAngle={-90,-90,0,-90,180}]{A}(5,0){B}(7,1){C}(2,1){D}(0,5){A_1} - \pstTranslation[PosAngle=120]{A}{A_1}{B,C,D}[B_1,C_1,D_1] - \pspolygon(A)(B)(C)(C_1)(D_1)(A_1) - \psline(A_1)(B_1)(C_1)(B)(B_1) - \pstMiddleAB[PosAngle=20]{B}{C_1}{E} - \psline(E)(C) - \pstMarkAngle{D}{E}{C}{} - \psset{linestyle=dashed} - \psline(C)(D)(D_1) - \psline(A)(D) - \psline(B)(D)(C_1) - \psline(D)(E) - \psset{linestyle=none,fillstyle=solid,fillcolor=gray} - \pspolygon(A)(D)(D_1)(A_1) - \pspolygon(B)(C_1)(D) -\end{pspicture} -\end{document} -\begin{frame}[label=timeline]{The journey\ldots} - \begin{tikzpicture} - \pause - \node[cloudy](spring2010){Spr... - \node[below=0mm of spring2010... - \pause - \node[cloudy,right=of spring20... - \node[below=0mm of summer2010... - \pause - \node[cloudy,right=of summer2... - \node[below=0mm of fall2010... - \end{tikzpicture} -\end{frame} diff --git a/Master/texmf-dist/doc/support/latexindent/success/alignmentoutsideEnvironments.tex b/Master/texmf-dist/doc/support/latexindent/success/alignmentoutsideEnvironments.tex index 0edbbbd28e1..04053c027a9 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/alignmentoutsideEnvironments.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/alignmentoutsideEnvironments.tex @@ -1,18 +1,18 @@ % arara: indent: {overwrite: true, trace: yes, silent: yes} \matrix{% - % \begin{tabular} - & A_1 & A_2 & A_3 & A_4 & A_5 & A_6 & A_7 & A_8 & A_9 \\\hline - A_1 & 0 & & & & & & & & \\ - A_2 & & 0 & & & & & & & \\ - A_3 & & & 0 & & & & & & \\ - A_4 & & & & 0 & & & & & \\ - A_5 & & & & & 0 & & & & \\ - A_6 & & & & & & 0 & & & \\ - A_7 & & & & & & & 0 & & \\ - A_8 & & & & & & & & 0 & \\ - A_9 & & & & & & & & & 0 \\ - %* \end{align} + %* \begin{tabular} + & A_1 & A_2 & A_3 & A_4 & A_5 & A_6 & A_7 & A_8 & A_9 \\\hline + A_1 & 0 & & & & & & & & \\ + A_2 & & 0 & & & & & & & \\ + A_3 & & & 0 & & & & & & \\ + A_4 & & & & 0 & & & & & \\ + A_5 & & & & & 0 & & & & \\ + A_6 & & & & & & 0 & & & \\ + A_7 & & & & & & & 0 & & \\ + A_8 & & & & & & & & 0 & \\ + A_9 & & & & & & & & & 0 \\ + %* \end{tabular} } \begin{tabular} & A_1 & A_2 & A_3 & A_4 & A_5 & A_6 & A_7 & A_8 & A_9 \\\hline diff --git a/Master/texmf-dist/doc/support/latexindent/success/braceTest.tex b/Master/texmf-dist/doc/support/latexindent/success/braceTest.tex index ac6b72d6be4..b389b436602 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/braceTest.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/braceTest.tex @@ -48,7 +48,7 @@ some other text \parbox{ \begin{something} - + \end{something} } diff --git a/Master/texmf-dist/doc/support/latexindent/success/bracketTest.tex b/Master/texmf-dist/doc/support/latexindent/success/bracketTest.tex new file mode 100644 index 00000000000..34cf9df16fb --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/bracketTest.tex @@ -0,0 +1,6 @@ +\cmh[ + here is some text +] +\cmh{ + here is some text +} diff --git a/Master/texmf-dist/doc/support/latexindent/success/environments.tex b/Master/texmf-dist/doc/support/latexindent/success/environments.tex index bf1d4d86c80..986474dca79 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/environments.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/environments.tex @@ -9,7 +9,7 @@ text \begin{align*} {\color{red}(3x^3+y)}(-4x^3+y) & = {\color{red}(3x^3+y)}(-4x^3)+{\color{red}(3x^3+y)}(y) \\ & = -12x^6-4x^3y+3x^3y+y^2 \\ - & = -12x^6-x^3y+y^2 + & = -12x^6-x^3y+y^2 \end{align*} \end{enumerate} \begin{enumerate} @@ -19,7 +19,7 @@ text \begin{align*} {\color{red}(3x^3+y)}(-4x^3+y) & = {\color{red}(3x^3+y)}(-4x^3)+{\color{red}(3x^3+y)}(y) \\ & = -12x^6-4x^3y+3x^3y+y^2 \\ - & = -12x^6-x^3y+y^2 + & = -12x^6-x^3y+y^2 \end{align*} \end{enumerate} diff --git a/Master/texmf-dist/doc/support/latexindent/success/filecontents1.tex b/Master/texmf-dist/doc/support/latexindent/success/filecontents1.tex new file mode 100644 index 00000000000..46e501ebaa0 --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/filecontents1.tex @@ -0,0 +1,18 @@ +% arara: indent: {overwrite: true, trace: false, localSettings: yes} + +\documentclass{article} +\begin{filecontents}{mybib.bib} + \begin{document} + here is some text + \end{document} +\end{filecontents} + +\begin{document} +\begin{myotherenvironment} + some text goes here + some text goes here + some text goes here + some text goes here +\end{myotherenvironment} + +\end{document} diff --git a/Master/texmf-dist/doc/support/latexindent/success/filecontents2.tex b/Master/texmf-dist/doc/support/latexindent/success/filecontents2.tex new file mode 100644 index 00000000000..54307023361 --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/filecontents2.tex @@ -0,0 +1,21 @@ +% arara: indent: {overwrite: true, trace: false, localSettings: yes} + +\documentclass{article} +\usepackage{verbatim} +\begin{filecontents}{mybib.bib} + \begin{document} + here is some text + \end{document} +\end{filecontents} + +\begin{document} + +\begin{verbatim} +\begin{filecontents}{mybib.bib} + \begin{document} + here is some text + \end{document} + \end{filecontents} +\end{verbatim} + +\end{document} diff --git a/Master/texmf-dist/doc/support/latexindent/success/ifelsefiSmall.tex b/Master/texmf-dist/doc/support/latexindent/success/ifelsefiSmall.tex new file mode 100644 index 00000000000..f4b4bad3e64 --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/ifelsefiSmall.tex @@ -0,0 +1,10 @@ +\ifnum\radius>5 + \ifnum\radius<16 + \draw[decorate,decoration={crosses},orange!\pgfmathresult!black] (1,1) circle ( \radius ex-5ex); + \fi +\fi +\ifnum + 1 +\else + 2 +\fi diff --git a/Master/texmf-dist/doc/support/latexindent/success/items1.tex b/Master/texmf-dist/doc/support/latexindent/success/items1.tex new file mode 100644 index 00000000000..29be75d5fdc --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/items1.tex @@ -0,0 +1,10 @@ +\begin{itemize} + \item one + here is some text + here is some text + here is some text + \item two + here is some text + here is some text + here is some text +\end{itemize} diff --git a/Master/texmf-dist/doc/support/latexindent/success/items2.tex b/Master/texmf-dist/doc/support/latexindent/success/items2.tex new file mode 100644 index 00000000000..76d70b95729 --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/items2.tex @@ -0,0 +1,21 @@ +\begin{enumerate} + \item one + here is some text + here is some text + here is some text + \item two + here is some text + here is some text + here is some text + \begin{itemize} + \item bullet + here is some text + here is some text + here is some text + \item bullet + here is some text + here is some text + here is some text + \end{itemize} + some text +\end{enumerate} diff --git a/Master/texmf-dist/doc/support/latexindent/success/items3.tex b/Master/texmf-dist/doc/support/latexindent/success/items3.tex new file mode 100644 index 00000000000..30460f40e72 --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/items3.tex @@ -0,0 +1,22 @@ +\begin{myenv} + \begin{itemize} + \item one + here is some text + here is some text + here is some text + \item two + here is some text + here is some text + here is some text + \end{itemize} +\end{myenv} +\begin{itemize} +\item one + here is some text + here is some text + here is some text +\item two + here is some text + here is some text + here is some text +\end{itemize} diff --git a/Master/texmf-dist/doc/support/latexindent/success/items4.tex b/Master/texmf-dist/doc/support/latexindent/success/items4.tex new file mode 100644 index 00000000000..49383c47e1a --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/items4.tex @@ -0,0 +1,22 @@ +\begin{myenv} +\begin{itemize} +\item one + here is some text + here is some text + here is some text +\item two + here is some text + here is some text + here is some text +\end{itemize} +\end{myenv} +\begin{itemize} +\item one + here is some text + here is some text + here is some text +\item two + here is some text + here is some text + here is some text +\end{itemize} diff --git a/Master/texmf-dist/doc/support/latexindent/success/matrix.tex b/Master/texmf-dist/doc/support/latexindent/success/matrix.tex index 729a922b8d7..79c959e1ba2 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/matrix.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/matrix.tex @@ -9,6 +9,6 @@ & 2 & & & \fullmoon & & & & \\ {\color{blue}*} & 1 & & & & & {\color{blue}\newmoon} & & \\\hline & & 1 & 2 & 3 & 4 & 5 & 6 & \\ - \% & & {\color{red}*} & {\color{red}*} & & {\color{red}*} & & & + \% & & {\color{red}*} & {\color{red}*} & & {\color{red}*} & & & \end{matrix} \] diff --git a/Master/texmf-dist/doc/support/latexindent/success/nestedalignment.tex b/Master/texmf-dist/doc/support/latexindent/success/nestedalignment.tex index 4bf214f2e4f..6578b4f4e00 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/nestedalignment.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/nestedalignment.tex @@ -9,7 +9,7 @@ \end{array} \right. \) - & Substitution {\em or }Addition & Because it is easy to solve for $x$ in the 1st equation + & Substitution {\em or }Addition & Because it is easy to solve for $x$ in the 1st equation {\em or} Because it is easy to multiply the first equation by -1 \\ \hline \( @@ -29,5 +29,5 @@ \end{array} \right. \) - & Substitution & Because the first equation can easily be solved for one of the variables + & Substitution & Because the first equation can easily be solved for one of the variables \end{tabular} diff --git a/Master/texmf-dist/doc/support/latexindent/success/nestedalignment1.tex b/Master/texmf-dist/doc/support/latexindent/success/nestedalignment1.tex index 0e6aa609a03..9a19ca8da43 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/nestedalignment1.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/nestedalignment1.tex @@ -5,7 +5,7 @@ \%\&\%\% & & \\ % & & 2x+y & =8 x+y & = & 6 \\ 2x+y & =8 - 2x+y \&\& & = & 8 % trailine comment + 2x+y \&\& & = & 8 % trailine comment \end{tabular} here's another line $\{ x^2 + 5x \}$ diff --git a/Master/texmf-dist/doc/support/latexindent/success/outputfile.tex b/Master/texmf-dist/doc/support/latexindent/success/outputfile.tex index 4d5506777d4..aac040a48c7 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/outputfile.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/outputfile.tex @@ -48,7 +48,7 @@ some other text \parbox{ \begin{something} - + \end{something} } diff --git a/Master/texmf-dist/doc/support/latexindent/success/sampleAFTER.tex b/Master/texmf-dist/doc/support/latexindent/success/sampleAFTER.tex index c9b38625713..b1f37474fe0 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/sampleAFTER.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/sampleAFTER.tex @@ -25,7 +25,7 @@ a \emph{decreasing} function. Similarly, if $a>0$ then $g$ is \emph{concave up} and if $a<0$ then $g$ is \emph{concave down}. Graphical representations of these statements are given in \cref{poly:fig:linquad}. - + \begin{figure}[!htb] \setlength{\figurewidth}{.2\textwidth} \begin{subfigure}{\figurewidth} @@ -94,18 +94,18 @@ \caption{Typical graphs of linear and quadratic functions.} \label{poly:fig:linquad} \end{figure} - + Let's look a little more closely at the formulas for $f$ and $g$ in \cref{poly:eq:linquad}. Note that the \emph{degree} of $f$ is $1$ since the highest power of $x$ that is present in the formula for $f(x)$ is $1$. Similarly, the degree of $g$ is $2$ since the highest power of $x$ that is present in the formula for $g(x)$ is $2$. - + In this section we will build upon our knowledge of these elementary functions. In particular, we will generalize the functions $f$ and $g$ to a function $p$ that has any degree that we wish. - + %=================================== % Author: Hughes % Date: March 2012 @@ -161,7 +161,7 @@ \end{subproblem} \end{problem} \end{essentialskills} - + \subsection*{Power functions with positive exponents} The study of polynomials will rely upon a good knowledge of power functions| you may reasonably ask, what is a power function? @@ -171,17 +171,17 @@ f(x) = a_n x^n \] where $n$ can be any real number. - + Note that for this section we will only be concerned with the case when $n$ is a positive integer. \end{pccdefinition} - + You may find assurance in the fact that you are already very comfortable with power functions that have $n=1$ (linear) and $n=2$ (quadratic). Let's explore some power functions that you might not be so familiar with. As you read \cref{poly:ex:oddpow,poly:ex:evenpow}, try and spot as many patterns and similarities as you can. - + %=================================== % Author: Hughes % Date: March 2012 @@ -199,12 +199,12 @@ the long-run behavior of each of the functions is the same, and in particular \begin{align*} f(x)\rightarrow\infty & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} f(x)\rightarrow-\infty & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} f(x)\rightarrow-\infty & \text{ as } x\rightarrow-\infty \end{align*} The same results hold for $g$ and $h$. \end{pccsolution} \end{pccexample} - + \begin{figure}[!htb] \begin{minipage}{.45\textwidth} \begin{tikzpicture} @@ -254,7 +254,7 @@ \label{poly:fig:evenpow} \end{minipage}% \end{figure} - + %=================================== % Author: Hughes % Date: March 2012 @@ -271,12 +271,12 @@ of each of the functions is the same, and in particular \begin{align*} F(x)\rightarrow\infty & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} F(x)\rightarrow\infty & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} F(x)\rightarrow\infty & \text{ as } x\rightarrow-\infty \end{align*} The same result holds for $G$ and $H$. \end{pccsolution} \end{pccexample} - + \begin{doyouunderstand} \begin{problem} Repeat \cref{poly:ex:oddpow,poly:ex:evenpow} using (respectively) @@ -285,7 +285,7 @@ \begin{shortsolution} The functions $f$, $g$, and $h$ have domain $(-\infty,\infty)$ and are graphed below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -303,11 +303,11 @@ \legend{$f$,$g$,$h$} \end{axis} \end{tikzpicture} - + Note that \begin{align*} f(x)\rightarrow-\infty & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} f(x)\rightarrow\infty & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} f(x)\rightarrow\infty & \text{ as } x\rightarrow-\infty \end{align*} The same is true for $g$ and $h$. \end{shortsolution} @@ -317,7 +317,7 @@ \begin{shortsolution} The functions $F$, $G$, and $H$ have domain $(-\infty,\infty)$ and are graphed below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -335,18 +335,18 @@ \legend{$F$,$G$,$H$} \end{axis} \end{tikzpicture} - + Note that \begin{align*} F(x)\rightarrow-\infty & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} F(x)\rightarrow-\infty & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} F(x)\rightarrow-\infty & \text{ as } x\rightarrow-\infty \end{align*} The same is true for $G$ and $H$. \end{shortsolution} \end{subproblem} \end{problem} \end{doyouunderstand} - + \subsection*{Polynomial functions} Now that we have a little more familiarity with power functions, we can define polynomial functions. Provided that you were comfortable @@ -357,7 +357,7 @@ and quadratic functions. Once you've studied the examples and problems in this section, you'll hopefully agree that polynomial functions are remarkably predictable. - + %=================================== % Author: Hughes % Date: May 2011 @@ -376,11 +376,11 @@ \end{itemize} In particular, we call $a_n$ the \emph{leading} coefficient, and $a_nx^n$ the \emph{leading term}. - + Note that if a polynomial is given in factored form, then the degree can be found by counting the number of linear factors. \end{pccdefinition} - + %=================================== % Author: Hughes % Date: March 2012 @@ -416,7 +416,7 @@ \end{enumerate} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: March 2012 @@ -440,7 +440,7 @@ shape and long-run behavior to the functions described in \cref{poly:ex:oddpow}. \end{itemize} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2011 @@ -536,7 +536,7 @@ \caption{Graphs to illustrate typical curves of polynomial functions.} \label{poly:fig:typical} \end{figure} - + %=================================== % Author: Hughes % Date: March 2012 @@ -550,7 +550,7 @@ to guide you. \begin{shortsolution} $a_1<0$: - + \begin{tikzpicture} \begin{axis}[ framed, @@ -563,9 +563,9 @@ \addplot expression[domain=-10:8]{-(x+2)}; \end{axis} \end{tikzpicture} - + $a_2<0$ - + \begin{tikzpicture} \begin{axis}[ framed, @@ -578,9 +578,9 @@ \addplot expression[domain=-4:4]{-(x^2-6)}; \end{axis} \end{tikzpicture} - + $a_3<0$ - + \begin{tikzpicture} \begin{axis}[ framed, @@ -593,9 +593,9 @@ \addplot expression[domain=-7.5:7.5]{-0.05*(x+6)*x*(x-6)}; \end{axis} \end{tikzpicture} - + $a_4<0$ - + \begin{tikzpicture} \begin{axis}[ framed, @@ -608,9 +608,9 @@ \addplot expression[domain=-2.35:5.35,samples=100]{-0.2*(x-5)*x*(x-3)*(x+2)}; \end{axis} \end{tikzpicture} - + $a_5<0$ - + \begin{tikzpicture} \begin{axis}[ framed, @@ -626,11 +626,11 @@ \end{shortsolution} \end{problem} \end{doyouunderstand} - + \fixthis{poly: Need a more basic example here- it can have a similar format to the multiple zeros example, but just keep it simple; it should be halfway between the 2 examples surrounding it} - + %=================================== % Author: Hughes % Date: May 2011 @@ -642,24 +642,24 @@ \begin{align*} p(x) & =(x-3)^2(x+4)^2 \\ q(x) & =x(x+2)^2(x-1)^2(x-3) \\ - r(x) & =x(x-3)^3(x+1)^2 + r(x) & =x(x-3)^3(x+1)^2 \end{align*} Find the degree of $p$, $q$, and $r$, and decide if the functions bounce off or cut through the horizontal axis at each of their zeros. \begin{pccsolution} The degree of $p$ is 4. Referring to \cref{poly:fig:bouncep}, the curve bounces off the horizontal axis at both zeros, $3$ and $4$. - + The degree of $q$ is 6. Referring to \cref{poly:fig:bounceq}, the curve bounces off the horizontal axis at $-2$ and $1$, and cuts through the horizontal axis at $0$ and $3$. - + The degree of $r$ is 6. Referring to \cref{poly:fig:bouncer}, the curve bounces off the horizontal axis at $-1$, and cuts through the horizontal axis at $0$ and at $3$, although is flattened immediately to the left and right of $3$. \end{pccsolution} \end{pccexample} - + \setlength{\figurewidth}{0.25\textwidth} \begin{figure}[!htb] \begin{subfigure}{\figurewidth} @@ -712,7 +712,7 @@ \caption{} \label{poly:fig:moremultiple} \end{figure} - + \begin{pccdefinition}[Multiple zeros]\label{poly:def:multzero} Let $p$ be a polynomial that has a repeated linear factor $(x-a)^n$. Then we say that $p$ has a multiple zero at $a$ of multiplicity $n$ and @@ -724,7 +724,7 @@ \end{itemize} If $n=1$, then we say that $p$ has a \emph{simple} zero at $a$. \end{pccdefinition} - + %=================================== % Author: Hughes % Date: May 2011 @@ -786,7 +786,7 @@ Let's check if the formula we have written satisfies this requirement \begin{align*} p(1) & = (1)(4)(2)(-1) \\ - & = -8 + & = -8 \end{align*} which is clearly not correct| it is close though. We can correct this by multiplying $p$ by a constant $k$; so let's assume that @@ -807,7 +807,7 @@ evaluate $p(2)$ \begin{align*} p(2) & =k(4)^2(-1) \\ - & =-16k + & =-16k \end{align*} We solve the equation $4=-8k$ and obtain $k=-\frac{1}{4}$ and conclude that the formula for $q(x)$ is @@ -817,8 +817,8 @@ \end{enumerate} \end{pccsolution} \end{pccexample} - - + + \fixthis{Chris: need sketching polynomial problems} \begin{pccspecialcomment}[Steps to follow when sketching polynomial functions] \begin{steps} @@ -865,12 +865,12 @@ \item We draw the details we have obtained so far on \cref{poly:fig:simplecubicp1}. Given that the curve of $p$ looks like the curve of $x^3$ in the long-run, we are able to complete a sketch of the graph of $p$ in \cref{poly:fig:simplecubicp2}. - + Note that we can not find the coordinates of the local minimums, local maximums, and inflection points| for the moment we make reasonable guesses as to where these points are (you'll find how to do this in calculus). \end{steps} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -909,7 +909,7 @@ \end{figure} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2012 @@ -934,7 +934,7 @@ \item We mark the details we have found so far on \cref{poly:fig:degree5p1}. Given that the curve of $q$ looks like the curve of $-x^5$ in the long-run, we can complete \cref{poly:fig:degree5p2}. \end{steps} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -973,7 +973,7 @@ \end{figure} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2012 @@ -1000,7 +1000,7 @@ the curve of $r$ looks like the curve of $x^6$ in the long-run, we complete the graph of $r$ in \cref{poly:fig:degree6p2}. \end{steps} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -1038,7 +1038,7 @@ \end{figure} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: March 2012 @@ -1058,7 +1058,7 @@ $x$ represents the length of a side, and $V(x)$ represents the volume of the box, we necessarily require both values to be positive; we illustrate the part of the curve that applies to this problem using a solid line. - + \begin{figure}[!htb] \centering \begin{tikzpicture} @@ -1080,21 +1080,21 @@ \caption{$y=V(x)$} \label{poly:fig:opentoppedbox} \end{figure} - + According to \cref{poly:fig:opentoppedbox}, the maximum volume of such a box is approximately $\unit[4000]{cm^2}$, and we achieve it using a base of length approximately $\unit[20]{cm}$. Since the base is square and each sheet of cardboard is $\unit[1200]{cm^2}$, we conclude that the dimensions of each box are $\unit[20]{cm}\times\unit[20]{cm}\times\unit[30]{cm}$. \end{pccsolution} \end{pccexample} - + \subsection*{Complex zeros} There has been a pattern to all of the examples that we have seen so far| the degree of the polynomial has dictated the number of \emph{real} zeros that the polynomial has. For example, the function $p$ in \cref{poly:ex:simplecubic} has degree $3$, and $p$ has $3$ real zeros; the function $q$ in \cref{poly:ex:degree5} has degree $5$ and $q$ has $5$ real zeros. - + You may wonder if this result can be generalized| does every polynomial that has degree $n$ have $n$ real zeros? Before we tackle the general result, let's consider an example that may help motivate it. @@ -1113,7 +1113,7 @@ x^2+1=0 \end{equation} The solutions to \cref{poly:eq:complx} are $\pm i$. - + We conclude that $c$ has $3$ zeros: $0$ and $\pm i$; we note that \emph{not all of them are real}. \end{pccexample} @@ -1143,7 +1143,7 @@ We begin by factoring $p$ \begin{align*} p(x) & =x^4-2x^3+5x^2 \\ - & =x^2(x^2-2x+5) + & =x^2(x^2-2x+5) \end{align*} We note that $0$ is a zero of $p$ with multiplicity $2$. The other zeros of $p$ can be found by solving the equation @@ -1154,7 +1154,7 @@ \begin{align*} x & =\frac{2\pm\sqrt{(-2)^2}-20}{2(1)} \\ & =\frac{2\pm\sqrt{-16}}{2} \\ - & =1\pm 2i + & =1\pm 2i \end{align*} We conclude that $p$ has $4$ zeros: $0$ (multiplicity $2$), and $1\pm 2i$ (simple). \end{pccsolution} @@ -1169,13 +1169,13 @@ We know that the zeros of a polynomial can be found by analyzing the linear factors. We are given the zeros, and have to work backwards to find the linear factors. - + We begin by assuming that $p$ has the form \begin{align*} p(x) & =(x-(2-i\sqrt{2}))(x-(2+i\sqrt{2})) \\ & =x^2-x(2+i\sqrt{2})-x(2-i\sqrt{2})+(2-i\sqrt{2})(2+i\sqrt{2}) \\ & =x^2-4x+(4-2i^2) \\ - & =x^2-4x+6 + & =x^2-4x+6 \end{align*} We conclude that a possible formula for a polynomial function, $p$, that has zeros at $2\pm i\sqrt{2}$ is @@ -1235,8 +1235,8 @@ \end{enumerate} \end{shortsolution} \end{problem} - - + + \begin{figure}[!htb] \setlength{\figurewidth}{0.3\textwidth} \begin{subfigure}{\figurewidth} @@ -1287,10 +1287,10 @@ \caption{} \label{poly:fig:findformula} \end{figure} - - - - + + + + \begin{exercises} %=================================== % Author: Hughes @@ -1459,14 +1459,14 @@ \begin{align*} p(x) & = (x-1)(x+2)(x-3) \\ m(x) & = -(x-1)(x+2)(x-3) \\ - n(x) & = (x-1)(x+2)(x-3)(x+1)(x+4) + n(x) & = (x-1)(x+2)(x-3)(x+1)(x+4) \end{align*} Note that for our present purposes we are not concerned with the vertical scale of the graphs. \begin{subproblem} Identify both on the graph {\em and} algebraically, the zeros of each polynomial. \begin{shortsolution} $y=p(x)$ is shown below. - + \begin{tikzpicture} \begin{axis}[ xmin=-5,xmax=5, @@ -1477,9 +1477,9 @@ \addplot[soldot] coordinates{(-2,0)(1,0)(3,0)}; \end{axis} \end{tikzpicture} - + $y=m(x)$ is shown below. - + \begin{tikzpicture} \begin{axis}[ xmin=-5,xmax=5, @@ -1490,9 +1490,9 @@ \addplot[soldot] coordinates{(-2,0)(1,0)(3,0)}; \end{axis} \end{tikzpicture} - + $y=n(x)$ is shown below. - + \begin{tikzpicture} \begin{axis}[ xmin=-5,xmax=5, @@ -1503,7 +1503,7 @@ \addplot[soldot] coordinates{(-4,0)(-2,0)(-1,0)(1,0)(3,0)}; \end{axis} \end{tikzpicture} - + The zeros of $p$ are $-2$, $1$, and $3$; the zeros of $m$ are $-2$, $1$, and $3$; the zeros of $n$ are $-4$, $-2$, $-1$, and $3$. \end{shortsolution} @@ -1520,7 +1520,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + \begin{figure}[!htb] \begin{widepage} \setlength{\figurewidth}{0.3\textwidth} @@ -1773,7 +1773,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -1792,7 +1792,7 @@ $\dd\lim_{x\rightarrow\infty}s(x)=\infty$, \end{shortsolution} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -1917,7 +1917,7 @@ is positive. \begin{shortsolution} Assuming that $a_3>0$: - + \begin{tikzpicture} \begin{axis}[ xmin=-10,xmax=10, @@ -1937,7 +1937,7 @@ is negative. \begin{shortsolution} Assuming that $a_3<0$: - + \begin{tikzpicture} \begin{axis}[ xmin=-10,xmax=10, @@ -1961,7 +1961,7 @@ coefficient of $q$ is positive. Hint: only one of the zeros is simple. \begin{shortsolution} Assuming that $a_4>0$ there are $2$ different options: - + \begin{tikzpicture} \begin{axis}[ xmin=-10,xmax=10, @@ -1982,7 +1982,7 @@ coefficient of $q$ is negative. \begin{shortsolution} Assuming that $a_4<0$ there are $2$ different options: - + \begin{tikzpicture} \begin{axis}[ xmin=-10,xmax=10, @@ -2194,7 +2194,7 @@ \end{subproblem} \end{multicols} \end{problem} - + %=================================== % Author: Hughes % Date: July 2012 @@ -2238,7 +2238,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + %=================================== % Author: Hughes % Date: July 2012 @@ -2290,7 +2290,7 @@ \end{subproblem} \end{multicols} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -2298,7 +2298,7 @@ \begin{problem}[Find a formula from a table]\label{poly:prob:findformula} \Crefrange{poly:tab:findformulap}{poly:tab:findformulas} show values of polynomial functions, $p$, $q$, $r$, and $s$. - + \begin{table}[!htb] \centering \begin{widepage} @@ -2382,7 +2382,7 @@ \end{subtable} \end{widepage} \end{table} - + \begin{subproblem} Assuming that all of the zeros of $p$ are shown (in \cref{poly:tab:findformulap}), how many zeros does $p$ have? \begin{shortsolution} @@ -2433,7 +2433,7 @@ \end{subproblem} \end{problem} \end{exercises} - + \section{Rational functions} \subsection*{Power functions with negative exponents} The study of rational functions will rely upon a good knowledge @@ -2455,21 +2455,21 @@ the long-run behavior of each of the functions is the same, and in particular \begin{align*} f(x)\rightarrow 0 & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} f(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} f(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty \end{align*} The same results hold for $g$ and $h$. Note also that each of the functions has a \emph{vertical asymptote} at $0$. We see that \begin{align*} f(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^- \\ - \mathllap{\text{and }} f(x)\rightarrow \infty & \text{ as } x\rightarrow 0^+ + \mathllap{\text{and }} f(x)\rightarrow \infty & \text{ as } x\rightarrow 0^+ \end{align*} The same results hold for $g$ and $h$. - + The curve of a function that has a vertical asymptote is necessarily separated into \emph{branches}| each of the functions $f$, $g$, and $h$ have $2$ branches. \end{pccsolution} \end{pccexample} - + \begin{figure}[!htb] \begin{minipage}{.45\textwidth} \begin{tikzpicture} @@ -2525,8 +2525,8 @@ \label{rat:fig:evenpow} \end{minipage}% \end{figure} - - + + %=================================== % Author: Hughes % Date: May 2011 @@ -2543,7 +2543,7 @@ the long-run behavior of each of the functions is the same, and in particular \begin{align*} F(x)\rightarrow 0 & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} f(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} f(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty \end{align*} As in \cref{rat:ex:oddpow}, $F$ has a horizontal asymptote that has equation $y=0$. @@ -2551,7 +2551,7 @@ has a \emph{vertical asymptote} at $0$. We see that \begin{align*} F(x)\rightarrow \infty & \text{ as } x\rightarrow 0^- \\ - \mathllap{\text{and }} F(x)\rightarrow \infty & \text{ as } x\rightarrow 0^+ + \mathllap{\text{and }} F(x)\rightarrow \infty & \text{ as } x\rightarrow 0^+ \end{align*} The same results hold for $G$ and $H$. Each of the functions $F$, $G$, and $H$ have $2$ branches. @@ -2569,7 +2569,7 @@ \begin{shortsolution} The functions $k$, $m$, and $n$ have domain $(-\infty,0)\cup (0,\infty)$, and are graphed below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -2590,14 +2590,14 @@ \legend{$k$,$m$,$n$} \end{axis} \end{tikzpicture} - + Note that \begin{align*} k(x)\rightarrow 0 & \text{ as } x\rightarrow\infty \\ \mathllap{\text{and }} k(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty \\ \intertext{and also} k(x)\rightarrow \infty & \text{ as } x\rightarrow 0^- \\ - \mathllap{\text{and }} k(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^+ + \mathllap{\text{and }} k(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^+ \end{align*} The same are true for $m$ and $n$. \end{shortsolution} @@ -2607,7 +2607,7 @@ \begin{shortsolution} The functions $K$, $M$, and $N$ have domain $(-\infty,0)\cup (0,\infty)$, and are graphed below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -2628,21 +2628,21 @@ \legend{$K$,$M$,$N$} \end{axis} \end{tikzpicture} - + Note that \begin{align*} K(x)\rightarrow 0 & \text{ as } x\rightarrow\infty \\ \mathllap{\text{and }} K(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty \\ \intertext{and also} K(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^- \\ - \mathllap{\text{and }} K(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^+ + \mathllap{\text{and }} K(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^+ \end{align*} The same are true for $M$ and $N$. \end{shortsolution} \end{subproblem} \end{problem} \end{doyouunderstand} - + \subsection*{Rational functions} \begin{pccdefinition}[Rational functions]\label{rat:def:function} Rational functions have the form @@ -2650,7 +2650,7 @@ r(x) = \frac{p(x)}{q(x)} \] where both $p$ and $q$ are polynomials. - + Note that \begin{itemize} \item the domain or $r$ will be all real numbers, except those that @@ -2658,13 +2658,13 @@ \item the zeros of $r$ are the zeros of $p$, i.e the real numbers that make the \emph{numerator}, $p(x)$, equal to $0$. \end{itemize} - + \Cref{rat:ex:oddpow,rat:ex:evenpow} are particularly important because $r$ will behave like $\frac{1}{x}$, or $\frac{1}{x^2}$ around its vertical asymptotes, depending on the power that the relevant term is raised to| we will demonstrate this in what follows. \end{pccdefinition} - + %=================================== % Author: Hughes % Date: May 2011 @@ -2699,7 +2699,7 @@ \end{enumerate} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2011 @@ -2779,7 +2779,7 @@ \caption{} \label{rat:fig:whichiswhich} \end{figure} - + \begin{pccsolution} Let's start with the function $r$. Note that domain of $r$ is $(-\infty,3)\cup(0,3)$, so we search for a function that has a vertical asymptote at $3$. There @@ -2787,18 +2787,18 @@ but note that the function in \cref{rat:fig:which3} also has a vertical asymptote at $-2$ which is not consistent with the formula for $r(x)$. Therefore, $y=r(x)$ is graphed in \cref{rat:fig:which2}. - + The function $q$ has domain $(-\infty,-5)\cup(-5,\infty)$, so we search for a function that has a vertical asymptote at $-5$. The only candidate is the curve shown in \cref{rat:fig:which1}; note that the curve also goes through $(2,0)$, which is consistent with the formula for $q(x)$, since $q(2)=0$, i.e $q$ has a zero at $2$. - + The function $k$ has domain $(-\infty,-2)\cup(-2,3)\cup(3,\infty)$, and has vertical asymptotes at $-2$ and $3$. This is consistent with the graph in \cref{rat:fig:which3} (and is the only curve that has $3$ branches). - + We note that each function behaves like $\frac{1}{x}$ around its vertical asymptotes, because each linear factor in each denominator is raised to the power $1$; if (for example) the definition of $r$ was instead @@ -2809,7 +2809,7 @@ the graph of $r$ would be very different. We will deal with these cases in the examples that follow. \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2011 @@ -2827,7 +2827,7 @@ so we are not surprised to see that each curve has $3$ branches. We also note that the numerator of each function is the same, which tells us that each function has only $1$ zero at $2$. - + The functions $g$ and $h$ are different from those that we have considered previously, because they have a repeated factor in the denominator. Notice in particular the way that the functions behave around their asymptotes: @@ -2910,7 +2910,7 @@ \caption{} \label{rat:fig:repfactd} \end{figure} - + \Cref{rat:def:function} says that the zeros of the rational function $r$ that has formula $r(x)=\frac{p(x)}{q(x)}$ are the zeros of $p$. Let's explore this a little more. @@ -2929,9 +2929,9 @@ x+5=0 \] The zero of $\alpha$ is $-5$. - + Similarly, we may solve $9-x=0$ to find the zero of $\beta$, which is clearly $9$. - + The zeros of $\gamma$ satisfy the equation \[ 17x^2-10=0 @@ -2943,7 +2943,7 @@ The zeros of $\gamma$ are $\pm\frac{10}{17}$. \end{pccsolution} \end{pccexample} - + \subsection*{Long-run behavior} Our focus so far has been on the behavior of rational functions around their \emph{vertical} asymptotes. In fact, rational functions also @@ -2966,7 +2966,7 @@ \end{pccdefinition} We will concentrate on functions that have horizontal asymptotes until we reach \cref{rat:sec:oblique}. - + %=================================== % Author: Hughes % Date: May 2012 @@ -2979,7 +2979,7 @@ and obtained the curves shown in \cref{rat:fig:horizasymp}. Kebede decides to test his knowledgeable friend \pccname{Oscar}, and asks him to match the formulas to the graphs. - + \begin{figure}[!htb] \setlength{\figurewidth}{0.3\textwidth} \begin{subfigure}{\figurewidth} @@ -3050,7 +3050,7 @@ \caption{Horizontal asymptotes} \label{rat:fig:horizasymp} \end{figure} - + Oscar notices that each function has a vertical asymptote at $3$ and a zero at $-1$. The main thing that catches Oscar's eye is that each function has a different coefficient in the numerator, and that each curve has a different horizontal asymptote. @@ -3064,14 +3064,14 @@ that since the degree of the numerator and the degree of the denominator is the same for each of the functions $r$, $s$, and $t$, the horizontal asymptote will be determined by evaluating the ratio of their leading coefficients. - + Oscar therefore says that $r$ should have a horizontal asymptote $y=\frac{1}{1}=1$, $s$ should have a horizontal asymptote $y=\frac{2}{1}=2$, and $t$ should have a horizontal asymptote $y=\frac{3}{1}=3$. Kebede is able to finish the problem from here, and says that $r$ is shown in \cref{rat:fig:horizasymp2}, $s$ is shown in \cref{rat:fig:horizasymp1}, and $t$ is shown in \cref{rat:fig:horizasymp3}. \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2012 @@ -3080,7 +3080,7 @@ \pccname{Xiao} and \pccname{Dwayne} saw \cref{rat:ex:horizasymp} but are a little confused about horizontal asymptotes. What does it mean to say that a function $r$ has a horizontal asymptote? - + They decide to explore the concept by constructing a table of values for the rational functions $R$ and $S$ that have formulas \[ @@ -3119,13 +3119,13 @@ \end{tabular} \end{minipage} \end{table} - + Xiao and Dwayne study \cref{rat:tab:plusinfty,rat:tab:minusinfty} and decide that the functions $R$ and $S$ never actually touch their horizontal asymptotes, but they do get infinitely close. They also feel as if they have a better understanding of what it means to study the behavior of a function as $x\rightarrow\pm\infty$. \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2011 @@ -3142,7 +3142,7 @@ \] We also notice that the numerators of each function are quite similar| indeed, each function has a zero at $2$, but how does each function behave around their zero? - + Using \cref{rat:fig:repfactn} to guide us, we note that \begin{itemize} \item $f$ has a horizontal intercept $(2,0)$, but the curve of @@ -3152,7 +3152,7 @@ \item $h$ has a horizontal intercept $(2,0)$, and the curve of $h$ also cuts the axis, but appears flattened as it does so. \end{itemize} - + We can further enrich our study by discussing the long-run behavior of each function. Using the tools of \cref{rat:def:longrun}, we can deduce that \begin{itemize} @@ -3162,7 +3162,7 @@ study this more in \cref{rat:sec:oblique}). \end{itemize} \end{pccexample} - + \begin{figure}[!htb] \setlength{\figurewidth}{0.3\textwidth} \begin{subfigure}{\figurewidth} @@ -3235,7 +3235,7 @@ \caption{} \label{rat:fig:repfactn} \end{figure} - + \subsection*{Holes} Rational functions have a vertical asymptote at $a$ if the denominator is $0$ at $a$. What happens if the numerator is $0$ at the same place? In this case, we say that the rational @@ -3250,7 +3250,7 @@ $(a,r(a))$ on the curve $y=r(x)$ by using a hollow circle, $\circ$. \end{pccdefinition} - + %=================================== % Author: Hughes % Date: March 2012 @@ -3262,12 +3262,12 @@ \] in their calculators, and can not decide if the correct graph is \cref{rat:fig:hole} or \cref{rat:fig:hole1}. - + Luckily for them, Oscar is nearby, and can help them settle the debate. Oscar demonstrates that \begin{align*} r(x) & =\frac{(x+3)(x-2)}{(x-2)} \\ - & = x+3 + & = x+3 \end{align*} but only when $x\ne 2$, because the function is undefined at $2$. Oscar says that this necessarily means that the domain or $r$ is @@ -3275,7 +3275,7 @@ (-\infty,2)\cup(2,\infty) \] and that $r$ must have a hole at $2$. - + Mohammed and Sue are very grateful for the clarification, and conclude that the graph of $r$ is shown in \cref{rat:fig:hole1}. \begin{figure}[!htb] @@ -3319,7 +3319,7 @@ \end{minipage}% \end{figure} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2011 @@ -3333,12 +3333,12 @@ make the denominator equal to $0$. Notice that \begin{align*} f(x) & = \frac{x(x+3)}{x(x-4)} \\ - & = \frac{x+3}{x-4} + & = \frac{x+3}{x-4} \end{align*} provided that $x\ne 0$. Since $0$ makes the numerator and the denominator 0 at the same time, we say that $f$ has a hole at $(0,-\nicefrac{3}{4})$. Note that this necessarily means that $f$ does not have a vertical intercept. - + We also note $f$ has a vertical asymptote at $4$; the function is graphed in \cref{rat:fig:holeex}. \begin{figure}[!htb] \centering @@ -3362,9 +3362,9 @@ \label{rat:fig:holeex} \end{figure} \end{pccexample} - - - + + + %=================================== % Author: Hughes % Date: March 2012 @@ -3374,7 +3374,7 @@ if a rational function has a vertical asymptote, then it can not possibly have local minimums and maximums, nor can it have global minimums and maximums. - + Trang says this statement is not always true. She plots the functions $f$ and $g$ that have formulas \[ @@ -3383,7 +3383,7 @@ in \cref{rat:fig:minmax1,rat:fig:minmax2} and shows them to Seamus. On seeing the graphs, Seamus quickly corrects himself, and says that $f$ has a local (and global) maximum of $2$ at $0$, and that $g$ has a local (and global) minimum of $-2$ at $0$. - + \begin{figure}[!htb] \begin{minipage}{.45\textwidth} \begin{tikzpicture}[/pgf/declare function={f=-32*(x-1)*(x+1)/(( x-2)^2*(x+2)^2);}] @@ -3427,19 +3427,19 @@ \label{rat:fig:minmax2} \end{minipage}% \end{figure} - + Seamus also notes that (in its domain) the function $f$ is always concave down, and that (in its domain) the function $g$ is always concave up. Furthermore, Trang observes that each function behaves like $\frac{1}{x^2}$ around each of its vertical asymptotes, because each linear factor in the denominator is raised to the power $2$. - + \pccname{Oscar} stops by and reminds both students about the long-run behavior; according to \cref{rat:def:longrun} since the degree of the denominator is greater than the degree of the numerator (in both functions), each function has a horizontal asymptote at $y=0$. \end{pccexample} - - + + \investigation*{} %=================================== % Author: Pettit/Hughes @@ -3448,12 +3448,12 @@ \begin{problem}[The spaghetti incident] The same Queen from \vref{exp:prob:queenschessboard} has recovered from the rice experiments, and has called her loyal jester for another challenge. - + The jester has an $11-$inch piece of uncooked spaghetti that he puts on a table; he uses a book to cover $\unit[1]{inch}$ of it so that $\unit[10]{inches}$ hang over the edge. The jester then produces a box of $\unit{mg}$ weights that can be hung from the spaghetti. - + The jester says it will take $\unit[y]{mg}$ to break the spaghetti when hung $\unit[x]{inches}$ from the edge, according to the rule $y=\frac{100}{x}$. \begin{margintable} @@ -3537,7 +3537,7 @@ note that this necessarily means that you will not be able to plot all of the points. \begin{shortsolution} The graph of $y=\frac{100}{x}$ is shown below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -3567,9 +3567,9 @@ \end{subproblem} The Queen looks forward to more food-related investigations from her jester. \end{problem} - - - + + + %=================================== % Author: Adams (Hughes) % Date: March 2012 @@ -3593,17 +3593,17 @@ Paying off the debt in $2$ years, we use \begin{align*} M & = \frac{2000\cdot 0.015}{1-(1+0.015)^{-24}} \\ - & \approx 99.85 + & \approx 99.85 \end{align*} The monthly payments are \$99.85. - + Paying off the debt in $1$ year, we use \begin{align*} M & = \frac{2000\cdot 0.015}{1-(1+0.015)^{-12}} \\ - & \approx 183.36 + & \approx 183.36 \end{align*} The monthly payments are \$183.36 - + In the $2$-year model we would pay a total of $\$99.85\cdot 12=\$2396.40$. In the $1$-year model we would pay a total of $\$183.36\cdot 12=\$2200.32$. We would therefore save $\$196.08$ if we went with the $1$-year model instead of the $2$-year model. @@ -3619,20 +3619,20 @@ For the $20$-year loan we use \begin{align*} M & = \frac{300000\cdot \frac{0.052}{12}}{1-\left( 1+\frac{0.052}{12} \right)^{-12\cdot 20}} \\ - & \approx 2013.16 + & \approx 2013.16 \end{align*} The monthly payments are \$2013.16. - + For the $30$-year loan we use \begin{align*} M & = \frac{300000\cdot \frac{0.052}{12}}{1-\left( 1+\frac{0.052}{12} \right)^{-12\cdot 30}} \\ - & \approx 1647.33 + & \approx 1647.33 \end{align*} The monthly payments are \$1647.33. - + The total amount paid during the $20$-year loan is $\$2013.16\cdot 12\cdot 20=\$483,158.40$. The total amount paid during the $30$-year loan is $\$1647.33\cdot 12\cdot 30=\$593,038.80$. - + Recommendation: if you can afford the payments, choose the $20$-year loan. \end{shortsolution} \end{subproblem} @@ -3662,7 +3662,7 @@ This means that the monthly payments will be calculated using \begin{align*} M & = \frac{14000\cdot \frac{0.04}{12}}{1-\left( 1+\frac{0.04}{12} \right)^{-12\cdot 5}} \\ - & \approx 257.83 + & \approx 257.83 \end{align*} The monthly payments will be $\$257.83$. The total amount paid will be $\$257.83\cdot 5\cdot 12=\$15,469.80$, of which $\$1469.80$ is interest. @@ -3670,7 +3670,7 @@ This means that the monthly payments will be calculated using \begin{align*} M & = \frac{12000\cdot \frac{0.08}{12}}{1-\left( 1+\frac{0.08}{12} \right)^{-12\cdot 5}} \\ - & \approx 243.32 + & \approx 243.32 \end{align*} The monthly payments will be $\$243.32$. The total amount paid will be $\$243.32\cdot 5\cdot 12 =\$14,599.20$, of which $\$2599.2$ is @@ -3681,7 +3681,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + \begin{exercises} %=================================== % Author: Hughes @@ -3783,7 +3783,7 @@ $\begin{aligned}[t] r(0) & =\frac{(0-2)(0+3)}{(0+5)(0-7)} \\ & =\frac{-6}{-35} \\ - & =\frac{6}{35} + & =\frac{6}{35} \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3793,7 +3793,7 @@ $\begin{aligned}[t] r(1) & =\frac{(1-2)(1+3)}{(1+5)(1-7)} \\ & =\frac{-4}{-36} \\ - & =\frac{1}{9} + & =\frac{1}{9} \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3803,7 +3803,7 @@ $\begin{aligned}[t] r(2) & =\frac{(2-2)(2+3)}{(2+5)(2-7)} \\ & = \frac{0}{-50} \\ - & =0 + & =0 \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3813,7 +3813,7 @@ $\begin{aligned}[t] r(4) & =\frac{(4-2)(4+3)}{(4+5)(4-7)} \\ & =\frac{14}{-27} \\ - & =-\frac{14}{27} + & =-\frac{14}{27} \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3822,9 +3822,9 @@ \begin{shortsolution} $\begin{aligned}[t] r(7) & =\frac{(7-2)(7+3)}{(7+5)(7-7)} \\ - & =\frac{50}{0} + & =\frac{50}{0} \end{aligned}$ - + $r(7)$ is undefined. \end{shortsolution} \end{subproblem} @@ -3834,7 +3834,7 @@ $\begin{aligned}[t] r(-3) & =\frac{(-3-2)(-3+3)}{(-3+5)(-3-7)} \\ & =\frac{0}{-20} \\ - & =0 + & =0 \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3843,9 +3843,9 @@ \begin{shortsolution} $\begin{aligned}[t] r(-5) & =\frac{(-5-2)(-5+3)}{(-5+5)(-5-7)} \\ - & =\frac{14}{0} + & =\frac{14}{0} \end{aligned}$ - + $r(-5)$ is undefined. \end{shortsolution} \end{subproblem} @@ -3856,7 +3856,7 @@ r\left( \frac{1}{2} \right) & = \frac{\left( \frac{1}{2}-2 \right)\left( \frac{1}{2}+3 \right)}{\left( \frac{1}{2}+5 \right)\left( \frac{1}{2}-7 \right)} \\ & =\frac{-\frac{3}{2}\cdot\frac{7}{2}}{\frac{11}{2}\left( -\frac{13}{2} \right)} \\ & =\frac{-\frac{21}{4}}{-\frac{143}{4}} \\ - & =\frac{37}{143} + & =\frac{37}{143} \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3908,7 +3908,7 @@ \end{subproblem} \end{multicols} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -3925,7 +3925,7 @@ \end{itemize} \end{shortsolution} \end{problem} - + \begin{figure}[!htb] \begin{widepage} \setlength{\figurewidth}{0.3\textwidth} @@ -3997,7 +3997,7 @@ \label{rat:fig:findformula} \end{widepage} \end{figure} - + %=================================== % Author: Hughes % Date: May 2011 @@ -4034,7 +4034,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -4099,7 +4099,7 @@ \end{subproblem} \end{multicols} \end{problem} - + %=================================== % Author: Hughes % Date: May 2012 @@ -4181,7 +4181,7 @@ \end{subproblem} \end{multicols} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -4212,7 +4212,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + %=================================== % Author: Hughes % Date: Feb 2011 @@ -4265,8 +4265,8 @@ \end{shortsolution} \end{subproblem} \end{problem} - - + + %=================================== % Author: Hughes % Date: May 2011 @@ -4309,7 +4309,7 @@ Sketch a graph of $r$. \begin{shortsolution} A graph of $r$ is shown below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -4329,7 +4329,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + %=================================== % Author: Hughes % Date: July 2012 @@ -4367,8 +4367,8 @@ \end{subproblem} \end{multicols} \end{problem} - - + + %=================================== % Author: Hughes % Date: July 2012 @@ -4419,8 +4419,8 @@ \end{subproblem} \end{multicols} \end{problem} - - + + %=================================== % Author: Hughes % Date: May 2011 @@ -4428,7 +4428,7 @@ \begin{problem}[Find a formula from a table]\label{rat:prob:findformula} \Crefrange{rat:tab:findformular}{rat:tab:findformulau} show values of rational functions $r$, $q$, $s$, and $t$. Assume that any values marked with an X are undefined. - + \begin{table}[!htb] \begin{widepage} \centering @@ -4525,7 +4525,7 @@ r(-4) & = \frac{-4-3}{-4+2} \\ & = \frac{7}{2} \\ \end{aligned}$ - + $r(-3)=\ldots$ etc \end{shortsolution} \end{subproblem} @@ -4541,9 +4541,9 @@ \begin{shortsolution} $\begin{aligned}[t] s(-4) & =\frac{-4+2}{(-4-3)(-4+1)} \\ - & =-\frac{2}{21} + & =-\frac{2}{21} \end{aligned}$ - + $s(-3)=\ldots$ etc \end{shortsolution} \end{subproblem} @@ -4563,13 +4563,13 @@ \end{subproblem} \end{problem} \end{exercises} - + \section{Graphing rational functions (horizontal asymptotes)} \reformatstepslist{R} % the steps list should be R1, R2, \ldots We studied rational functions in the previous section, but were not asked to graph them; in this section we will demonstrate the steps to be followed in order to sketch graphs of the functions. - + Remember from \vref{rat:def:function} that rational functions have the form \[ @@ -4583,7 +4583,7 @@ in this section \emph{will have a horizontal asymptote} (see \vref{rat:def:longrun}). The cases in which the degree of $p$ is greater than the degree of $q$ is covered in the next section. - + Before we begin, it is important to remember the following: \begin{itemize} \item Our sketches will give a good representation of the overall @@ -4612,10 +4612,10 @@ find the exact coordinates of local minimums, local maximums, and points of inflection. \end{pccspecialcomment} - + The examples that follow show how \crefrange{rat:step:first}{rat:step:last} can be applied to a variety of different rational functions. - + %=================================== % Author: Hughes % Date: May 2012 @@ -4641,7 +4641,7 @@ \end{steps} \end{pccsolution} \end{pccexample} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -4678,14 +4678,14 @@ \end{subfigure}% \caption{$y=\dfrac{1}{x-2}$} \end{figure} - + The function $r$ in \cref{rat:ex:1overxminus2p2} has a horizontal asymptote which has equation $y=0$. This asymptote lies on the horizontal axis, and you might (understandably) find it hard to distinguish between the two lines (\cref{rat:fig:1overxminus2p2}). When faced with such a situation, it is perfectly acceptable to draw the horizontal axis as a dashed line| just make sure to label it correctly. We will demonstrate this in the next example. - + %=================================== % Author: Hughes % Date: May 2012 @@ -4711,12 +4711,12 @@ is, because we know what the overall shape will be. Let's compute $v(2)$ \begin{align*} v(2) & =\dfrac{10}{2} \\ - & = 5 + & = 5 \end{align*} We therefore mark the point $(2,5)$ on \cref{rat:fig:1overxp2}, and then complete the sketch using the details we found in the previous steps. \end{steps} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -4760,7 +4760,7 @@ \end{figure} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2012 @@ -4778,7 +4778,7 @@ \begin{align*} u(x) & =\frac{-4(x^2-9)}{x^2-8x+15} \\ & =\frac{-4(x+3)(x-3)}{(x-5)(x-3)} \\ - & =\frac{-4(x+3)}{x-5} + & =\frac{-4(x+3)}{x-5} \end{align*} provided that $x\ne 3$. Therefore $u$ has a vertical asymptote at $5$ and a hole at $3$. The curve of $u$ has $2$ branches. @@ -4788,7 +4788,7 @@ \item We put the details we have obtained so far on \cref{rat:fig:1overxminus2p1}. Notice that there is only one way to complete the graph, which we have done in \cref{rat:fig:1overxminus2p2}. \end{steps} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -4833,12 +4833,12 @@ \end{figure} \end{pccsolution} \end{pccexample} - + \Cref{rat:ex:1overxminus2p2,rat:ex:1overxp1,rat:ex:asympandholep1} have focused on functions that only have one vertical asymptote; the remaining examples in this section concern functions that have more than one vertical asymptote. We will demonstrate that \crefrange{rat:step:first}{rat:step:last} still apply. - + %=================================== % Author: Hughes % Date: May 2012 @@ -4862,20 +4862,20 @@ of the numerator and denominator, we say that $w$ has a horizontal asymptote with equation $y=\frac{2}{1}=2$. \item We put the details we have obtained so far on \cref{rat:fig:sketchtwoasymptp1}. - + The function $w$ is a little more complicated than the functions that we have considered in the previous examples because the curve has $3$ branches. When graphing such functions, it is generally a good idea to start with the branch for which you have the most information| in this case, that is the \emph{middle} branch on the interval $(-5,4)$. - + Once we have drawn the middle branch, there is only one way to complete the graph (because of our observations about the behavior of $w$ around its vertical asymptotes), which we have done in \cref{rat:fig:sketchtwoasymptp2}. \end{steps} \end{pccsolution} \end{pccexample} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -4921,12 +4921,12 @@ \end{subfigure}% \caption{$y=\dfrac{2(x+3)(x-5)}{(x+5)(x-4)}$} \end{figure} - + The rational functions that we have considered so far have had simple factors in the denominator; each function has behaved like $\frac{1}{x}$ around each of its vertical asymptotes. \Cref{rat:ex:2asympnozeros,rat:ex:2squaredasymp} consider functions that have a repeated factor in the denominator. - + %=================================== % Author: Hughes % Date: May 2012 @@ -4949,17 +4949,17 @@ denominator of $f$ is $2$. $f$ has a horizontal asymptote with equation $y=0$. \item We put the details we have obtained so far on \cref{rat:fig:2asympnozerosp1}. - + The function $f$ is similar to the function $w$ that we considered in \cref{rat:ex:sketchtwoasymp}| it has two vertical asymptotes and $3$ branches, but in contrast to $w$ it does not have any zeros. - + We sketch $f$ in \cref{rat:fig:2asympnozerosp2}, using the middle branch as our guide because we have the most information about the function on the interval $(-5,4)$. - + Once we have drawn the middle branch, there is only one way to complete the graph because of our observations about the behavior of $f$ around its vertical asymptotes (it behaves like $\frac{1}{x}$), which we have done in \cref{rat:fig:2asympnozerosp2}. - + Note that we are not yet able to find the local minimum of $f$ algebraically on the interval $(-5,4)$, so we make a reasonable guess as to where it is| we can be confident that it is above the horizontal axis since $f$ has no zeros. You may think that this is unsatisfactory, but once we have the tools of calculus, we will @@ -4967,7 +4967,7 @@ \end{steps} \end{pccsolution} \end{pccexample} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -5011,7 +5011,7 @@ \end{subfigure}% \caption{$y=\dfrac{100}{(x+5)(x-4)^2}$} \end{figure} - + %=================================== % Author: Hughes % Date: May 2012 @@ -5037,19 +5037,19 @@ \cref{rat:fig:2squaredasymp1}. The function $g$ is similar to the functions we considered in \cref{rat:ex:sketchtwoasymp,rat:ex:2asympnozeros} because it has $2$ vertical asymptotes and $3$ branches. - + We sketch $g$ using the middle branch as our guide because we have the most information about $g$ on the interval $(-3,5)$. Note that there is no other way to draw this branch without introducing other zeros which $g$ does not have. - + Once we have drawn the middle branch, there is only one way to complete the graph because of our observations about the behavior of $g$ around its vertical asymptotes| it behaves like $\frac{1}{x^2}$. - + \end{steps} \end{pccsolution} \end{pccexample} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -5093,14 +5093,14 @@ \end{subfigure}% \caption{$y=\dfrac{50(2-x)}{(x+3)^2(x-5)^2}$} \end{figure} - + Each of the rational functions that we have considered so far has had either a \emph{simple} zero, or no zeros at all. Remember from our work on polynomial functions, and particularly \vref{poly:def:multzero}, that a \emph{repeated} zero corresponds to the curve of the function behaving differently at the zero when compared to how the curve behaves at a simple zero. \Cref{rat:ex:doublezero} details a function that has a non-simple zero. - + %=================================== % Author: Hughes % Date: June 2012 @@ -5127,20 +5127,20 @@ \cref{rat:fig:doublezerop1}. The function $h$ is different from the functions that we have considered in previous examples because of the multiplicity of the zero at $3$. - + We sketch $h$ using the middle branch as our guide because we have the most information about $h$ on the interval $(-4,6)$. Note that there is no other way to draw this branch without introducing other zeros which $h$ does not have| also note how the curve bounces off the horizontal axis at $3$. - + Once we have drawn the middle branch, there is only one way to complete the graph because of our observations about the behavior of $h$ around its vertical asymptotes| it behaves like $\frac{1}{x}$. - + \end{steps} \end{pccsolution} \end{pccexample} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -5199,7 +5199,7 @@ at $b$, and a vertical asymptote at $c$. Furthermore, these functions behave like $\frac{1}{x}$ around their vertical asymptote, and the curve of each function will have $2$ branches. - + Katie has been working with $3$ functions that have the form given in \cref{rat:eq:deducecurve}, and has followed \crefrange{rat:step:first}{rat:step:penultimate}; her results are shown in \cref{rat:fig:deducecurve}. There is just one @@ -5207,7 +5207,7 @@ Help Katie finish each graph by deducing the curve of each function. \begin{shortsolution} \Vref{rat:fig:deducecurve1} - + \begin{tikzpicture}[/pgf/declare function={f=3*(x+4)/(x+5);}] \begin{axis}[ xmin=-10,xmax=10, @@ -5222,9 +5222,9 @@ \addplot[pccplot] expression[domain=-4.76923:10,samples=50]{f}; \end{axis} \end{tikzpicture} - + \Vref{rat:fig:deducecurve2} - + \begin{tikzpicture}[/pgf/declare function={f=-3*(x-2)/(x-4);}] \begin{axis}[ xmin=-10,xmax=10, @@ -5239,9 +5239,9 @@ \addplot[pccplot] expression[domain=4.85714:10]{f}; \end{axis} \end{tikzpicture} - + \Vref{rat:fig:deducecurve4} - + \begin{tikzpicture}[/pgf/declare function={f=2*(x-6)/(x-4);}] \begin{axis}[ xmin=-10,xmax=10, @@ -5258,7 +5258,7 @@ \end{tikzpicture} \end{shortsolution} \end{problem} - + \begin{figure}[!htb] \begin{widepage} \setlength{\figurewidth}{0.3\textwidth} @@ -5316,7 +5316,7 @@ \label{rat:fig:deducecurve} \end{widepage} \end{figure} - + %=================================== % Author: Hughes % Date: June 2012 @@ -5331,13 +5331,13 @@ at $b$ and $c$, and vertical asymptotes at $d$ and $e$. Furthermore, these functions behave like $\frac{1}{x}$ around both vertical asymptotes, and the curve of the function will have $3$ branches. - + David has followed \crefrange{rat:step:first}{rat:step:penultimate} for $3$ separate functions, and drawn the results in \cref{rat:fig:deducehard}. Help David finish each graph by deducing the curve of each function. \begin{shortsolution} \Vref{rat:fig:deducehard1} - + \begin{tikzpicture}[/pgf/declare function={f=(x-6)*(x+3)/( (x-4)*(x+1));}] \begin{axis}[ xmin=-10,xmax=10, @@ -5354,9 +5354,9 @@ \addplot[pccplot] expression[domain=4.24276:10]{f}; \end{axis} \end{tikzpicture} - + \Vref{rat:fig:deducehard2} - + \begin{tikzpicture}[/pgf/declare function={f=3*(x-2)*(x+3)/( (x-6)*(x+5));}] \begin{axis}[ xmin=-10,xmax=10, @@ -5373,9 +5373,9 @@ \addplot[pccplot] expression[domain=7.34324:10]{f}; \end{axis} \end{tikzpicture} - + \Vref{rat:fig:deducehard3} - + \begin{tikzpicture}[/pgf/declare function={f=2*(x-7)*(x+3)/( (x+6)*(x-5));}] \begin{axis}[ xmin=-10,xmax=10, @@ -5392,10 +5392,10 @@ \addplot[pccplot] expression[domain=5.25586:10]{f}; \end{axis} \end{tikzpicture} - + \end{shortsolution} \end{problem} - + \begin{figure}[!htb] \begin{widepage} \setlength{\figurewidth}{0.3\textwidth} @@ -5470,7 +5470,7 @@ $y=\dfrac{4}{x+2}$ \begin{shortsolution} Vertical intercept: $(0,2)$; vertical asymptote: $x=-2$, horizontal asymptote: $y=0$. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -5494,7 +5494,7 @@ Vertical intercept:$\left( 0,\frac{1}{9} \right)$; horizontal intercept: $\left( \frac{1}{2},0 \right)$; vertical asymptotes: $x=-3$, $x=3$, horizontal asymptote: $y=0$. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -5519,7 +5519,7 @@ \begin{shortsolution} Vertical intercept $\left( 0,-\frac{3}{5} \right)$; horizontal intercept: $(-3,0)$; vertical asymptote: $x=5$; horizontal asymptote: $y=1$. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -5544,7 +5544,7 @@ \begin{shortsolution} Vertical intercept: $(0,-3)$; horizontal intercept: $\left( -\frac{3}{2},0 \right)$; vertical asymptote: $x=\frac{1}{3}$, horizontal asymptote: $y=\frac{2}{3}$. - + \begin{tikzpicture}[/pgf/declare function={f=(2*x+3)/(3*x-1);}] \begin{axis}[ framed, @@ -5568,7 +5568,7 @@ Vertical intercept: $\left( 0,-\frac{4}{9} \right)$; horizontal intercepts: $(2,0)$, $(-2,0)$; vertical asymptotes: $x=-3$, $x=3$; horizontal asymptote: $y=-1$. - + \begin{tikzpicture}[/pgf/declare function={f=(4-x^2)/(x^2-9);}] \begin{axis}[ framed, @@ -5594,7 +5594,7 @@ Vertical intercept: $\left( 0,\frac{4}{5} \right)$; horizontal intercepts: $\left( -\frac{5}{4},0 \right)$, $\left( \frac{4}{3},0 \right)$; vertical asymptotes: $x=-\frac{5}{2}$, $x=5$; horizontal asymptote: $y=6$. - + \begin{tikzpicture}[/pgf/declare function={f=(4*x+5)*(3*x-4)/((2*x+5)*(x-5));}] \begin{axis}[ framed, @@ -5724,7 +5724,7 @@ R(x)= \begin{dcases} \frac{2}{x+3}, & x<-5 \\ - \frac{x-4}{x-10}, & x\geq -5 + \frac{x-4}{x-10}, & x\geq -5 \end{dcases} \] Evaluate each of the following. @@ -5762,7 +5762,7 @@ \end{subproblem} \end{problem} \end{exercises} - + \section{Graphing rational functions (oblique asymptotes)}\label{rat:sec:oblique} \begin{subproblem} $y=\dfrac{x^2+1}{x-4}$ @@ -5771,7 +5771,7 @@ \item $\left( 0,-\frac{1}{4} \right)$ \item Vertical asymptote: $x=4$. \item A graph of the function is shown below - + \begin{tikzpicture}[/pgf/declare function={f=(x^2+1)/(x-4);}] \begin{axis}[ framed, @@ -5798,7 +5798,7 @@ \item $(0,0)$, $(-3,0)$ \item Vertical asymptote: $x=5$, horizontal asymptote: none. \item A graph of the function is shown below - + \begin{tikzpicture}[/pgf/declare function={f=x^3*(x+3)/(x-5);}] \begin{axis}[ framed, diff --git a/Master/texmf-dist/doc/support/latexindent/success/sampleBEFORE.tex b/Master/texmf-dist/doc/support/latexindent/success/sampleBEFORE.tex index bf62bb9ee1f..ae704bd4bc1 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/sampleBEFORE.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/sampleBEFORE.tex @@ -25,7 +25,7 @@ a \emph{decreasing} function. Similarly, if $a>0$ then $g$ is \emph{concave up} and if $a<0$ then $g$ is \emph{concave down}. Graphical representations of these statements are given in \cref{poly:fig:linquad}. - + \begin{figure}[!htb] \setlength{\figurewidth}{.2\textwidth} \begin{subfigure}{\figurewidth} @@ -94,18 +94,18 @@ \caption{Typical graphs of linear and quadratic functions.} \label{poly:fig:linquad} \end{figure} - + Let's look a little more closely at the formulas for $f$ and $g$ in \cref{poly:eq:linquad}. Note that the \emph{degree} of $f$ is $1$ since the highest power of $x$ that is present in the formula for $f(x)$ is $1$. Similarly, the degree of $g$ is $2$ since the highest power of $x$ that is present in the formula for $g(x)$ is $2$. - + In this section we will build upon our knowledge of these elementary functions. In particular, we will generalize the functions $f$ and $g$ to a function $p$ that has any degree that we wish. - + %=================================== % Author: Hughes % Date: March 2012 @@ -161,7 +161,7 @@ \end{subproblem} \end{problem} \end{essentialskills} - + \subsection*{Power functions with positive exponents} The study of polynomials will rely upon a good knowledge of power functions| you may reasonably ask, what is a power function? @@ -171,17 +171,17 @@ f(x) = a_n x^n \] where $n$ can be any real number. - + Note that for this section we will only be concerned with the case when $n$ is a positive integer. \end{pccdefinition} - + You may find assurance in the fact that you are already very comfortable with power functions that have $n=1$ (linear) and $n=2$ (quadratic). Let's explore some power functions that you might not be so familiar with. As you read \cref{poly:ex:oddpow,poly:ex:evenpow}, try and spot as many patterns and similarities as you can. - + %=================================== % Author: Hughes % Date: March 2012 @@ -199,12 +199,12 @@ the long-run behavior of each of the functions is the same, and in particular \begin{align*} f(x)\rightarrow\infty & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} f(x)\rightarrow-\infty & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} f(x)\rightarrow-\infty & \text{ as } x\rightarrow-\infty \end{align*} The same results hold for $g$ and $h$. \end{pccsolution} \end{pccexample} - + \begin{figure}[!htb] \begin{minipage}{.45\textwidth} \begin{tikzpicture} @@ -254,7 +254,7 @@ \label{poly:fig:evenpow} \end{minipage}% \end{figure} - + %=================================== % Author: Hughes % Date: March 2012 @@ -271,12 +271,12 @@ of each of the functions is the same, and in particular \begin{align*} F(x)\rightarrow\infty & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} F(x)\rightarrow\infty & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} F(x)\rightarrow\infty & \text{ as } x\rightarrow-\infty \end{align*} The same result holds for $G$ and $H$. \end{pccsolution} \end{pccexample} - + \begin{doyouunderstand} \begin{problem} Repeat \cref{poly:ex:oddpow,poly:ex:evenpow} using (respectively) @@ -285,7 +285,7 @@ \begin{shortsolution} The functions $f$, $g$, and $h$ have domain $(-\infty,\infty)$ and are graphed below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -303,11 +303,11 @@ \legend{$f$,$g$,$h$} \end{axis} \end{tikzpicture} - + Note that \begin{align*} f(x)\rightarrow-\infty & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} f(x)\rightarrow\infty & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} f(x)\rightarrow\infty & \text{ as } x\rightarrow-\infty \end{align*} The same is true for $g$ and $h$. \end{shortsolution} @@ -317,7 +317,7 @@ \begin{shortsolution} The functions $F$, $G$, and $H$ have domain $(-\infty,\infty)$ and are graphed below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -335,18 +335,18 @@ \legend{$F$,$G$,$H$} \end{axis} \end{tikzpicture} - + Note that \begin{align*} F(x)\rightarrow-\infty & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} F(x)\rightarrow-\infty & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} F(x)\rightarrow-\infty & \text{ as } x\rightarrow-\infty \end{align*} The same is true for $G$ and $H$. \end{shortsolution} \end{subproblem} \end{problem} \end{doyouunderstand} - + \subsection*{Polynomial functions} Now that we have a little more familiarity with power functions, we can define polynomial functions. Provided that you were comfortable @@ -357,7 +357,7 @@ and quadratic functions. Once you've studied the examples and problems in this section, you'll hopefully agree that polynomial functions are remarkably predictable. - + %=================================== % Author: Hughes % Date: May 2011 @@ -376,11 +376,11 @@ \end{itemize} In particular, we call $a_n$ the \emph{leading} coefficient, and $a_nx^n$ the \emph{leading term}. - + Note that if a polynomial is given in factored form, then the degree can be found by counting the number of linear factors. \end{pccdefinition} - + %=================================== % Author: Hughes % Date: March 2012 @@ -416,7 +416,7 @@ \end{enumerate} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: March 2012 @@ -440,7 +440,7 @@ shape and long-run behavior to the functions described in \cref{poly:ex:oddpow}. \end{itemize} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2011 @@ -536,7 +536,7 @@ \caption{Graphs to illustrate typical curves of polynomial functions.} \label{poly:fig:typical} \end{figure} - + %=================================== % Author: Hughes % Date: March 2012 @@ -550,7 +550,7 @@ to guide you. \begin{shortsolution} $a_1<0$: - + \begin{tikzpicture} \begin{axis}[ framed, @@ -563,9 +563,9 @@ \addplot expression[domain=-10:8]{-(x+2)}; \end{axis} \end{tikzpicture} - + $a_2<0$ - + \begin{tikzpicture} \begin{axis}[ framed, @@ -578,9 +578,9 @@ \addplot expression[domain=-4:4]{-(x^2-6)}; \end{axis} \end{tikzpicture} - + $a_3<0$ - + \begin{tikzpicture} \begin{axis}[ framed, @@ -593,9 +593,9 @@ \addplot expression[domain=-7.5:7.5]{-0.05*(x+6)*x*(x-6)}; \end{axis} \end{tikzpicture} - + $a_4<0$ - + \begin{tikzpicture} \begin{axis}[ framed, @@ -608,9 +608,9 @@ \addplot expression[domain=-2.35:5.35,samples=100]{-0.2*(x-5)*x*(x-3)*(x+2)}; \end{axis} \end{tikzpicture} - + $a_5<0$ - + \begin{tikzpicture} \begin{axis}[ framed, @@ -626,11 +626,11 @@ \end{shortsolution} \end{problem} \end{doyouunderstand} - + \fixthis{poly: Need a more basic example here- it can have a similar format to the multiple zeros example, but just keep it simple; it should be halfway between the 2 examples surrounding it} - + %=================================== % Author: Hughes % Date: May 2011 @@ -642,24 +642,24 @@ \begin{align*} p(x) & =(x-3)^2(x+4)^2 \\ q(x) & =x(x+2)^2(x-1)^2(x-3) \\ - r(x) & =x(x-3)^3(x+1)^2 + r(x) & =x(x-3)^3(x+1)^2 \end{align*} Find the degree of $p$, $q$, and $r$, and decide if the functions bounce off or cut through the horizontal axis at each of their zeros. \begin{pccsolution} The degree of $p$ is 4. Referring to \cref{poly:fig:bouncep}, the curve bounces off the horizontal axis at both zeros, $3$ and $4$. - + The degree of $q$ is 6. Referring to \cref{poly:fig:bounceq}, the curve bounces off the horizontal axis at $-2$ and $1$, and cuts through the horizontal axis at $0$ and $3$. - + The degree of $r$ is 6. Referring to \cref{poly:fig:bouncer}, the curve bounces off the horizontal axis at $-1$, and cuts through the horizontal axis at $0$ and at $3$, although is flattened immediately to the left and right of $3$. \end{pccsolution} \end{pccexample} - + \setlength{\figurewidth}{0.25\textwidth} \begin{figure}[!htb] \begin{subfigure}{\figurewidth} @@ -712,7 +712,7 @@ \caption{} \label{poly:fig:moremultiple} \end{figure} - + \begin{pccdefinition}[Multiple zeros]\label{poly:def:multzero} Let $p$ be a polynomial that has a repeated linear factor $(x-a)^n$. Then we say that $p$ has a multiple zero at $a$ of multiplicity $n$ and @@ -724,7 +724,7 @@ \end{itemize} If $n=1$, then we say that $p$ has a \emph{simple} zero at $a$. \end{pccdefinition} - + %=================================== % Author: Hughes % Date: May 2011 @@ -786,7 +786,7 @@ Let's check if the formula we have written satisfies this requirement \begin{align*} p(1) & = (1)(4)(2)(-1) \\ - & = -8 + & = -8 \end{align*} which is clearly not correct| it is close though. We can correct this by multiplying $p$ by a constant $k$; so let's assume that @@ -807,7 +807,7 @@ evaluate $p(2)$ \begin{align*} p(2) & =k(4)^2(-1) \\ - & =-16k + & =-16k \end{align*} We solve the equation $4=-8k$ and obtain $k=-\frac{1}{4}$ and conclude that the formula for $q(x)$ is @@ -817,8 +817,8 @@ \end{enumerate} \end{pccsolution} \end{pccexample} - - + + \fixthis{Chris: need sketching polynomial problems} \begin{pccspecialcomment}[Steps to follow when sketching polynomial functions] \begin{steps} @@ -865,12 +865,12 @@ \item We draw the details we have obtained so far on \cref{poly:fig:simplecubicp1}. Given that the curve of $p$ looks like the curve of $x^3$ in the long-run, we are able to complete a sketch of the graph of $p$ in \cref{poly:fig:simplecubicp2}. - + Note that we can not find the coordinates of the local minimums, local maximums, and inflection points| for the moment we make reasonable guesses as to where these points are (you'll find how to do this in calculus). \end{steps} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -909,7 +909,7 @@ \end{figure} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2012 @@ -934,7 +934,7 @@ \item We mark the details we have found so far on \cref{poly:fig:degree5p1}. Given that the curve of $q$ looks like the curve of $-x^5$ in the long-run, we can complete \cref{poly:fig:degree5p2}. \end{steps} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -973,7 +973,7 @@ \end{figure} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2012 @@ -1000,7 +1000,7 @@ the curve of $r$ looks like the curve of $x^6$ in the long-run, we complete the graph of $r$ in \cref{poly:fig:degree6p2}. \end{steps} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -1038,7 +1038,7 @@ \end{figure} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: March 2012 @@ -1058,7 +1058,7 @@ $x$ represents the length of a side, and $V(x)$ represents the volume of the box, we necessarily require both values to be positive; we illustrate the part of the curve that applies to this problem using a solid line. - + \begin{figure}[!htb] \centering \begin{tikzpicture} @@ -1080,21 +1080,21 @@ \caption{$y=V(x)$} \label{poly:fig:opentoppedbox} \end{figure} - + According to \cref{poly:fig:opentoppedbox}, the maximum volume of such a box is approximately $\unit[4000]{cm^2}$, and we achieve it using a base of length approximately $\unit[20]{cm}$. Since the base is square and each sheet of cardboard is $\unit[1200]{cm^2}$, we conclude that the dimensions of each box are $\unit[20]{cm}\times\unit[20]{cm}\times\unit[30]{cm}$. \end{pccsolution} \end{pccexample} - + \subsection*{Complex zeros} There has been a pattern to all of the examples that we have seen so far| the degree of the polynomial has dictated the number of \emph{real} zeros that the polynomial has. For example, the function $p$ in \cref{poly:ex:simplecubic} has degree $3$, and $p$ has $3$ real zeros; the function $q$ in \cref{poly:ex:degree5} has degree $5$ and $q$ has $5$ real zeros. - + You may wonder if this result can be generalized| does every polynomial that has degree $n$ have $n$ real zeros? Before we tackle the general result, let's consider an example that may help motivate it. @@ -1113,7 +1113,7 @@ x^2+1=0 \end{equation} The solutions to \cref{poly:eq:complx} are $\pm i$. - + We conclude that $c$ has $3$ zeros: $0$ and $\pm i$; we note that \emph{not all of them are real}. \end{pccexample} @@ -1143,7 +1143,7 @@ We begin by factoring $p$ \begin{align*} p(x) & =x^4-2x^3+5x^2 \\ - & =x^2(x^2-2x+5) + & =x^2(x^2-2x+5) \end{align*} We note that $0$ is a zero of $p$ with multiplicity $2$. The other zeros of $p$ can be found by solving the equation @@ -1154,7 +1154,7 @@ \begin{align*} x & =\frac{2\pm\sqrt{(-2)^2}-20}{2(1)} \\ & =\frac{2\pm\sqrt{-16}}{2} \\ - & =1\pm 2i + & =1\pm 2i \end{align*} We conclude that $p$ has $4$ zeros: $0$ (multiplicity $2$), and $1\pm 2i$ (simple). \end{pccsolution} @@ -1169,13 +1169,13 @@ We know that the zeros of a polynomial can be found by analyzing the linear factors. We are given the zeros, and have to work backwards to find the linear factors. - + We begin by assuming that $p$ has the form \begin{align*} p(x) & =(x-(2-i\sqrt{2}))(x-(2+i\sqrt{2})) \\ & =x^2-x(2+i\sqrt{2})-x(2-i\sqrt{2})+(2-i\sqrt{2})(2+i\sqrt{2}) \\ & =x^2-4x+(4-2i^2) \\ - & =x^2-4x+6 + & =x^2-4x+6 \end{align*} We conclude that a possible formula for a polynomial function, $p$, that has zeros at $2\pm i\sqrt{2}$ is @@ -1235,8 +1235,8 @@ \end{enumerate} \end{shortsolution} \end{problem} - - + + \begin{figure}[!htb] \setlength{\figurewidth}{0.3\textwidth} \begin{subfigure}{\figurewidth} @@ -1287,10 +1287,10 @@ \caption{} \label{poly:fig:findformula} \end{figure} - - - - + + + + \begin{exercises} %=================================== % Author: Hughes @@ -1459,14 +1459,14 @@ \begin{align*} p(x) & = (x-1)(x+2)(x-3) \\ m(x) & = -(x-1)(x+2)(x-3) \\ - n(x) & = (x-1)(x+2)(x-3)(x+1)(x+4) + n(x) & = (x-1)(x+2)(x-3)(x+1)(x+4) \end{align*} Note that for our present purposes we are not concerned with the vertical scale of the graphs. \begin{subproblem} Identify both on the graph {\em and} algebraically, the zeros of each polynomial. \begin{shortsolution} $y=p(x)$ is shown below. - + \begin{tikzpicture} \begin{axis}[ xmin=-5,xmax=5, @@ -1477,9 +1477,9 @@ \addplot[soldot] coordinates{(-2,0)(1,0)(3,0)}; \end{axis} \end{tikzpicture} - + $y=m(x)$ is shown below. - + \begin{tikzpicture} \begin{axis}[ xmin=-5,xmax=5, @@ -1490,9 +1490,9 @@ \addplot[soldot] coordinates{(-2,0)(1,0)(3,0)}; \end{axis} \end{tikzpicture} - + $y=n(x)$ is shown below. - + \begin{tikzpicture} \begin{axis}[ xmin=-5,xmax=5, @@ -1503,7 +1503,7 @@ \addplot[soldot] coordinates{(-4,0)(-2,0)(-1,0)(1,0)(3,0)}; \end{axis} \end{tikzpicture} - + The zeros of $p$ are $-2$, $1$, and $3$; the zeros of $m$ are $-2$, $1$, and $3$; the zeros of $n$ are $-4$, $-2$, $-1$, and $3$. \end{shortsolution} @@ -1520,7 +1520,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + \begin{figure}[!htb] \begin{widepage} \setlength{\figurewidth}{0.3\textwidth} @@ -1773,7 +1773,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -1792,7 +1792,7 @@ $\dd\lim_{x\rightarrow\infty}s(x)=\infty$, \end{shortsolution} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -1917,7 +1917,7 @@ is positive. \begin{shortsolution} Assuming that $a_3>0$: - + \begin{tikzpicture} \begin{axis}[ xmin=-10,xmax=10, @@ -1937,7 +1937,7 @@ is negative. \begin{shortsolution} Assuming that $a_3<0$: - + \begin{tikzpicture} \begin{axis}[ xmin=-10,xmax=10, @@ -1961,7 +1961,7 @@ coefficient of $q$ is positive. Hint: only one of the zeros is simple. \begin{shortsolution} Assuming that $a_4>0$ there are $2$ different options: - + \begin{tikzpicture} \begin{axis}[ xmin=-10,xmax=10, @@ -1982,7 +1982,7 @@ coefficient of $q$ is negative. \begin{shortsolution} Assuming that $a_4<0$ there are $2$ different options: - + \begin{tikzpicture} \begin{axis}[ xmin=-10,xmax=10, @@ -2194,7 +2194,7 @@ \end{subproblem} \end{multicols} \end{problem} - + %=================================== % Author: Hughes % Date: July 2012 @@ -2238,7 +2238,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + %=================================== % Author: Hughes % Date: July 2012 @@ -2290,7 +2290,7 @@ \end{subproblem} \end{multicols} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -2298,7 +2298,7 @@ \begin{problem}[Find a formula from a table]\label{poly:prob:findformula} \Crefrange{poly:tab:findformulap}{poly:tab:findformulas} show values of polynomial functions, $p$, $q$, $r$, and $s$. - + \begin{table}[!htb] \centering \begin{widepage} @@ -2382,7 +2382,7 @@ \end{subtable} \end{widepage} \end{table} - + \begin{subproblem} Assuming that all of the zeros of $p$ are shown (in \cref{poly:tab:findformulap}), how many zeros does $p$ have? \begin{shortsolution} @@ -2433,7 +2433,7 @@ \end{subproblem} \end{problem} \end{exercises} - + \section{Rational functions} \subsection*{Power functions with negative exponents} The study of rational functions will rely upon a good knowledge @@ -2455,21 +2455,21 @@ the long-run behavior of each of the functions is the same, and in particular \begin{align*} f(x)\rightarrow 0 & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} f(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} f(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty \end{align*} The same results hold for $g$ and $h$. Note also that each of the functions has a \emph{vertical asymptote} at $0$. We see that \begin{align*} f(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^- \\ - \mathllap{\text{and }} f(x)\rightarrow \infty & \text{ as } x\rightarrow 0^+ + \mathllap{\text{and }} f(x)\rightarrow \infty & \text{ as } x\rightarrow 0^+ \end{align*} The same results hold for $g$ and $h$. - + The curve of a function that has a vertical asymptote is necessarily separated into \emph{branches}| each of the functions $f$, $g$, and $h$ have $2$ branches. \end{pccsolution} \end{pccexample} - + \begin{figure}[!htb] \begin{minipage}{.45\textwidth} \begin{tikzpicture} @@ -2525,8 +2525,8 @@ \label{rat:fig:evenpow} \end{minipage}% \end{figure} - - + + %=================================== % Author: Hughes % Date: May 2011 @@ -2543,7 +2543,7 @@ the long-run behavior of each of the functions is the same, and in particular \begin{align*} F(x)\rightarrow 0 & \text{ as } x\rightarrow\infty \\ - \mathllap{\text{and }} f(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty + \mathllap{\text{and }} f(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty \end{align*} As in \cref{rat:ex:oddpow}, $F$ has a horizontal asymptote that has equation $y=0$. @@ -2551,7 +2551,7 @@ has a \emph{vertical asymptote} at $0$. We see that \begin{align*} F(x)\rightarrow \infty & \text{ as } x\rightarrow 0^- \\ - \mathllap{\text{and }} F(x)\rightarrow \infty & \text{ as } x\rightarrow 0^+ + \mathllap{\text{and }} F(x)\rightarrow \infty & \text{ as } x\rightarrow 0^+ \end{align*} The same results hold for $G$ and $H$. Each of the functions $F$, $G$, and $H$ have $2$ branches. @@ -2569,7 +2569,7 @@ \begin{shortsolution} The functions $k$, $m$, and $n$ have domain $(-\infty,0)\cup (0,\infty)$, and are graphed below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -2590,14 +2590,14 @@ \legend{$k$,$m$,$n$} \end{axis} \end{tikzpicture} - + Note that \begin{align*} k(x)\rightarrow 0 & \text{ as } x\rightarrow\infty \\ \mathllap{\text{and }} k(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty \\ \intertext{and also} k(x)\rightarrow \infty & \text{ as } x\rightarrow 0^- \\ - \mathllap{\text{and }} k(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^+ + \mathllap{\text{and }} k(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^+ \end{align*} The same are true for $m$ and $n$. \end{shortsolution} @@ -2607,7 +2607,7 @@ \begin{shortsolution} The functions $K$, $M$, and $N$ have domain $(-\infty,0)\cup (0,\infty)$, and are graphed below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -2628,21 +2628,21 @@ \legend{$K$,$M$,$N$} \end{axis} \end{tikzpicture} - + Note that \begin{align*} K(x)\rightarrow 0 & \text{ as } x\rightarrow\infty \\ \mathllap{\text{and }} K(x)\rightarrow 0 & \text{ as } x\rightarrow-\infty \\ \intertext{and also} K(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^- \\ - \mathllap{\text{and }} K(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^+ + \mathllap{\text{and }} K(x)\rightarrow -\infty & \text{ as } x\rightarrow 0^+ \end{align*} The same are true for $M$ and $N$. \end{shortsolution} \end{subproblem} \end{problem} \end{doyouunderstand} - + \subsection*{Rational functions} \begin{pccdefinition}[Rational functions]\label{rat:def:function} Rational functions have the form @@ -2650,7 +2650,7 @@ r(x) = \frac{p(x)}{q(x)} \] where both $p$ and $q$ are polynomials. - + Note that \begin{itemize} \item the domain or $r$ will be all real numbers, except those that @@ -2658,13 +2658,13 @@ \item the zeros of $r$ are the zeros of $p$, i.e the real numbers that make the \emph{numerator}, $p(x)$, equal to $0$. \end{itemize} - + \Cref{rat:ex:oddpow,rat:ex:evenpow} are particularly important because $r$ will behave like $\frac{1}{x}$, or $\frac{1}{x^2}$ around its vertical asymptotes, depending on the power that the relevant term is raised to| we will demonstrate this in what follows. \end{pccdefinition} - + %=================================== % Author: Hughes % Date: May 2011 @@ -2699,7 +2699,7 @@ \end{enumerate} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2011 @@ -2779,7 +2779,7 @@ \caption{} \label{rat:fig:whichiswhich} \end{figure} - + \begin{pccsolution} Let's start with the function $r$. Note that domain of $r$ is $(-\infty,3)\cup(0,3)$, so we search for a function that has a vertical asymptote at $3$. There @@ -2787,18 +2787,18 @@ but note that the function in \cref{rat:fig:which3} also has a vertical asymptote at $-2$ which is not consistent with the formula for $r(x)$. Therefore, $y=r(x)$ is graphed in \cref{rat:fig:which2}. - + The function $q$ has domain $(-\infty,-5)\cup(-5,\infty)$, so we search for a function that has a vertical asymptote at $-5$. The only candidate is the curve shown in \cref{rat:fig:which1}; note that the curve also goes through $(2,0)$, which is consistent with the formula for $q(x)$, since $q(2)=0$, i.e $q$ has a zero at $2$. - + The function $k$ has domain $(-\infty,-2)\cup(-2,3)\cup(3,\infty)$, and has vertical asymptotes at $-2$ and $3$. This is consistent with the graph in \cref{rat:fig:which3} (and is the only curve that has $3$ branches). - + We note that each function behaves like $\frac{1}{x}$ around its vertical asymptotes, because each linear factor in each denominator is raised to the power $1$; if (for example) the definition of $r$ was instead @@ -2809,7 +2809,7 @@ the graph of $r$ would be very different. We will deal with these cases in the examples that follow. \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2011 @@ -2827,7 +2827,7 @@ so we are not surprised to see that each curve has $3$ branches. We also note that the numerator of each function is the same, which tells us that each function has only $1$ zero at $2$. - + The functions $g$ and $h$ are different from those that we have considered previously, because they have a repeated factor in the denominator. Notice in particular the way that the functions behave around their asymptotes: @@ -2910,7 +2910,7 @@ \caption{} \label{rat:fig:repfactd} \end{figure} - + \Cref{rat:def:function} says that the zeros of the rational function $r$ that has formula $r(x)=\frac{p(x)}{q(x)}$ are the zeros of $p$. Let's explore this a little more. @@ -2929,9 +2929,9 @@ x+5=0 \] The zero of $\alpha$ is $-5$. - + Similarly, we may solve $9-x=0$ to find the zero of $\beta$, which is clearly $9$. - + The zeros of $\gamma$ satisfy the equation \[ 17x^2-10=0 @@ -2943,7 +2943,7 @@ The zeros of $\gamma$ are $\pm\frac{10}{17}$. \end{pccsolution} \end{pccexample} - + \subsection*{Long-run behavior} Our focus so far has been on the behavior of rational functions around their \emph{vertical} asymptotes. In fact, rational functions also @@ -2966,7 +2966,7 @@ \end{pccdefinition} We will concentrate on functions that have horizontal asymptotes until we reach \cref{rat:sec:oblique}. - + %=================================== % Author: Hughes % Date: May 2012 @@ -2979,7 +2979,7 @@ and obtained the curves shown in \cref{rat:fig:horizasymp}. Kebede decides to test his knowledgeable friend \pccname{Oscar}, and asks him to match the formulas to the graphs. - + \begin{figure}[!htb] \setlength{\figurewidth}{0.3\textwidth} \begin{subfigure}{\figurewidth} @@ -3050,7 +3050,7 @@ \caption{Horizontal asymptotes} \label{rat:fig:horizasymp} \end{figure} - + Oscar notices that each function has a vertical asymptote at $3$ and a zero at $-1$. The main thing that catches Oscar's eye is that each function has a different coefficient in the numerator, and that each curve has a different horizontal asymptote. @@ -3064,14 +3064,14 @@ that since the degree of the numerator and the degree of the denominator is the same for each of the functions $r$, $s$, and $t$, the horizontal asymptote will be determined by evaluating the ratio of their leading coefficients. - + Oscar therefore says that $r$ should have a horizontal asymptote $y=\frac{1}{1}=1$, $s$ should have a horizontal asymptote $y=\frac{2}{1}=2$, and $t$ should have a horizontal asymptote $y=\frac{3}{1}=3$. Kebede is able to finish the problem from here, and says that $r$ is shown in \cref{rat:fig:horizasymp2}, $s$ is shown in \cref{rat:fig:horizasymp1}, and $t$ is shown in \cref{rat:fig:horizasymp3}. \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2012 @@ -3080,7 +3080,7 @@ \pccname{Xiao} and \pccname{Dwayne} saw \cref{rat:ex:horizasymp} but are a little confused about horizontal asymptotes. What does it mean to say that a function $r$ has a horizontal asymptote? - + They decide to explore the concept by constructing a table of values for the rational functions $R$ and $S$ that have formulas \[ @@ -3119,13 +3119,13 @@ \end{tabular} \end{minipage} \end{table} - + Xiao and Dwayne study \cref{rat:tab:plusinfty,rat:tab:minusinfty} and decide that the functions $R$ and $S$ never actually touch their horizontal asymptotes, but they do get infinitely close. They also feel as if they have a better understanding of what it means to study the behavior of a function as $x\rightarrow\pm\infty$. \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2011 @@ -3142,7 +3142,7 @@ \] We also notice that the numerators of each function are quite similar| indeed, each function has a zero at $2$, but how does each function behave around their zero? - + Using \cref{rat:fig:repfactn} to guide us, we note that \begin{itemize} \item $f$ has a horizontal intercept $(2,0)$, but the curve of @@ -3152,7 +3152,7 @@ \item $h$ has a horizontal intercept $(2,0)$, and the curve of $h$ also cuts the axis, but appears flattened as it does so. \end{itemize} - + We can further enrich our study by discussing the long-run behavior of each function. Using the tools of \cref{rat:def:longrun}, we can deduce that \begin{itemize} @@ -3162,7 +3162,7 @@ study this more in \cref{rat:sec:oblique}). \end{itemize} \end{pccexample} - + \begin{figure}[!htb] \setlength{\figurewidth}{0.3\textwidth} \begin{subfigure}{\figurewidth} @@ -3235,7 +3235,7 @@ \caption{} \label{rat:fig:repfactn} \end{figure} - + \subsection*{Holes} Rational functions have a vertical asymptote at $a$ if the denominator is $0$ at $a$. What happens if the numerator is $0$ at the same place? In this case, we say that the rational @@ -3250,7 +3250,7 @@ $(a,r(a))$ on the curve $y=r(x)$ by using a hollow circle, $\circ$. \end{pccdefinition} - + %=================================== % Author: Hughes % Date: March 2012 @@ -3262,12 +3262,12 @@ \] in their calculators, and can not decide if the correct graph is \cref{rat:fig:hole} or \cref{rat:fig:hole1}. - + Luckily for them, Oscar is nearby, and can help them settle the debate. Oscar demonstrates that \begin{align*} r(x) & =\frac{(x+3)(x-2)}{(x-2)} \\ - & = x+3 + & = x+3 \end{align*} but only when $x\ne 2$, because the function is undefined at $2$. Oscar says that this necessarily means that the domain or $r$ is @@ -3275,7 +3275,7 @@ (-\infty,2)\cup(2,\infty) \] and that $r$ must have a hole at $2$. - + Mohammed and Sue are very grateful for the clarification, and conclude that the graph of $r$ is shown in \cref{rat:fig:hole1}. \begin{figure}[!htb] @@ -3319,7 +3319,7 @@ \end{minipage}% \end{figure} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2011 @@ -3333,12 +3333,12 @@ make the denominator equal to $0$. Notice that \begin{align*} f(x) & = \frac{x(x+3)}{x(x-4)} \\ - & = \frac{x+3}{x-4} + & = \frac{x+3}{x-4} \end{align*} provided that $x\ne 0$. Since $0$ makes the numerator and the denominator 0 at the same time, we say that $f$ has a hole at $(0,-\nicefrac{3}{4})$. Note that this necessarily means that $f$ does not have a vertical intercept. - + We also note $f$ has a vertical asymptote at $4$; the function is graphed in \cref{rat:fig:holeex}. \begin{figure}[!htb] \centering @@ -3362,9 +3362,9 @@ \label{rat:fig:holeex} \end{figure} \end{pccexample} - - - + + + %=================================== % Author: Hughes % Date: March 2012 @@ -3374,7 +3374,7 @@ if a rational function has a vertical asymptote, then it can not possibly have local minimums and maximums, nor can it have global minimums and maximums. - + Trang says this statement is not always true. She plots the functions $f$ and $g$ that have formulas \[ @@ -3383,7 +3383,7 @@ in \cref{rat:fig:minmax1,rat:fig:minmax2} and shows them to Seamus. On seeing the graphs, Seamus quickly corrects himself, and says that $f$ has a local (and global) maximum of $2$ at $0$, and that $g$ has a local (and global) minimum of $-2$ at $0$. - + \begin{figure}[!htb] \begin{minipage}{.45\textwidth} \begin{tikzpicture}[/pgf/declare function={f=-32*(x-1)*(x+1)/(( x-2)^2*(x+2)^2);}] @@ -3427,19 +3427,19 @@ \label{rat:fig:minmax2} \end{minipage}% \end{figure} - + Seamus also notes that (in its domain) the function $f$ is always concave down, and that (in its domain) the function $g$ is always concave up. Furthermore, Trang observes that each function behaves like $\frac{1}{x^2}$ around each of its vertical asymptotes, because each linear factor in the denominator is raised to the power $2$. - + \pccname{Oscar} stops by and reminds both students about the long-run behavior; according to \cref{rat:def:longrun} since the degree of the denominator is greater than the degree of the numerator (in both functions), each function has a horizontal asymptote at $y=0$. \end{pccexample} - - + + \investigation*{} %=================================== % Author: Pettit/Hughes @@ -3448,12 +3448,12 @@ \begin{problem}[The spaghetti incident] The same Queen from \vref{exp:prob:queenschessboard} has recovered from the rice experiments, and has called her loyal jester for another challenge. - + The jester has an $11-$inch piece of uncooked spaghetti that he puts on a table; he uses a book to cover $\unit[1]{inch}$ of it so that $\unit[10]{inches}$ hang over the edge. The jester then produces a box of $\unit{mg}$ weights that can be hung from the spaghetti. - + The jester says it will take $\unit[y]{mg}$ to break the spaghetti when hung $\unit[x]{inches}$ from the edge, according to the rule $y=\frac{100}{x}$. \begin{margintable} @@ -3537,7 +3537,7 @@ note that this necessarily means that you will not be able to plot all of the points. \begin{shortsolution} The graph of $y=\frac{100}{x}$ is shown below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -3567,9 +3567,9 @@ \end{subproblem} The Queen looks forward to more food-related investigations from her jester. \end{problem} - - - + + + %=================================== % Author: Adams (Hughes) % Date: March 2012 @@ -3593,17 +3593,17 @@ Paying off the debt in $2$ years, we use \begin{align*} M & = \frac{2000\cdot 0.015}{1-(1+0.015)^{-24}} \\ - & \approx 99.85 + & \approx 99.85 \end{align*} The monthly payments are \$99.85. - + Paying off the debt in $1$ year, we use \begin{align*} M & = \frac{2000\cdot 0.015}{1-(1+0.015)^{-12}} \\ - & \approx 183.36 + & \approx 183.36 \end{align*} The monthly payments are \$183.36 - + In the $2$-year model we would pay a total of $\$99.85\cdot 12=\$2396.40$. In the $1$-year model we would pay a total of $\$183.36\cdot 12=\$2200.32$. We would therefore save $\$196.08$ if we went with the $1$-year model instead of the $2$-year model. @@ -3619,20 +3619,20 @@ For the $20$-year loan we use \begin{align*} M & = \frac{300000\cdot \frac{0.052}{12}}{1-\left( 1+\frac{0.052}{12} \right)^{-12\cdot 20}} \\ - & \approx 2013.16 + & \approx 2013.16 \end{align*} The monthly payments are \$2013.16. - + For the $30$-year loan we use \begin{align*} M & = \frac{300000\cdot \frac{0.052}{12}}{1-\left( 1+\frac{0.052}{12} \right)^{-12\cdot 30}} \\ - & \approx 1647.33 + & \approx 1647.33 \end{align*} The monthly payments are \$1647.33. - + The total amount paid during the $20$-year loan is $\$2013.16\cdot 12\cdot 20=\$483,158.40$. The total amount paid during the $30$-year loan is $\$1647.33\cdot 12\cdot 30=\$593,038.80$. - + Recommendation: if you can afford the payments, choose the $20$-year loan. \end{shortsolution} \end{subproblem} @@ -3662,7 +3662,7 @@ This means that the monthly payments will be calculated using \begin{align*} M & = \frac{14000\cdot \frac{0.04}{12}}{1-\left( 1+\frac{0.04}{12} \right)^{-12\cdot 5}} \\ - & \approx 257.83 + & \approx 257.83 \end{align*} The monthly payments will be $\$257.83$. The total amount paid will be $\$257.83\cdot 5\cdot 12=\$15,469.80$, of which $\$1469.80$ is interest. @@ -3670,7 +3670,7 @@ This means that the monthly payments will be calculated using \begin{align*} M & = \frac{12000\cdot \frac{0.08}{12}}{1-\left( 1+\frac{0.08}{12} \right)^{-12\cdot 5}} \\ - & \approx 243.32 + & \approx 243.32 \end{align*} The monthly payments will be $\$243.32$. The total amount paid will be $\$243.32\cdot 5\cdot 12 =\$14,599.20$, of which $\$2599.2$ is @@ -3681,7 +3681,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + \begin{exercises} %=================================== % Author: Hughes @@ -3783,7 +3783,7 @@ $\begin{aligned}[t] r(0) & =\frac{(0-2)(0+3)}{(0+5)(0-7)} \\ & =\frac{-6}{-35} \\ - & =\frac{6}{35} + & =\frac{6}{35} \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3793,7 +3793,7 @@ $\begin{aligned}[t] r(1) & =\frac{(1-2)(1+3)}{(1+5)(1-7)} \\ & =\frac{-4}{-36} \\ - & =\frac{1}{9} + & =\frac{1}{9} \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3803,7 +3803,7 @@ $\begin{aligned}[t] r(2) & =\frac{(2-2)(2+3)}{(2+5)(2-7)} \\ & = \frac{0}{-50} \\ - & =0 + & =0 \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3813,7 +3813,7 @@ $\begin{aligned}[t] r(4) & =\frac{(4-2)(4+3)}{(4+5)(4-7)} \\ & =\frac{14}{-27} \\ - & =-\frac{14}{27} + & =-\frac{14}{27} \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3822,9 +3822,9 @@ \begin{shortsolution} $\begin{aligned}[t] r(7) & =\frac{(7-2)(7+3)}{(7+5)(7-7)} \\ - & =\frac{50}{0} + & =\frac{50}{0} \end{aligned}$ - + $r(7)$ is undefined. \end{shortsolution} \end{subproblem} @@ -3834,7 +3834,7 @@ $\begin{aligned}[t] r(-3) & =\frac{(-3-2)(-3+3)}{(-3+5)(-3-7)} \\ & =\frac{0}{-20} \\ - & =0 + & =0 \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3843,9 +3843,9 @@ \begin{shortsolution} $\begin{aligned}[t] r(-5) & =\frac{(-5-2)(-5+3)}{(-5+5)(-5-7)} \\ - & =\frac{14}{0} + & =\frac{14}{0} \end{aligned}$ - + $r(-5)$ is undefined. \end{shortsolution} \end{subproblem} @@ -3856,7 +3856,7 @@ r\left( \frac{1}{2} \right) & = \frac{\left( \frac{1}{2}-2 \right)\left( \frac{1}{2}+3 \right)}{\left( \frac{1}{2}+5 \right)\left( \frac{1}{2}-7 \right)} \\ & =\frac{-\frac{3}{2}\cdot\frac{7}{2}}{\frac{11}{2}\left( -\frac{13}{2} \right)} \\ & =\frac{-\frac{21}{4}}{-\frac{143}{4}} \\ - & =\frac{37}{143} + & =\frac{37}{143} \end{aligned}$ \end{shortsolution} \end{subproblem} @@ -3908,7 +3908,7 @@ \end{subproblem} \end{multicols} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -3925,7 +3925,7 @@ \end{itemize} \end{shortsolution} \end{problem} - + \begin{figure}[!htb] \begin{widepage} \setlength{\figurewidth}{0.3\textwidth} @@ -3997,7 +3997,7 @@ \label{rat:fig:findformula} \end{widepage} \end{figure} - + %=================================== % Author: Hughes % Date: May 2011 @@ -4034,7 +4034,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -4099,7 +4099,7 @@ \end{subproblem} \end{multicols} \end{problem} - + %=================================== % Author: Hughes % Date: May 2012 @@ -4181,7 +4181,7 @@ \end{subproblem} \end{multicols} \end{problem} - + %=================================== % Author: Hughes % Date: May 2011 @@ -4212,7 +4212,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + %=================================== % Author: Hughes % Date: Feb 2011 @@ -4265,8 +4265,8 @@ \end{shortsolution} \end{subproblem} \end{problem} - - + + %=================================== % Author: Hughes % Date: May 2011 @@ -4309,7 +4309,7 @@ Sketch a graph of $r$. \begin{shortsolution} A graph of $r$ is shown below. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -4329,7 +4329,7 @@ \end{shortsolution} \end{subproblem} \end{problem} - + %=================================== % Author: Hughes % Date: July 2012 @@ -4367,8 +4367,8 @@ \end{subproblem} \end{multicols} \end{problem} - - + + %=================================== % Author: Hughes % Date: July 2012 @@ -4419,8 +4419,8 @@ \end{subproblem} \end{multicols} \end{problem} - - + + %=================================== % Author: Hughes % Date: May 2011 @@ -4428,7 +4428,7 @@ \begin{problem}[Find a formula from a table]\label{rat:prob:findformula} \Crefrange{rat:tab:findformular}{rat:tab:findformulau} show values of rational functions $r$, $q$, $s$, and $t$. Assume that any values marked with an X are undefined. - + \begin{table}[!htb] \begin{widepage} \centering @@ -4525,7 +4525,7 @@ r(-4) & = \frac{-4-3}{-4+2} \\ & = \frac{7}{2} \\ \end{aligned}$ - + $r(-3)=\ldots$ etc \end{shortsolution} \end{subproblem} @@ -4541,9 +4541,9 @@ \begin{shortsolution} $\begin{aligned}[t] s(-4) & =\frac{-4+2}{(-4-3)(-4+1)} \\ - & =-\frac{2}{21} + & =-\frac{2}{21} \end{aligned}$ - + $s(-3)=\ldots$ etc \end{shortsolution} \end{subproblem} @@ -4563,13 +4563,13 @@ \end{subproblem} \end{problem} \end{exercises} - + \section{Graphing rational functions (horizontal asymptotes)} \reformatstepslist{R} % the steps list should be R1, R2, \ldots We studied rational functions in the previous section, but were not asked to graph them; in this section we will demonstrate the steps to be followed in order to sketch graphs of the functions. - + Remember from \vref{rat:def:function} that rational functions have the form \[ @@ -4583,7 +4583,7 @@ in this section \emph{will have a horizontal asymptote} (see \vref{rat:def:longrun}). The cases in which the degree of $p$ is greater than the degree of $q$ is covered in the next section. - + Before we begin, it is important to remember the following: \begin{itemize} \item Our sketches will give a good representation of the overall @@ -4612,10 +4612,10 @@ find the exact coordinates of local minimums, local maximums, and points of inflection. \end{pccspecialcomment} - + The examples that follow show how \crefrange{rat:step:first}{rat:step:last} can be applied to a variety of different rational functions. - + %=================================== % Author: Hughes % Date: May 2012 @@ -4641,7 +4641,7 @@ \end{steps} \end{pccsolution} \end{pccexample} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -4678,14 +4678,14 @@ \end{subfigure}% \caption{$y=\dfrac{1}{x-2}$} \end{figure} - + The function $r$ in \cref{rat:ex:1overxminus2p2} has a horizontal asymptote which has equation $y=0$. This asymptote lies on the horizontal axis, and you might (understandably) find it hard to distinguish between the two lines (\cref{rat:fig:1overxminus2p2}). When faced with such a situation, it is perfectly acceptable to draw the horizontal axis as a dashed line| just make sure to label it correctly. We will demonstrate this in the next example. - + %=================================== % Author: Hughes % Date: May 2012 @@ -4711,12 +4711,12 @@ is, because we know what the overall shape will be. Let's compute $v(2)$ \begin{align*} v(2) & =\dfrac{10}{2} \\ - & = 5 + & = 5 \end{align*} We therefore mark the point $(2,5)$ on \cref{rat:fig:1overxp2}, and then complete the sketch using the details we found in the previous steps. \end{steps} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -4760,7 +4760,7 @@ \end{figure} \end{pccsolution} \end{pccexample} - + %=================================== % Author: Hughes % Date: May 2012 @@ -4778,7 +4778,7 @@ \begin{align*} u(x) & =\frac{-4(x^2-9)}{x^2-8x+15} \\ & =\frac{-4(x+3)(x-3)}{(x-5)(x-3)} \\ - & =\frac{-4(x+3)}{x-5} + & =\frac{-4(x+3)}{x-5} \end{align*} provided that $x\ne 3$. Therefore $u$ has a vertical asymptote at $5$ and a hole at $3$. The curve of $u$ has $2$ branches. @@ -4788,7 +4788,7 @@ \item We put the details we have obtained so far on \cref{rat:fig:1overxminus2p1}. Notice that there is only one way to complete the graph, which we have done in \cref{rat:fig:1overxminus2p2}. \end{steps} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -4833,12 +4833,12 @@ \end{figure} \end{pccsolution} \end{pccexample} - + \Cref{rat:ex:1overxminus2p2,rat:ex:1overxp1,rat:ex:asympandholep1} have focused on functions that only have one vertical asymptote; the remaining examples in this section concern functions that have more than one vertical asymptote. We will demonstrate that \crefrange{rat:step:first}{rat:step:last} still apply. - + %=================================== % Author: Hughes % Date: May 2012 @@ -4862,20 +4862,20 @@ of the numerator and denominator, we say that $w$ has a horizontal asymptote with equation $y=\frac{2}{1}=2$. \item We put the details we have obtained so far on \cref{rat:fig:sketchtwoasymptp1}. - + The function $w$ is a little more complicated than the functions that we have considered in the previous examples because the curve has $3$ branches. When graphing such functions, it is generally a good idea to start with the branch for which you have the most information| in this case, that is the \emph{middle} branch on the interval $(-5,4)$. - + Once we have drawn the middle branch, there is only one way to complete the graph (because of our observations about the behavior of $w$ around its vertical asymptotes), which we have done in \cref{rat:fig:sketchtwoasymptp2}. \end{steps} \end{pccsolution} \end{pccexample} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -4921,12 +4921,12 @@ \end{subfigure}% \caption{$y=\dfrac{2(x+3)(x-5)}{(x+5)(x-4)}$} \end{figure} - + The rational functions that we have considered so far have had simple factors in the denominator; each function has behaved like $\frac{1}{x}$ around each of its vertical asymptotes. \Cref{rat:ex:2asympnozeros,rat:ex:2squaredasymp} consider functions that have a repeated factor in the denominator. - + %=================================== % Author: Hughes % Date: May 2012 @@ -4949,17 +4949,17 @@ denominator of $f$ is $2$. $f$ has a horizontal asymptote with equation $y=0$. \item We put the details we have obtained so far on \cref{rat:fig:2asympnozerosp1}. - + The function $f$ is similar to the function $w$ that we considered in \cref{rat:ex:sketchtwoasymp}| it has two vertical asymptotes and $3$ branches, but in contrast to $w$ it does not have any zeros. - + We sketch $f$ in \cref{rat:fig:2asympnozerosp2}, using the middle branch as our guide because we have the most information about the function on the interval $(-5,4)$. - + Once we have drawn the middle branch, there is only one way to complete the graph because of our observations about the behavior of $f$ around its vertical asymptotes (it behaves like $\frac{1}{x}$), which we have done in \cref{rat:fig:2asympnozerosp2}. - + Note that we are not yet able to find the local minimum of $f$ algebraically on the interval $(-5,4)$, so we make a reasonable guess as to where it is| we can be confident that it is above the horizontal axis since $f$ has no zeros. You may think that this is unsatisfactory, but once we have the tools of calculus, we will @@ -4967,7 +4967,7 @@ \end{steps} \end{pccsolution} \end{pccexample} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -5011,7 +5011,7 @@ \end{subfigure}% \caption{$y=\dfrac{100}{(x+5)(x-4)^2}$} \end{figure} - + %=================================== % Author: Hughes % Date: May 2012 @@ -5037,19 +5037,19 @@ \cref{rat:fig:2squaredasymp1}. The function $g$ is similar to the functions we considered in \cref{rat:ex:sketchtwoasymp,rat:ex:2asympnozeros} because it has $2$ vertical asymptotes and $3$ branches. - + We sketch $g$ using the middle branch as our guide because we have the most information about $g$ on the interval $(-3,5)$. Note that there is no other way to draw this branch without introducing other zeros which $g$ does not have. - + Once we have drawn the middle branch, there is only one way to complete the graph because of our observations about the behavior of $g$ around its vertical asymptotes| it behaves like $\frac{1}{x^2}$. - + \end{steps} \end{pccsolution} \end{pccexample} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -5093,14 +5093,14 @@ \end{subfigure}% \caption{$y=\dfrac{50(2-x)}{(x+3)^2(x-5)^2}$} \end{figure} - + Each of the rational functions that we have considered so far has had either a \emph{simple} zero, or no zeros at all. Remember from our work on polynomial functions, and particularly \vref{poly:def:multzero}, that a \emph{repeated} zero corresponds to the curve of the function behaving differently at the zero when compared to how the curve behaves at a simple zero. \Cref{rat:ex:doublezero} details a function that has a non-simple zero. - + %=================================== % Author: Hughes % Date: June 2012 @@ -5127,20 +5127,20 @@ \cref{rat:fig:doublezerop1}. The function $h$ is different from the functions that we have considered in previous examples because of the multiplicity of the zero at $3$. - + We sketch $h$ using the middle branch as our guide because we have the most information about $h$ on the interval $(-4,6)$. Note that there is no other way to draw this branch without introducing other zeros which $h$ does not have| also note how the curve bounces off the horizontal axis at $3$. - + Once we have drawn the middle branch, there is only one way to complete the graph because of our observations about the behavior of $h$ around its vertical asymptotes| it behaves like $\frac{1}{x}$. - + \end{steps} \end{pccsolution} \end{pccexample} - + \begin{figure}[!htbp] \begin{subfigure}{.45\textwidth} \begin{tikzpicture} @@ -5199,7 +5199,7 @@ at $b$, and a vertical asymptote at $c$. Furthermore, these functions behave like $\frac{1}{x}$ around their vertical asymptote, and the curve of each function will have $2$ branches. - + Katie has been working with $3$ functions that have the form given in \cref{rat:eq:deducecurve}, and has followed \crefrange{rat:step:first}{rat:step:penultimate}; her results are shown in \cref{rat:fig:deducecurve}. There is just one @@ -5207,7 +5207,7 @@ Help Katie finish each graph by deducing the curve of each function. \begin{shortsolution} \Vref{rat:fig:deducecurve1} - + \begin{tikzpicture}[/pgf/declare function={f=3*(x+4)/(x+5);}] \begin{axis}[ xmin=-10,xmax=10, @@ -5222,9 +5222,9 @@ \addplot[pccplot] expression[domain=-4.76923:10,samples=50]{f}; \end{axis} \end{tikzpicture} - + \Vref{rat:fig:deducecurve2} - + \begin{tikzpicture}[/pgf/declare function={f=-3*(x-2)/(x-4);}] \begin{axis}[ xmin=-10,xmax=10, @@ -5239,9 +5239,9 @@ \addplot[pccplot] expression[domain=4.85714:10]{f}; \end{axis} \end{tikzpicture} - + \Vref{rat:fig:deducecurve4} - + \begin{tikzpicture}[/pgf/declare function={f=2*(x-6)/(x-4);}] \begin{axis}[ xmin=-10,xmax=10, @@ -5258,7 +5258,7 @@ \end{tikzpicture} \end{shortsolution} \end{problem} - + \begin{figure}[!htb] \begin{widepage} \setlength{\figurewidth}{0.3\textwidth} @@ -5316,7 +5316,7 @@ \label{rat:fig:deducecurve} \end{widepage} \end{figure} - + %=================================== % Author: Hughes % Date: June 2012 @@ -5331,13 +5331,13 @@ at $b$ and $c$, and vertical asymptotes at $d$ and $e$. Furthermore, these functions behave like $\frac{1}{x}$ around both vertical asymptotes, and the curve of the function will have $3$ branches. - + David has followed \crefrange{rat:step:first}{rat:step:penultimate} for $3$ separate functions, and drawn the results in \cref{rat:fig:deducehard}. Help David finish each graph by deducing the curve of each function. \begin{shortsolution} \Vref{rat:fig:deducehard1} - + \begin{tikzpicture}[/pgf/declare function={f=(x-6)*(x+3)/( (x-4)*(x+1));}] \begin{axis}[ xmin=-10,xmax=10, @@ -5354,9 +5354,9 @@ \addplot[pccplot] expression[domain=4.24276:10]{f}; \end{axis} \end{tikzpicture} - + \Vref{rat:fig:deducehard2} - + \begin{tikzpicture}[/pgf/declare function={f=3*(x-2)*(x+3)/( (x-6)*(x+5));}] \begin{axis}[ xmin=-10,xmax=10, @@ -5373,9 +5373,9 @@ \addplot[pccplot] expression[domain=7.34324:10]{f}; \end{axis} \end{tikzpicture} - + \Vref{rat:fig:deducehard3} - + \begin{tikzpicture}[/pgf/declare function={f=2*(x-7)*(x+3)/( (x+6)*(x-5));}] \begin{axis}[ xmin=-10,xmax=10, @@ -5392,10 +5392,10 @@ \addplot[pccplot] expression[domain=5.25586:10]{f}; \end{axis} \end{tikzpicture} - + \end{shortsolution} \end{problem} - + \begin{figure}[!htb] \begin{widepage} \setlength{\figurewidth}{0.3\textwidth} @@ -5470,7 +5470,7 @@ $y=\dfrac{4}{x+2}$ \begin{shortsolution} Vertical intercept: $(0,2)$; vertical asymptote: $x=-2$, horizontal asymptote: $y=0$. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -5494,7 +5494,7 @@ Vertical intercept:$\left( 0,\frac{1}{9} \right)$; horizontal intercept: $\left( \frac{1}{2},0 \right)$; vertical asymptotes: $x=-3$, $x=3$, horizontal asymptote: $y=0$. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -5519,7 +5519,7 @@ \begin{shortsolution} Vertical intercept $\left( 0,-\frac{3}{5} \right)$; horizontal intercept: $(-3,0)$; vertical asymptote: $x=5$; horizontal asymptote: $y=1$. - + \begin{tikzpicture} \begin{axis}[ framed, @@ -5544,7 +5544,7 @@ \begin{shortsolution} Vertical intercept: $(0,-3)$; horizontal intercept: $\left( -\frac{3}{2},0 \right)$; vertical asymptote: $x=\frac{1}{3}$, horizontal asymptote: $y=\frac{2}{3}$. - + \begin{tikzpicture}[/pgf/declare function={f=(2*x+3)/(3*x-1);}] \begin{axis}[ framed, @@ -5568,7 +5568,7 @@ Vertical intercept: $\left( 0,-\frac{4}{9} \right)$; horizontal intercepts: $(2,0)$, $(-2,0)$; vertical asymptotes: $x=-3$, $x=3$; horizontal asymptote: $y=-1$. - + \begin{tikzpicture}[/pgf/declare function={f=(4-x^2)/(x^2-9);}] \begin{axis}[ framed, @@ -5594,7 +5594,7 @@ Vertical intercept: $\left( 0,\frac{4}{5} \right)$; horizontal intercepts: $\left( -\frac{5}{4},0 \right)$, $\left( \frac{4}{3},0 \right)$; vertical asymptotes: $x=-\frac{5}{2}$, $x=5$; horizontal asymptote: $y=6$. - + \begin{tikzpicture}[/pgf/declare function={f=(4*x+5)*(3*x-4)/((2*x+5)*(x-5));}] \begin{axis}[ framed, @@ -5724,7 +5724,7 @@ R(x)= \begin{dcases} \frac{2}{x+3}, & x<-5 \\ - \frac{x-4}{x-10}, & x\geq -5 + \frac{x-4}{x-10}, & x\geq -5 \end{dcases} \] Evaluate each of the following. @@ -5762,7 +5762,7 @@ \end{subproblem} \end{problem} \end{exercises} - + \section{Graphing rational functions (oblique asymptotes)}\label{rat:sec:oblique} \begin{subproblem} $y=\dfrac{x^2+1}{x-4}$ @@ -5771,7 +5771,7 @@ \item $\left( 0,-\frac{1}{4} \right)$ \item Vertical asymptote: $x=4$. \item A graph of the function is shown below - + \begin{tikzpicture}[/pgf/declare function={f=(x^2+1)/(x-4);}] \begin{axis}[ framed, @@ -5798,7 +5798,7 @@ \item $(0,0)$, $(-3,0)$ \item Vertical asymptote: $x=5$, horizontal asymptote: none. \item A graph of the function is shown below - + \begin{tikzpicture}[/pgf/declare function={f=x^3*(x+3)/(x-5);}] \begin{axis}[ framed, diff --git a/Master/texmf-dist/doc/support/latexindent/success/stylefile.tex b/Master/texmf-dist/doc/support/latexindent/success/stylefile.tex index 1fd497c1e2f..c7e3cce3730 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/stylefile.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/stylefile.tex @@ -45,89 +45,91 @@ Another tabbing mechanism]\relax \advance\CurrentLineWidth -2em \advance\CurrentLineWidth -\displayindent \advance\CurrentLineWidth -\leftskip - \fi\fi - \ifdim\CurrentLineWidth<\z@ \CurrentLineWidth\z@\fi - % Enshrine the tab-to position; #1 might reference \CurrentLineWidth - \@tempdimb=#1\relax - \message{*** Tab to \the\@tempdimb, previous width is \the\CurrentLineWidth. ***}% - % Save width for possible return use - \xdef\TabPrevPos{\the\CurrentLineWidth}% - % Build the action to perform - \protected@xdef\TTo@action{% - \vrule\@width\z@\@depth\the\prevdepth - \ifdim\CurrentLineWidth>\@tempdimb - \ifTTo@overlap\else - \protect\newline \protect\null - \fi\fi - \protect\nobreak - \protect\hskip\the\@tempdimb\relax - }% - %\message{\string\TTo@action: \meaning \TTo@action. }% - % get back to the baseline, regardless of its depth. - \vskip-\prevdepth - \prevdepth-99\p@ - \vskip\prevdepth - }}% - $$ - % Don't count the display as lines in the paragraph - \count@\prevgraf \advance\count@-4 \prevgraf\count@ - \TTo@action - %% \penalty\@m % to allow a penalized line break - \fi - \endgroup - \TTo@overlapfalse - \ignorespaces + \fi \fi - } + \ifdim\CurrentLineWidth<\z@ \CurrentLineWidth\z@\fi + % Enshrine the tab-to position; #1 might reference \CurrentLineWidth + \@tempdimb=#1\relax + \message{*** Tab to \the\@tempdimb, previous width is \the\CurrentLineWidth. ***}% + % Save width for possible return use + \xdef\TabPrevPos{\the\CurrentLineWidth}% + % Build the action to perform + \protected@xdef\TTo@action{% + \vrule\@width\z@\@depth\the\prevdepth + \ifdim\CurrentLineWidth>\@tempdimb + \ifTTo@overlap\else + \protect\newline \protect\null + \fi + \fi + \protect\nobreak + \protect\hskip\the\@tempdimb\relax + }% + %\message{\string\TTo@action: \meaning \TTo@action. }% + % get back to the baseline, regardless of its depth. + \vskip-\prevdepth + \prevdepth-99\p@ + \vskip\prevdepth + }}% + $$ + % Don't count the display as lines in the paragraph + \count@\prevgraf \advance\count@-4 \prevgraf\count@ + \TTo@action + %% \penalty\@m % to allow a penalized line break + \fi + \endgroup + \TTo@overlapfalse + \ignorespaces + \fi +} - % \tab -- to the next position - % \hskip so \tab\tab moves two positions - % Allow a (penalized but flexible) line-break right after the tab. - % - \newcommand\tab{\leavevmode\hskip2sp\tabto{\NextTabStop}% - \nobreak\hskip\z@\@plus 30\p@\penalty4000\hskip\z@\@plus-30\p@\relax} +% \tab -- to the next position +% \hskip so \tab\tab moves two positions +% Allow a (penalized but flexible) line-break right after the tab. +% +\newcommand\tab{\leavevmode\hskip2sp\tabto{\NextTabStop}% + \nobreak\hskip\z@\@plus 30\p@\penalty4000\hskip\z@\@plus-30\p@\relax} - % Expandable macro to select the next tab position from the list +% Expandable macro to select the next tab position from the list - \newcommand\NextTabStop{% - \expandafter \TTo@nexttabstop \TabStopList,\maxdimen,>% - } +\newcommand\NextTabStop{% + \expandafter \TTo@nexttabstop \TabStopList,\maxdimen,>% +} - \def\TTo@nexttabstop #1,{% - \ifdim#1<\CurrentLineWidth - \expandafter\TTo@nexttabstop - \else - \ifdim#1<0.9999\linewidth#1\else\z@\fi - \expandafter\strip@prefix - \fi - } - \def\TTo@foundtabstop#1>{} +\def\TTo@nexttabstop #1,{% + \ifdim#1<\CurrentLineWidth + \expandafter\TTo@nexttabstop + \else + \ifdim#1<0.9999\linewidth#1\else\z@\fi + \expandafter\strip@prefix + \fi +} +\def\TTo@foundtabstop#1>{} - \newcommand\TabPositions[1]{\def\TabStopList{\z@,#1}} +\newcommand\TabPositions[1]{\def\TabStopList{\z@,#1}} - \newcommand\NumTabs[1]{% - \def\TabStopList{}% - \@tempdimb\linewidth - \divide\@tempdimb by#1\relax - \advance\@tempdimb 1sp % counteract rounding-down by \divide - \CurrentLineWidth\z@ - \@whiledim\CurrentLineWidth<\linewidth\do {% - \edef\TabStopList{\TabStopList\the\CurrentLineWidth,}% - \advance\CurrentLineWidth\@tempdimb - }% - \edef\TabStopList{\TabStopList\linewidth}% - } +\newcommand\NumTabs[1]{% + \def\TabStopList{}% + \@tempdimb\linewidth + \divide\@tempdimb by#1\relax + \advance\@tempdimb 1sp % counteract rounding-down by \divide + \CurrentLineWidth\z@ + \@whiledim\CurrentLineWidth<\linewidth\do {% + \edef\TabStopList{\TabStopList\the\CurrentLineWidth,}% + \advance\CurrentLineWidth\@tempdimb + }% + \edef\TabStopList{\TabStopList\linewidth}% +} - % default setting of tab positions: - \TabPositions{\parindent,.5\linewidth} +% default setting of tab positions: +\TabPositions{\parindent,.5\linewidth} - \newif\ifTTo@overlap \TTo@overlapfalse +\newif\ifTTo@overlap \TTo@overlapfalse - \@ifundefined{predisplaydirection}{ - \let\TTo@Direction\predisplaysize - \let\predisplaydirection\@undefined - } - { - \let\TTo@Direction\predisplaydirection - } +\@ifundefined{predisplaydirection}{ + \let\TTo@Direction\predisplaysize + \let\predisplaydirection\@undefined +} +{ + \let\TTo@Direction\predisplaydirection +} diff --git a/Master/texmf-dist/doc/support/latexindent/success/table4.tex b/Master/texmf-dist/doc/support/latexindent/success/table4.tex new file mode 100644 index 00000000000..6f6e71323ce --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/table4.tex @@ -0,0 +1,22 @@ +% arara: indent: {overwrite: true, silent: on, localSettings: on} +\documentclass{article} +\usepackage{siunitx} + +\begin{document} +\begin{tabular}{% + l + S[table-format=3.0] + S[table-format=3.2] + S[table-format=2.2] + S[table-format=3.2] + S[table-format=-2.2] + S[table-format=3.2] + } + Latex & 360 & 101.77 & 10.71 & 101.86 & 64.60 & 127.20 \\ + Manufacturing & 360 & -7.33 & 12.59 & -7.24 & -49.00 & 22.00 \\ + Cons & 360 & -17.19 & 23.4 & -17.22 & -79.00 & 43.00 \\ + Apple and Orange & 360 & 3.38 & 13.84 & 3.60 & -47.00 & 29.00 \\ + Services and Harry & 104 & -4.96 & 20.8 & -4.81 & -57.00 & 30.00 \\ + Manchester & 360 & -9.29 & 8.64 & -9.26 & -35.00 & 8.00 \\ +\end{tabular} +\end{document} diff --git a/Master/texmf-dist/doc/support/latexindent/success/table5.tex b/Master/texmf-dist/doc/support/latexindent/success/table5.tex new file mode 100644 index 00000000000..e2750f40d78 --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/table5.tex @@ -0,0 +1,35 @@ +\documentclass{article} + +\begin{document} + +\begin{tabular}{M|MMMMMMMMM} + & A_1 & A_2 & A_3 & A_4 & A_5 & A_6 & A_7 & A_8 & A_9 \\\hline + A_1 & 0 & & & & & & & & \\ + A_2 & & 0 & & & & & & & \\ + A_3 & & & 0 & & & & & & \\ + A_4 & & & & 0 & & & & & \\ + A_5 & & & & & 0 & & & & \\ + A_6 & & & & & & 0 & & & \\ + A_7 & & & & & & & 0 & & \\ + A_8 & & & & & & & & 0 & \\ + A_9 & & & & & & & & & 0 \\ +\end{tabular} +\begin{tabularx}{M|MMMMMMMMM} + & A_1 & A_2 & A_3 & A_4 & A_5 & A_6 & A_7 & A_8 & A_9 \\\hline + A_1 & 0 & & & & & & & & \\ + A_2 & & 0 & & & & & & & \\ + A_3 & & & 0 & & & & & & \\ + A_4 & & & & 0 & & & & & \\ + A_5 & & & & & 0 & & & & \\ + A_6 & & & & & & 0 & & & \\ + A_7 & & & & & & & 0 & & \\ + A_8 & & & & & & & & 0 & \\ + A_9 & & & & & & & & & 0 \\ +\end{tabularx} +\begin{align*} + CCI_n & = \frac{p_n-SMA(p_n)}{0.015 \cdot \sigma(p_n)}\\ + \textrm{wobei} & n = \textrm{Perioden, i.\,d.\,R. 20};\p_n = \textrm{Typischer Preis/Kurs};\ SMA(p_n) = \textrm{SMA der typischen Preise};\\ + & \sigma(p_n) = \textrm{Standardabweichung}\\ +\end{align*} +\end{document} + diff --git a/Master/texmf-dist/doc/support/latexindent/success/testHeadings-simple.tex b/Master/texmf-dist/doc/support/latexindent/success/testHeadings-simple.tex new file mode 100644 index 00000000000..565157dcaca --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/testHeadings-simple.tex @@ -0,0 +1,56 @@ +% arara: indent: {onlyDefault: no, overwrite: true, trace: on, silent: yes, localSettings: true} +\part{part} + part text + part text + \chapter{chapter long title} + chapter text + chapter text + \section[for the toc]{section} + section text + section text + \section[for the toc]{section} + section text + section text + \subsection[for the toc]{subsection} + subsection text + subsection text + \subsection[for the toc]{subsection} + subsection text + subsection text + \section[for the toc]{section} + section text + section text + \chapter{chapter} + chapter text + chapter text +\part{part} + part text + part text + \chapter[toc]{chapter title} + chapter text + chapter text + \section[for the toc]{section} + section text + section text + \subsubsection[for the toc]{subsubsection} + subsubsection text + subsubsection text + \paragraph{paragraph} + paragraph text + paragraph text + \subparagraph{subparagraph} + subparagraph text + subparagraph text + \section[for the toc]{section} + section text + section text + \subsubsection[for the toc]{subsubsection} + subsubsection text + subsubsection text + \paragraph{paragraph} + paragraph text + paragraph text + \subparagraph{subparagraph} + subparagraph text + subparagraph text + \chapter[somethingelse]{goes here} diff --git a/Master/texmf-dist/doc/support/latexindent/success/testItems.tex b/Master/texmf-dist/doc/support/latexindent/success/testItems.tex index 32e153eb19a..fba97784548 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/testItems.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/testItems.tex @@ -70,7 +70,7 @@ regular text some other stuff % here's a comment \end{list} - + \item some text some text some text some text some text some text diff --git a/Master/texmf-dist/doc/support/latexindent/success/testcls.cls b/Master/texmf-dist/doc/support/latexindent/success/testcls.cls index 8b0d1a0e73a..d4c23660c5a 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/testcls.cls +++ b/Master/texmf-dist/doc/support/latexindent/success/testcls.cls @@ -187,12 +187,14 @@ % - Page break after % - TODO: couldn't get pdfbookmark to point to this page instead of the % first page so it was removed. +%\begin{noindent} \xpretocmd{\tableofcontents}{% \begin{singlespace}}{}{} - \xapptocmd{\tableofcontents}{% - \end{singlespace}% - \pagestyle{plain}% - \clearpage}{}{} +\xapptocmd{\tableofcontents}{% +\end{singlespace}% +\pagestyle{plain}% +\clearpage}{}{} +%\end{noindent} % - Add dot leader for chapter levels \renewcommand\cftchapdotsep{\cftdotsep} @@ -201,23 +203,23 @@ % - Adjust indentation of levels % - Capitalize title entries, if requested \if@isu@capstoc -\renewcommand\cftchappresnum{\MakeUppercase{\chaptertitlename} } -\cftsetindents{chapter}{0em}{8em} -\cftsetindents{section}{2em}{0em} -\cftsetindents{subsection}{3em}{0em} -\renewcommand{\cftchapfont}{\MakeUppercase} + \renewcommand\cftchappresnum{\MakeUppercase{\chaptertitlename} } + \cftsetindents{chapter}{0em}{8em} + \cftsetindents{section}{2em}{0em} + \cftsetindents{subsection}{3em}{0em} + \renewcommand{\cftchapfont}{\MakeUppercase} \else -\renewcommand\cftchappresnum{\chaptertitlename\ } -\cftsetindents{chapter}{0em}{6em} -\cftsetindents{section}{1em}{0em} -\cftsetindents{subsection}{2em}{0em} + \renewcommand\cftchappresnum{\chaptertitlename\ } + \cftsetindents{chapter}{0em}{6em} + \cftsetindents{section}{1em}{0em} + \cftsetindents{subsection}{2em}{0em} \fi % - Remove section/subsection numbers from ToC by capturing % see idea at http://tex.stackexchange.com/questions/71123/remove-section-number-toc-entries-with-tocloft \if@isu@tocnumbersections@\else -\renewcommand{\cftsecpresnum}{\begin{lrbox}{\@tempboxa}} -\renewcommand{\cftsecaftersnum}{\end{lrbox}} + \renewcommand{\cftsecpresnum}{\begin{lrbox}{\@tempboxa}} + \renewcommand{\cftsecaftersnum}{\end{lrbox}} \fi \if@isu@tocnumbersubsections@\else @@ -229,10 +231,12 @@ % List of Figures: % - Single space % - Page break after +%\begin{noindent} \xpretocmd{\listoffigures}{% - \begin{singlespace}}{}{} - \xapptocmd{\listoffigures}{% - \end{singlespace}\clearpage}{}{} +\begin{singlespace}}{}{} +\xapptocmd{\listoffigures}{% +\end{singlespace}\clearpage}{}{} +%\end{noindent} % - Prepend the word "Figure" to the number \renewcommand\cftfigpresnum{Figure } @@ -242,10 +246,12 @@ % List of Tables: % - Single space % - Page break after +%\begin{noindent} \xpretocmd{\listoftables}{% \begin{singlespace}}{}{} - \xapptocmd{\listoftables}{% - \end{singlespace}\clearpage}{}{} +\xapptocmd{\listoftables}{% + \end{singlespace}\clearpage}{}{} +%\end{noindent} % - Prepend the word "Table" to the number \renewcommand\cfttabpresnum{Table } @@ -279,13 +285,13 @@ % Verify that we actually got some main matter \AfterEndDocument{ \if@isu@errormissingmainmatter@ - \ifdefined\@isu@gottitle - \ClassInfo{\@isu@classname}{Full dissertation mode} - \unless\ifdefined\@isu@gotmainmatter@ - \ClassError{\@isu@classname}{Missing \protect\mainmatter\space before your first real chapter!}{Missing mainmatter} - % \ClassError{\@isu@classname}{% - % \protect\mainmatter\space not called in your document expected before your first real chapter}{% - % You need to put \protect\mainmatter\space before your first real numbered chapter, typically your introduction.} + \ifdefined\@isu@gottitle + \ClassInfo{\@isu@classname}{Full dissertation mode} + \unless\ifdefined\@isu@gotmainmatter@ + \ClassError{\@isu@classname}{Missing \protect\mainmatter\space before your first real chapter!}{Missing mainmatter} + % \ClassError{\@isu@classname}{% + % \protect\mainmatter\space not called in your document expected before your first real chapter}{% + % You need to put \protect\mainmatter\space before your first real numbered chapter, typically your introduction.} \fi \fi \fi @@ -318,13 +324,13 @@ All rights reserved.} \renewcommand{\maketitle}{ \newcommand{\@isu@gottitle}{} % Assume that \maketitle implies typesetting a full thesis, not just a chapter. \ClassInfo{\@isu@classname}{Generating title page -- assuming we are typesetting a full dissertation.} - + \begin{titlepage} \setlength{\parindent}{0pt} % Don't you dare try to indent! \vbox to \textheight{ % Full-page box to contain everything and stretch everything. \begin{center} % Center this whole page \vspace*{12pt} % Designated blank line at the top of the page. - + \begin{singlespace} % Single-space this section, we manually add spacing. \textbf{\@title}\\ % Title in bold \@isu@maketwoblanklines % "two blank lines" @@ -332,34 +338,34 @@ All rights reserved.} \@isu@maketwoblanklines % "two blank lines" \textbf{\@author} % Author in bold \end{singlespace} - + \vfill{} % let LaTeX decide what "4-6 blank lines" should be. - + \begin{\isu@space} % Normal document spacing here. A \isu@submissiontype\ submitted to the graduate faculty\\ in partial fulfillment of the requirements of the degree of\\ \MakeUppercase{\isu@degree} % Doctor of Philosophy, etc. We enforce caps so they don't have to. \end{\isu@space} - + \@isu@maketwoblanklines % "two blank lines" - + \begin{singlespace} % Committee is single-spaced, looks like really long majors would be too. \isu@majorline\\ % "Major: MAJ (CONC)" or "Co-majors: MAJ; MAJ; \medskip % Unspecified space here, looks like just "one blank line" on sample Program of Study Committee:\\ \isu@committee % Committee, user-delimited with \\ and user-annoted with ", Major Professor" or "Co-major Professor" \end{singlespace} - + \vfill{} % let LaTeX decide what "7-8 blank lines" should be. \@isu@maketwoblanklines % Suggest it's a little longer than the other vfill. - + \begin{\isu@space} % Normal document spacing here Iowa State University\\ Ames, Iowa\\ \isu@gradyear % Newline after here, if needed, is in the copyright notice macro. \isu@copyrightnotice % Copyright line optional if copyright not formally filed. \end{\isu@space} - + \end{center} } \end{titlepage} diff --git a/Master/texmf-dist/doc/support/latexindent/success/theorem.tex b/Master/texmf-dist/doc/support/latexindent/success/theorem.tex index dcf9fe05a23..6541ed31ceb 100644 --- a/Master/texmf-dist/doc/support/latexindent/success/theorem.tex +++ b/Master/texmf-dist/doc/support/latexindent/success/theorem.tex @@ -32,7 +32,7 @@ \begin{document} \section{Introduction} Lorem ipsum sed nulla id risus adipiscing vulputate. - + \begin{example} Um consumidor financiou a compra de um veículo pagando 48 parcelas de \$800,00 mensais e a taxa de juros cobrada pela concessionária foi de 1,2\% a.m.. Qual era o valor à vista do automóvel adquirido? \newline @@ -42,6 +42,6 @@ PV = 800 \times \left[ \dfrac{0,772820}{0,021274} \right] \newline PV = \$29.061,79$ \end{example} - + Lorem ipsum sed nulla id risus adipiscing vulputate. \end{document} diff --git a/Master/texmf-dist/doc/support/latexindent/success/verbatim1.tex b/Master/texmf-dist/doc/support/latexindent/success/verbatim1.tex new file mode 100644 index 00000000000..635192051f2 --- /dev/null +++ b/Master/texmf-dist/doc/support/latexindent/success/verbatim1.tex @@ -0,0 +1,21 @@ +% arara: indent: {overwrite: true, silent: on} +\documentclass{article} + +\begin{document} +\begin{verbatim}{% + l + S[table-format=3.0] + S[table-format=3.2] + S[table-format=2.2] + S[table-format=3.2] + S[table-format=-2.2] + S[table-format=3.2] + } + Latex & 360 & 101.77 & 10.71 & 101.86 & 64.60 & 127.20 \\ +Manufacturing & 360 & -7.33 & 12.59 & -7.24 & -49.00 & 22.00 \\ + Cons & 360 & -17.19 & 23.4 & -17.22 & -79.00 & 43.00 \\ + Apple and Orange & 360 & 3.38 & 13.84 & 3.60 & -47.00 & 29.00 \\ + Services and Harry & 104 & -4.96 & 20.8 & -4.81 & -57.00 & 30.00 \\ + Manchester & 360 & -9.29 & 8.64 & -9.26 & -35.00 & 8.00 \\ +\end{verbatim} +\end{document} -- cgit v1.2.3