diff options
Diffstat (limited to 'info')
-rw-r--r-- | info/latex-via-exemplos/README.md | 4 | ||||
-rw-r--r-- | info/latex-via-exemplos/changelog.txt | 4 | ||||
-rw-r--r-- | info/latex-via-exemplos/latex-via-exemplos-oneside.pdf | bin | 1099977 -> 1109432 bytes | |||
-rw-r--r-- | info/latex-via-exemplos/latex-via-exemplos.pdf | bin | 1099381 -> 1109756 bytes | |||
-rw-r--r-- | info/latex-via-exemplos/latex-via-exemplos.tex | 222 | ||||
-rw-r--r-- | info/tex-nutshell/tex-nutshell.pdf | bin | 258588 -> 256523 bytes | |||
-rw-r--r-- | info/tex-nutshell/tex-nutshell.tex | 103 |
7 files changed, 266 insertions, 67 deletions
diff --git a/info/latex-via-exemplos/README.md b/info/latex-via-exemplos/README.md index b68f5c89ed..e8c6787493 100644 --- a/info/latex-via-exemplos/README.md +++ b/info/latex-via-exemplos/README.md @@ -1,5 +1,5 @@ -LaTeX Via Exemplos -================== +LaTeX2e Via Exemplos +==================== This is the LaTeX2e course written in brazilian portuguese language. diff --git a/info/latex-via-exemplos/changelog.txt b/info/latex-via-exemplos/changelog.txt index f6e938ecda..17df358342 100644 --- a/info/latex-via-exemplos/changelog.txt +++ b/info/latex-via-exemplos/changelog.txt @@ -1,3 +1,7 @@ +version (0.5.8) (2022-05-17) + - added example of package algorithmicx + - added example of package caption + - small change on example of ABNTEX2 version (0.5.7) (2021-07-17) - Added example of packages "background". - Added example to create class file diff --git a/info/latex-via-exemplos/latex-via-exemplos-oneside.pdf b/info/latex-via-exemplos/latex-via-exemplos-oneside.pdf Binary files differindex 46657dd732..cd01732dfa 100644 --- a/info/latex-via-exemplos/latex-via-exemplos-oneside.pdf +++ b/info/latex-via-exemplos/latex-via-exemplos-oneside.pdf diff --git a/info/latex-via-exemplos/latex-via-exemplos.pdf b/info/latex-via-exemplos/latex-via-exemplos.pdf Binary files differindex faf2ad9ea2..f43f354454 100644 --- a/info/latex-via-exemplos/latex-via-exemplos.pdf +++ b/info/latex-via-exemplos/latex-via-exemplos.pdf diff --git a/info/latex-via-exemplos/latex-via-exemplos.tex b/info/latex-via-exemplos/latex-via-exemplos.tex index b6e6b744a4..cc95c29b65 100644 --- a/info/latex-via-exemplos/latex-via-exemplos.tex +++ b/info/latex-via-exemplos/latex-via-exemplos.tex @@ -1,3 +1,4 @@ + % Usar XeLaTeX ou LuaLaTeX % acento nao sobrevive no arquivo temporario de showexpl % Use diretamente do arquivo externo, ou use XeLaTeX/LuaLaTeX @@ -33,6 +34,16 @@ % \renewcommand{\@iffont@firstfont}{MS Mincho} %\makeatother +%\ifXeTeX +% \ifx \IfFontExistsTF\undefined +% \let\IfFontExistsTF\iffontexists +% \fi +%\else\ifLuaTeX + \ifx \IfFontExistsTF\undefined + \PackageError{\jobname}{fontspec is old}{Install updated fontspec package} + \fi +%\fi\fi + %\ifLuaTeX % patch on iffont @@ -90,16 +101,6 @@ % versao antiga (2016) do fontspec ainda nao tem \IfFontExistsTF % precisa atualizar o fontspec -%\ifXeTeX -% \ifx \IfFontExistsTF\undefined -% \let\IfFontExistsTF\iffontexists -% \fi -%\else\ifLuaTeX - \ifx \IfFontExistsTF\undefined - \PackageError{\jobname}{fontspec is old}{Install updated fontspec package} - \fi -%\fi\fi - \IfFontExistsTF{\jafont}{}{\PackageError{\jobname}{Fonte japonês Mincho (\jafont) não encontrada.}{Instale um dos seguintes: Noto Serif CJK JP, MS Mincho, TakaoMincho, IPAexMincho, IPAMincho, Hiragino Mincho Pro}} \IfFontExistsTF{\jagothic}{}{\PackageError{\jobname}{Fonte japonês Gothic não encontrada.}{Instale um dos seguintes: Noto Sans CJK JP, MS Gothic, TakaoGothic, IPAexGothic, IPAGothic, Hiragino Maru Gothic Pro}} @@ -184,6 +185,8 @@ \usepackage{keyval} \usepackage{showexpl} % ele carrega listings +% \usepackage{algorithmicx} +\usepackage{algpseudocode} % arquivo de estilo de algorithmicx %%% pacotes usados nos exemplos correspondentes % @@ -235,6 +238,11 @@ %% caixa colorida usada para exemplo de certificado. % \usepacakge{tcolorbox} +% Opção 'H' e criar float personalizado. +%\usepackage{float} +%\newfloat{algorithm}{tbp}{loa}[chapter] +% \floatname{algorithm}{AlgorÃtimo} + % bug no titlesec 2.10.1 remove enumeracao da secao (corrigido em 2.10.2 de 21/03/2016). % O Usuario de ubuntu 16.04 devem atualizar o titlesec % https://tex.stackexchange.com/questions/299969/titlesec-loss-of-section-numbering-with-the-new-update-2016-03-15/300259 @@ -331,6 +339,7 @@ @inbook,@incollectedbook,@incollection,@injournal,@inproceedings,% @manual,@mastersthesis,@misc,@patent,@periodical,@phdthesis,@preamble,% @proceedings,@standard,@string,@techreport,@unpublished% + % author, editor, publisher, year, url, urldate }, comment=[l][\itshape]{@comment}, sensitive=false, @@ -877,7 +886,7 @@ \providecommand{\square}{\openbox} % lmusrrache/rmustache não tem no Latin Modern Math -% unicode math redfine no comeco do documento. +% unicode math redefine no comeco do documento. % Portanto, deve redefinir no comeco do documento (não no preambulo) % usando \AtBeginDocument \DeclareSymbolFont{largesymbolsoriginal}{OMX}{cmex}{m}{n} @@ -948,10 +957,12 @@ % Terceira atualização (0.5.3): junho de 2018. % Quarta atualização (0.5.4): agosto de 2019 % Quinta atualização (0.5.6): dezembro de 2019 -\date{Versão 0.5.7, 17 de julho de 2021} +% Sexta atualização (0.5.7): julho de 2021 +\date{Versão 0.5.8, 17 de maio de 2022} + %%%%%%%%%%%%%%%%%%%%%%% -% Docuemt start here +% Documet start here \pagestyle{empty} \begin{document} @@ -959,7 +970,7 @@ \thispagestyle{empty} -Copyright \textcopyright 2018--2021 por Sadao Massago. +Copyright \textcopyright 2018--2022 por Sadao Massago. Todos os direitos reservados. Este documento é software livre; podendo ser redistribuÃdo e/ou modificado de acordo com os termos da Licença Pública da GNU como publicado pela Free Software Foundation; versão 2 da Licença, ou (se for sua opção) qualquer versão posterior. Veja \url{https://opensource.org/licenses/gpl-license}. @@ -1047,8 +1058,8 @@ Apêndice~G descreve alguns aplicativos livres interessantes que auxilia os usuà % Sorocaba, junho de 2018. % Sorocaba, agosto de 2019. % Sorocaba, dezembro de 2019. -Sorocaba, julho de 2021. - +% Sorocaba, julho de 2021. +Sorocaba, maio de 2022. \ @@ -4418,11 +4429,12 @@ Muitas vezes, um contador está vinculado no outro e quando outro for incrementa Além disso, contadores vinculados aos outros imprimem dois valores (contador do outro mais dele). Este vÃnculo pode ser criado pelo comando -\verb+\numberwithin{<contador>}{<pai>}+\index{numberwithin@\verb+\numberwithin+}. +\verb+\counterwithin{<contador>}{<pai>}+\index{counterwithin@\verb+\counterwithin+}. Quando o \verb+<pai>+ for incrementado, o \verb+<contador>+ é reinicializado. -Por exemplo, para que a enumeração da equação seja da forma \texttt{<no. do capÃtulo>.<no da equação>}, basta colocar \verb+\numberwithin{equation}{chapter}+ no \texttt{preamble} do documento. +Por exemplo, para que a enumeração da equação seja da forma \texttt{<no. do capÃtulo>.<no da equação>}, basta colocar \verb+\counterwithin{equation}{chapter}+ no \texttt{preamble} do documento. +Observando que, para \LaTeX{} versão anterior a 2018/04/01, requer o pacote \texttt{chngcntr}. -Para eliminar um vÃnculo, usa-se o comando \verb+\@removefromreset+\index{arrobaremovefromreset@\arrobasymbforindex\verb+removefromreset+}. Por exemplo, pare remover o vÃnculo do contador da equação com o contador da seção, coloque o código +Para eliminar um vÃnculo, usa-se o comando \verb+\@removefromreset+\index{arrobaremovefromreset@\arrobasymbforindex\verb+removefromreset+}. Por exemplo, para remover o vÃnculo do contador da equação com o contador da seção, coloque o código \begin{singlespacing} \begin{lstlisting} @@ -6274,6 +6286,58 @@ Veja o Exemplo~\ref{ex15:pdflscape}. % %rotating (sideways,sidewaysfigure,sidewaystable) ou lscape/pdflscape? OK +\section{Criando ambientes tipo figuras e tabelas} + +O pacote \texttt{float}\index{float} permite criar elemento flutuante do tipo figuras e tabelas. +O novo elemento flutuante é crido pelo comando \verb+\newfloat+\index{newfloat@\verb+\newfloat+}. +O código +\begin{singlespacing} +%\begin{lstlisting}[caption={ex11-06.tex, parte d},label=ex:11-06:d] +\begin{lstlisting} +\newfloat{algorithm}{tbp}{loa}%[section] +\floatname{algorithm}{AlgorÃtmo} +\end{lstlisting} +\end{singlespacing} +cria o ambiente \texttt{algorithm} que auto posiciona e aceita \verb+\caption+ dentro dele para enumerar e colocar o tÃtulo. Veja o exemplo~\ref{ex15:newfloat}. + +\begin{singlespacing} +%\begin{lstlisting}[caption={ex11-06.tex, parte d},label=ex:11-06:d] +\begin{lstlisting}[caption={ex15-newfloat.tex},label=ex15:newfloat] +\begin{algorithm} +\caption{Primeiro algorÃtimo} +AlgorÃtimo aqui. +\end{algorithm} +\end{lstlisting} +\end{singlespacing} +% +\begin{ltxlistingout} +\begin{center}AlgorÃtmo 1: Primeiro algorÃtimo\end{center} +AlgorÃtimo aqui. +\end{ltxlistingout} + +A lista do novo elemento flutuante é criado pelo comando \verb+\listof+. Para listar algorÃtmos criados acima, usa-se o comando \verb+\listof{algorithm}{Lista de algorÃtmos}+ + +Note que o elemento flutuante não pode dividir em páginas, sendo recomendado para figuras ou elementos menores. No caso do exemplo, o algorÃtimo pode ser maior, sendo recomendado dividir em páginas, como ocorre com a tabela longa. Para criar o ambiente do estilo \texttt{longtable} (tabela longa) na qual pode quebrar entre páginas, mas ficam enumeradas como os elementos flutuantes, usa-se o pacote \texttt{caption}\index{caption} que permite controlar capÃtulos dos elementos flutuantes e similares. +O código +% +\begin{singlespacing} +%\begin{lstlisting}[caption={ex11-06.tex, parte d},label=ex:11-06:d] +\begin{lstlisting} +% definindo o tipo algorÃtimo +\DeclareCaptionType{algorithmtype}[AlgorÃtimo][Lista de algorÃtimos] +% ambiente algorÃtmo configura o caption para tipo algorÃtimo +\newenvironment{algorithm}{\captionsetup{type=algorithmtype}}{} +%{\captionsetup{type=algorithmtype,justification=centering}}{} +% atalho para lista de algoritmos +\newcommand\listofalgorithms\listofalgorithmtypes +% contador subordinado a capÃtulo +\usepackage{chngcntr} % não e necessário a partir de 2018/04/01 +\counterwithin{algorithmtype}{chapter} +\end{lstlisting} +\end{singlespacing} +% +Cria o ambiente \texttt{algorithm} similar a \texttt{longtable}. + \section{Escrevendo medidas internacionais} Para escrever medidas, requer alguns cuidados tais como usar letra romana reta (por ser abreviatura da palavra), ter pequeno espaço entre valor e medida, entre outros. @@ -6390,7 +6454,7 @@ A configuração geral de formatação pode ser feito pela opção do pacote ou %\end{LTXexample} %\end{singlespacing} -\section{Enfeites e código fontes} +\section{Moldura, enumeração das linhas e marca d'água} Para enfeitar o documento, como colocar moldura nos elementos, usamos os pacotes adicionais, exceto molduras simples fornecidos pelo \verb+\fbox+\index{fbox@\verb+\fbox+}. O pacote \texttt{fancybox}\index{fancybox} oferece caixas com molduras extras tais como \verb+\shadowbox+\index{shadowbox@\verb+\shadowbox+} (com sombra), \verb+doublebox+\index{doublebox@\verb+\doublebox+} (moldura dupla) e \verb+\ovalbox+\index{ovalbox@\verb+\ovalbox+} (moldura com quinas arredondadas). @@ -6628,9 +6692,92 @@ Para limpar o fundo, usa-se o \verb+\ClearShipoutPictureBG+\index{ClearShipoutPi Os comandos do \texttt{eso-pic} tem a versão ``BG'' para atrás da página como marca d'agua e versão ``FG'' para colocar na frente da página. Por exemplo, \verb+\AddToShipoutPictureFG+\index{AddToShipoutPictureFG@\verb+\AddToShipoutPictureFG+} coloca na frente em vez de trás da página. -Para colocar código fonte de um programa, costuma usar o pacote \texttt{listings}\index{listings} que implementa o ambiente \texttt{lstlisting}\index{lstlisting} na qual formata o código de acordo com a linguagem de programação escolhida. +\section{AlgorÃtmo e código fonte} + +Para algoritmos, poderá usar o pacote \texttt{algorithmicx}\index{algorithmicx} que destaca entre pacotes com mesma finalidade, por poder configurar a forma como será exibido. Para usar, carrege o pacote \texttt{algpseudocode}\index{algpseudocode} que carregará o pacote \texttt{algoritmicx} e define estilo para pseudo código. +% +%Para que algoritmos sejam tratados como elemento flutuante, poderá criar o ambiente usando o pacote \texttt{float}\index{float}, colocando o código similar a que segue, no preambulo. +% +%\begin{singlespacing} +%\begin{lstlisting} +%\usepackage{float} +%% criando algoritmo flutuante +%\newfloat{algorithm}{tbp}{loa}[section] +%\floatname{algorithm}{AlgorÃtmmo} +%\end{lstlisting} +%\end{singlespacing} +%% +%Assim, o ambiente criado \texttt{algorithmm} ficam auto posicionadas e enumeradas. Para listar os algorÃtmmos, use o comando \verb+\listof{algorithm}{Lista de algorÃtimos}+. +%Nte que, colocar como elemento flutuante não é recomendável para código mais longo. +% +%Para código maais longo, use o pacote \texttt{caption} +%para colocar titulo e enumeração com \textt{captionof}. +% +Veja o Exemplo~\ref{ex15:alg} +%\begin{singlespacing} +\begin{ltxlisting}[caption={ex15-alg.tex},label=ex15:alg] + \begin{algorithmic}[1] % iniciar enumeração das linhas + \Procedure{DotProd}{$u,v$} \Comment{Produto interno de u e v} + \State $p\gets 0$ \Comment{Inicializa como 0} + \For{$i\gets 1,\ldots, n$} + \State $p \gets p + u_i*v_i$ + \EndFor + \State \textbf{return} $p$\Comment{retorna o valor} + \EndProcedure + \end{algorithmic} +\end{ltxlisting} +%\end{singlespacing} +% +%\begin{ltxlistingout} +% \begin{center}AlgorÃtmo 1.1: produto interno\end{center} +% \begin{algorithmic}[1] % iniciar enumeração das linhas +% \Procedure{DotProd}{$u,v$} \Comment{Produto interno de u e v} +% \State $p\gets 0$ \Comment{Inicializa como 0} +% \For{$i\gets 1,\ldots, n$} +% \State $p \gets p + u_i*v_i$ +% \EndFor +% \State \textbf{return} $p$\Comment{retorna o valor} +% \EndProcedure +% \end{algorithmic} +%\end{ltxlistingout} +% +Como o pacote usa a palavra-chave em inglês, pode querer traduzir para português. Para isso, use o comando \verb+\algrenewcommand+\index{algrenewcommand@\verb+\algrenewcommand+} para redefinir palavra-chaves no preambulo do documento. + +Por exemplo, o código +% +\begin{singlespacing} +\begin{lstlisting} +\usepackage{algpseudocode} +% traduzindo a palavras-chave +\algrenewcommand\algorithmicprocedure{\textbf{procedimento}} +\algrenewcommand\algorithmicfor{\textbf{para}} +\algrenewcommand\algorithmicdo{\textbf{faça}} +\algrenewcommand\algorithmicend{\textbf{fim}} +\end{lstlisting} +\end{singlespacing} +% +traduzirá a palavra-chaves do algoritmo anterior para português brasileiro. Ajustando o ``return'' para ``retorne'', terá a saÃda +\begin{singlespacing} +\algrenewcommand\algorithmicprocedure{\textbf{procedimento}} +\algrenewcommand\algorithmicfor{\textbf{para}} +\algrenewcommand\algorithmicdo{\textbf{faça}} +\algrenewcommand\algorithmicend{\textbf{fim}} +\begin{ltxlistingout} + \begin{algorithmic}[1] % iniciar enumeração das linhas + \Procedure{DotProd}{$u,v$} \Comment{Produto interno de u e v} + \State $p\gets 0$ \Comment{Inicializa como 0} + \For{$i\gets 1,\ldots, n$} + \State $p \gets p + u_i*v_i$ + \EndFor + \State \textbf{retorne} $p$\Comment{retorna o valor} + \EndProcedure + \end{algorithmic} +\end{ltxlistingout} +\end{singlespacing} + +O Pacote \texttt{algorithmicx} vem com mais dois estilos que são para linguagem Pascal e C, mas para colocar código fonte de um programa, costuma usar o pacote \texttt{listings}\index{listings} que implementa o ambiente \texttt{lstlisting}\index{lstlisting} na qual formata o código de acordo com a linguagem de programação escolhida. -Ele já vem com configurações para diversas idiomas, tais como \texttt{Ada}, \texttt{Algol}, \texttt{Assember}, \texttt{awk}, \texttt{bash}, \texttt{Basic}, \texttt{C\#}, \texttt{C++}, \texttt{C}, \texttt{Cobol}, \texttt{Delphi}, \texttt{Fortran}, \texttt{Gnuplot}, \texttt{HTML}, \texttt{Java}, \texttt{Lisp}, \texttt{Logo}, \texttt{Lua}, \texttt{Make}, \texttt{Mathematica}, \texttt{Matlab}, \texttt{Metapost}, \texttt{Modula-2}, \texttt{Objective C}, \texttt{Octave}, \texttt{Pascal}, \texttt{Perl}, \texttt{PHP}, \texttt{Prolog}, \texttt{Python}, \texttt{R}, \texttt{Ruby}, \texttt{SAS}, \texttt{Scilab}, \texttt{sh}, \texttt{SQL}, \texttt{TeX}, \texttt{XML}, entre vários outros. +Ele já vem com configurações para diversas idiomas, tais como \texttt{Ada}, \texttt{Algol}, \texttt{Assember}, \texttt{awk}, \texttt{bash}, \texttt{Basic}, \texttt{C\#}, \texttt{C++}, \texttt{C}, \texttt{Cobol}, \texttt{Delphi}, \texttt{Fortran}, \texttt{Gnuplot}, \texttt{HTML}, \texttt{Java}, \texttt{Lisp}, \texttt{Logo}, \texttt{Lua}, \texttt{Make}, \texttt{Mathematica}, \texttt{Matlab}, \texttt{Metapost}, \texttt{Modula-2}, \texttt{Objective C}, \texttt{Octave}, \texttt{Pascal}, \texttt{Perl}, \texttt{PHP}, \texttt{Prolog}, \texttt{Python}, \texttt{GNU R}, \texttt{Ruby}, \texttt{SAS}, \texttt{Scilab}, \texttt{sh}, \texttt{SQL}, \texttt{TeX}, \texttt{XML}, entre vários outros. Se a linguagem pretendida não estiver na lista, poderá definir novos idiomas. Para o seu uso, costuma efetuar configurações iniciais no \texttt{preamble} com o comando \verb+\lstset+\index{lstset@\verb+\lstset+} e no ambiente de \texttt{lstlisting}, efetuar mais alguns ajustes se necessário. @@ -7486,6 +7633,26 @@ Veja Exemplo~\ref{ex16:tikz:pintar}. %\end{LTXexample} %\end{singlespacing} +Para traçar grades, existe o comando \texttt{grid}\index{grid}. O Exemplo~\ref{ex16:tikz:grid} ilustra o seu uso para produzir papel milimetrado, cuja saÃda será omitida. +% +\begin{singlespacing} +\begin{lstlisting}[caption={ex16-tikz-grid.tex}, label=ex16:tikz:grid] +\begin{center} +\documentclass[a4paper]{article} +% A4: 21cmx29.7cm +\usepackage[a4paper,lmargin=0.5cm,textheight=28.05cm,textwidth=19.05cm]{geometry} +\usepackage{tikz} +\begin{document} +\begin{tikzpicture} +\draw [black!20, very thin, step=0.1cm] (0,0) grid (19,28); +\draw [black!20, step=0.5cm] (0,0) grid (19,28); +\draw [black!20, step=1.0cm, thick] (0,0) grid (19,28); +\end{tikzpicture} +\end{document} +\end{center} +\end{lstlisting} +\end{singlespacing} +% Na matriz do \texttt{tikz}, podemos desenhar sobre ele. Veja Exemplo~\ref{ex16:tikz:matriz}. @@ -8307,7 +8474,7 @@ A sua saÃda será omitida aqui. % Desabilitando ou redefinindo comandos que causa erros no bookmark do PDF \pdfstringdefDisableCommands{% \let\MakeUppercase\relax% desabilitando - \def\\{ }%quebra de linha será substituÃdo pelo espaço + % \\ e \and já é tratada adequadamente em ABNT2 } \usepackage{pdfpages} % para incluir documento PDF (ex.: folha de aprovação) \usepackage{indentfirst} % se quer que o primeiro parágrafo seja indentada @@ -8414,9 +8581,8 @@ Resumo em lÃngua estrangeira (obrigatório no ABNT). % CONTEÚDO PRINCIPAL \clearpage\thispagestyle{empty}\cleardoublepage \mainmatter % ou \textual -\phantomsection%\pdfbookmark[chapter]{Prefácio}{prefacio} -\addcontentsline{toc}{chapter}{\MakeUppercase{Prefácio}} -\chapter*{Prefácio} % % prefácio (ou apresentação) é opcional no ABNT +% Como já é conteúdo textual, capÃtulos serão enumerados. +\chapter{Prefácio} % % prefácio (ou apresentação) é opcional no ABNT Prefácio aqui. Se preferir, pode incorporar na introdução. \clearpage\thispagestyle{empty}\cleardoublepage \chapter{Introdução} @@ -11857,13 +12023,13 @@ Assim, não foi incluÃdo detalhes sobre caixas e similares. Para quem pretende criar comandos e ambientes complexos ou desenvolver pacotes, o conhecimento sobre caixas é importante. Para este assunto, recomendo a leitura de outro material tais como \cite{book:oeticker:2018} e \cite{book:wikibook:latex}. -Neste texto, foram apresentados pacotes e classes mais utilizados, mas vários pacotes e classes populares foram omitidos. +Neste texto, foram apresentados alguns dos pacotes e classes mais utilizados, mas vários pacotes e classes populares foram omitidos. Por exemplo, quem trabalha com fórmulas complexas, é recomendável que considere o uso do pacote \texttt{mathtools}\index{mathtools} que resolve algumas deficiências do pacote \texttt{amsmath}. Para criar ficha catalográfica, é interessante colocar o número total de páginas usando o pacote \texttt{lastpage}\index{lastpage}. Para inserir uma ou mais páginas diretamente no documento em vez de inserir como figuras, usa-se o pacote \texttt{pdfpages}. Quem trabalha com tabelas, pode precisar do pacote \texttt{multirow}\index{multirow} para mesclar linhas, além de vários pacotes especÃficos para tabelas omitidos neste documento. -%Para elaborar livros: koma script, memoir, tufte-latex, bookest, willowtreebook, octavo, ElegantBook (templates), ycbook, nostarch, simplivre +%Para elaborar livros: koma script, memoir, tufte-latex, bookest, willowtreebook, octavo, ElegantBook (templates), ycbook, nostarch, simplivre (multilingue), beaulivre (multilingue, colorido) Ainda existem pacotes especÃficos para xadrez, diagrama quÃmica, música, etc, além dos pacotes destinados para cada tipo de ajustes. %A lista dos pacotes interessantes são longas. diff --git a/info/tex-nutshell/tex-nutshell.pdf b/info/tex-nutshell/tex-nutshell.pdf Binary files differindex 3e3c59b2f5..b8a8da3b93 100644 --- a/info/tex-nutshell/tex-nutshell.pdf +++ b/info/tex-nutshell/tex-nutshell.pdf diff --git a/info/tex-nutshell/tex-nutshell.tex b/info/tex-nutshell/tex-nutshell.tex index 412313ca2d..18077c7bf7 100644 --- a/info/tex-nutshell/tex-nutshell.tex +++ b/info/tex-nutshell/tex-nutshell.tex @@ -1,12 +1,25 @@ \useoptex % We are using OpTeX, no LaTeX -\report \fontfam[pagella] +\report \emergencystretch=2em \hbadness=2100 \def\thed#1{\ifnum#1<10 0\fi\the#1} +\let\isAleBsaved=\_isAleB +\def\preprocessindex{% sort \_iilist with the rule: .word is before :word is before word + \def\_isAleB ##1##2{% + \edef\tmpb{\csstring ##1&\relax\csstring ##2&\relax}% + \_ea\testAleB \tmpb + } + \ifx\_iilist\empty \else \_dosorting\_iilist \fi + \let\_isAleB=\isAleBsaved +} +\def\testAleB #1#2#3\relax #4#5#6\relax{% + \ifnum `#2<`#5 \_AleBtrue \else \_AleBfalse \fi +} + \catcode`<=13 \def<#1>{{\def\_dsp { }\iindex{:#1}\iis {:#1} {$\langle\hbox{\it#1}\rangle$}}% $\def\,{\hskip1.5pt plus.3pt minus1.2pt}\,\langle\hbox{\it#1}\rangle\,$} @@ -21,7 +34,11 @@ \adef|#1;{{\Red#1}} \toksapp\everyintt{\catcode`\/=13 \catcode`\|=13} \catcode`\/=12 \catcode`\|=12 -\def\comment#1\par{{\adef\%{\%}\Green\%#1}\par} +\ifx\_partokenset\undefined + \def\comment#1\par{{\adef\%{\%}\Green\%#1}\par} +\else + \def\comment#1\_par{{\adef\%{\%}\Green\%#1}\_par} +\fi \catcode`\%=14 \toksapp\everytt{\adef\%{\comment}} @@ -134,8 +151,9 @@ There are four types of meanings of control sequences: * the control sequence can be a \ii macro {\em macro}. When it is read, it is replaced by its \ii replacement/text {\em replacement text} in the input queue. If there are more macros in the replacement text, all macros are replaced. This is called the - \ii expansion/process {\em expansion process} which ends on the level of text to be printed or - primitive commands or registers or character constants or font selectors. + \ii expansion/process {\em expansion process} which ends when only printable text, + primitive commands (listed in section~\ref[main]), + registers (section~\ref[reg]), character constants, or font selectors remain. \enditems Example. When \TeX/ reads: @@ -170,9 +188,10 @@ only \"private" control sequences (prefixed by `_`). So, a user can re-define \sec Formats, engines \TeX/ is able to start without any macros preloaded in the so-called \ii ini-TeX/state {\em ini-\TeX/ -state} (the `-ini` option on the command line must be used). It knows only Cca 300 -primitive registers and primitive commands at this state.\fnote -{Roughly speaking, if you know all these 300 primitive objects and the syntax of all +state} (the `-ini` option on the command line must be used). It already knows +only primitive registers and primitive commands at this state.\fnote +{Roughly speaking, if you know all these primitive objects (about 300 in +classical \TeX/, 700 in Lua\TeX/) and the syntax of all these primitive commands and all the built-in algorithms, then you know all about \TeX. But starting to produce ordinary documents from this primitive level without macro support is nearly impossible.} @@ -200,7 +219,7 @@ format file with the same name which is used for running \TeX. For example and reads the `document.tex`. The `tex.fmt` is the format file dumped when \ii plain~TeX/macros {\em plain \TeX/ macros}\fnote -{Plain \TeX/ macros were made by \iindex {Knuth,/Donald} Donald Knuth, the author of \TeX. It is a +{Plain \TeX/ macros were made by \iindex {Knuth,/Donald}Donald Knuth, the author of \TeX. It is a set of basic macros and settings which is used (more or less) as a subset of all other macro packages.} were read, and `latex.fmt` is the format file dumped when \ii LaTeX/macros {\em \LaTeX/ macros} were read. @@ -318,20 +337,19 @@ If you need to print these special characters you can use \ii -percent,-at,-dollar,-hash `\%`, `\&`, `\$`, `\#` or `\_`. These five control sequences are declared as \"print this character" in all typical \TeX/ formats. -Another possibility is to use a verbatim environment (it depends on the used format) +Another possibility is to use a verbatim environment (it depends on the used format). Last alternative: you can use \i csstring {\let\,=\relax`\csstring\<character>`} -in Lua\TeX/, because Lua\TeX/ disposes -with the primitive command `\csstring` which converts `\<character>` +in Lua\TeX/, because it has +the primitive command `\csstring` which converts `\<character>` to `<character>`\c{12}. The \ii active/character \"active character\c{13}" can be declared by \i catcode `\catcode`\code{`}`\<character>=13`. -Such a `<character>` behaves like a `<control sequence>`. For example, you can +Such a `<character>` behaves like a control sequence. For example, you can define it by -\i def `\def<character>{...}`. -If a `<control sequence>` is -listed in this document, the active character is meant too. -{\emergencystretch=2em\par} +\i def `\def<character>{...}` and use this `<character>` as a macro. +If the term `<control sequence>` is used in syntactical rules in this document +then it means a real control sequence or an active character. Each control sequence is built by the tokenizer starting from `\`\c0. Its name is a continuous sequence of letters\c{11} finalized by the first non-letter. @@ -341,7 +359,7 @@ Note that \OpTeX/ sets You can look to such files and you will see many such characters inside private control sequence names declared by \LaTeX/ macros. -If the first character after `\`\c0 is not letter\c{\ne11}, then the control sequence is +If the first character after `\`\c0 is non-letter (i.e.\ `<something>`\c{\ne11}), then the control sequence is finalized with only this character in its name. So called \ii one~character/control~sequence {\em one-character control sequence} is created. Other control sequences are \ii multiletter/control~sequence {\em multiletter control sequences}. @@ -458,8 +476,9 @@ The following primitive commands used in vertical mode start horizontal mode: the first character of a paragraph (most common situation) or \i indent `\indent`, \i noindent `\noindent`, \i hskip `\hskip` (and its alternatives), -\i vrule `\vrule`\fnote {The list is not fully completed, but most important commands -are mentioned here.} and the plain \TeX/ macro \i leavevmode `\leavevmode`. +\i vrule `\vrule` and the plain \TeX/ macro +\i leavevmode `\leavevmode`\fnote {The list is not exhaustive, but most important commands +are mentioned.}. When horizontal mode is opened, an indentation of \i parindent `\parindent` width is included. The exception is only if horizontal mode is started by \i noindent `\noindent`; then the paragraph has no indentation. @@ -748,7 +767,7 @@ example: Note that there are two possibilities of how to write real macro parameters when a macro is in use. The parameter is one token by default but if there is `{<something>}` then the parameter is `<something>`. The braces -here are delimiters for the real parameter (the \TeX/ group is not open/close +here are delimiters for the real parameter (no \TeX/ group is opened/closed here). The example above shows a declaration of \ii unseparated/parameter,@ {\em unseparated parameters}. The @@ -806,8 +825,8 @@ then the number of `#` must be doubled for inner declaration. Example: \def\defmacro#1#2{% \def#1##1 ##2 {##1 says: #1 ##2.}% } -\defmacro \hello {hello} % expands to \def\hello#1 #2 {#1 says: hello #2.} -\defmacro \goobye {good bye} +\defmacro \hello {hello} % expands to \def\hello#1 #2 {#1 says: hello #2.} +\defmacro \goodbye {good bye} \hello Jane Eric % expands to: Jane says: hello Eric. \goodbye Eric John % expands to: Eric says: good bye John. \endtt @@ -962,7 +981,7 @@ type of the register (i.e.\ `<number>`, `<dimen>`, `<skip>` and `<toks>`) follow `01234567`\,; * {\let\,=\relax \code{`}`<character>`} (the prefix is the reverse single quote \code{`}). It returns the code of the `<character>`. Examples: - \code{`}`A` or one-character control sequence \code{`\\A}). + \code{`}{`|A;`} or one-character control sequence \code{`}{`|\A;`}). Both examples represent the number 65. The Unicode of the character is taken here if Lua\TeX/ or \XeTeX/ is used; * \i numexpr `\numexpr<num. expression>`.\fnote @@ -1077,7 +1096,7 @@ value given by plain \TeX/ follows. by \x`\baselineskip` by default. The appropriate real glue is inserted between the lines. But if this real glue (between boxes) is less than \x`\lineskiplimit` - then only \x`\lineskip` is inserted between the boxes. + then \x`\lineskip` is inserted between the boxes instead. * \y`\topskip=10pt` is the distance between the top of the page box and the baseline of the first line. @@ -1101,7 +1120,8 @@ value given by plain \TeX/ follows. and \x`\widowpenalty` (inserted before the last line of a paragraph). Typographical rules often demand us to set these registers to 10000 (no page break is allowed here). -* \y`\looseness=0` allows us to create of a \"suboptimal" paragraph. The page-building +* \y`\looseness=0` allows us to create of a \"suboptimal" paragraph. The + paragraph building algorithm tries to build the paragraph with \x`\looseness` lines more than the optimal solution. If the {\noda\x`\tolerance`} does not have a sufficiently large value then this setting is simply ignored. It is reset to zero after each @@ -1225,6 +1245,9 @@ detail). \sec[expand] Expandable primitive commands +These commands are processed like macros, i.e.\ they expand to +another sequence of tokens. + Notes about notation are in this and the following sections. If the documented command is from the $\varepsilon$\TeX{} extension (i.e.\ implemented in pdf\TeX, \XeTeX/ @@ -1277,7 +1300,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed. Another example: a macro programmer should implement a key/value dictionary using this primitive: \begtt -\def\keyval #1 #2 {\expandafter\def\csname dict:#1\endcsnme{#2}} +\def\keyval #1 #2 {\expandafter\def\csname dict:#1\endcsname{#2}} \def\value #1 {\csname dict:#1\endcsname} \keyval Peter 21 % key=Peter, value=21, saved to the dictionary % it does \def\dict:Peter{21} @@ -1299,10 +1322,10 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed. We need not define `\csname` by `\def`; we want to define a `\dict:key`. The \x`\expandafter` helps here. - The \z`<token 2>` should be another \x`\expandafter`. We can see + The \z`<token 2>` can be another \x`\expandafter`. We can see \x`\expandafter` chains in many macro files. For example - `\expandafter A\expandafter B\expandafter CD` is processed as - \z`ABC<expanded D>`. + `\expandafter\A\expandafter\B\expandafter\C\D` is processed as + \z`\A \B \C <expanded>\D`. The `/<expandafters>.`\z`{|<text>};` syntax rule enables us to prepare \z`|<text>;` by `\expandafter`(s). For example \i detokenize `\detokenize{\macro}` expands to @@ -1377,6 +1400,10 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed. (or nothing if no `<else text>` is declared) when a branch with a given `<number>` does not exist. +* \*\i pdfstrcmp `\pdfstrcmp{<stringA>}{<stringB>}` returns $-1$ if + <stringA>$\string<$<stringB>, 0 if they are equal or 1 in other cases. + It is not implemented in \LuaTeX. + * \i noexpand `\noexpand|<token>;`. The expand processor does not expand the `<token>` if it is expanding the text in {\noda\x`\edef`, \x`\write`, \x`\message`} or similar lists. @@ -1429,7 +1456,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed. {\bf Commands used for declaration of control sequences} \par\nobreak\medskip\nobreak \begitems -* \x`\def` \x`\edef` \x`\gdef` \x`\xdef` were documented in section~\ref[def]. +* \x`\def`, \x`\edef`, \x`\gdef`, \x`\xdef` were documented in section~\ref[def]. * \x`\long` is a prefix; it can be used before `\def`, `\edef`, `\gdef`, `\xdef`. The declared macro accepts the control sequence `\par` in its parameters. @@ -1497,6 +1524,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed. processor. Typically \z`<token 1>` is a macro that needs to know the next token. \enditems +\goodbreak \noindent {\bf Commands for box manipulation} \begitems @@ -1547,7 +1575,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed. \ii box/register {\em box registers} addressed by `<box number>` and accessed via \i box `\box<box number>` or alternatives described below. The `\setbox` command saves the given `<box>` to the register addressed by - `<box-number>`. + `<box number>`. Macro programmers use only 0 to 9 \z`<box numbers>` directly. Other addresses to box registers should be allocated by @@ -2238,13 +2266,13 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed. \nonum\sec[index] Index -\iis LaTeX/macros {\LaTeX/ macros} -\iis plain~TeX/macros {plain \TeX/ macros} +\iis LaTeX/macros {\LaTeX{} macros} +\iis plain~TeX/macros {plain \TeX{} macros} \iis OpTeX {\OpTeX} \iis pdfTeX {pdf\TeX} \iis luaTeX {Lua\TeX} \iis XeTeX {\XeTeX} -\iis TeX/engines {\TeX/ engines} +\iis TeX/engines {\TeX{} engines} \iis -percent {{\code{\\\%}}} \iis -at {{\code{\\\&}}} \iis -dollar {{\code{\\\$}}} @@ -2252,14 +2280,15 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed. \iis -space {{\code{\\}{\tt\char9251}}} \iis -italiccorr {{\code{\\/}}} \iis -hyphen {{\code{\\-}}} -\iis TeXlive {\TeX/live} +\iis TeXlive {\TeX{}live} \iis baselineskiprule {\code{\\baselineskip} rule} \iis -comma {{\code{\\,}}} \iis -greater {{\code{\\>}}} \iis -column {{\code{\\;}}} \iis -exclam {{\code{\\!}}} +\iis plain~TeX {plain \TeX} -{\let\Blue=\relax \typosize[9/11] \begmulti 3 \makeindex \endmulti} +{\let\Blue=\relax \typosize[9/11] \preprocessindex \begmulti 3 \makeindex \endmulti } \normalbottom @@ -2268,7 +2297,7 @@ If it is~a~Lua\TeX/ only command then three *** are prefixed. \noindent Petr Olšák {\tt petr@olsak.net}\nl Czech Technical University in Prague\nl -Version of the text: 0.7 (\the\year-\thed\month-\thed\day) +Version of the text: 0.8 (\the\year-\thed\month-\thed\day) \break |