Outils pour utilisateurs

Outils du site


issue76:c_c

à relire

Over the last couple of issues, I asked for input from the readers on commands that they find useful, and a short description of what they do. Now, I have nearly three A4 pages of commands in the Google Doc I created for this. To anyone who contributed – thank you! There were a surprising number of commands (or variations) that I hadn't ever come across before. If anyone would like recognition on the title page of the PDF, you can either email me at lswest34+cli-cookbook@gmail.com, or open an issue on the GitHub (or just fork the repository!). For the actual article this month, I will briefly explain how to set up and use LaTeX on Ubuntu, for anyone who wishes to contribute to the PDF (using LaTeX), but isn't yet comfortable with LaTeX.

Au cours des deux derniers numéros, j'ai demandé aux lecteurs de partager les commandes qu'ils trouvent utiles et une brève description de ce qu'elles font. Maintenant, j'ai presque trois pages A4 de commandes dans le document Google Doc que j'ai créé pour cela. À tous ceux qui ont contribué : merci ! Il y a un nombre surprenant de commandes (ou variantes) que je n'avais jamais rencontrées auparavant. Si vous souhaitez être désigné sur la page de titre du fichier PDF, vous pouvez m'envoyer un e-mail à lswest34+cli-cookbook@gmail.com, ou ouvrir une discussion sur GitHub (ou simplement dupliquer le référentiel). Pour l'article de ce mois-ci, j'expliquerai brièvement comment configurer et utiliser LaTeX sous Ubuntu, pour toute personne qui souhaite contribuer au PDF (à l'aide de LaTeX), mais qui n'est pas encore à l'aise avec LaTeX.

First off, the Cookbook is now located on GitHub, here: https://github.com/lswest/cli-cookbook It's a public repository, so anyone who wants to contribute needs only to fork the repository, make those changes, and then send me a pull request. I will reserve the right to veto the inclusion of any commands if they seem to me to be either unnecessary duplicates of existing commands, or else are purely malicious (by this I mean commands that will result in loss of data, without any feasible security usage). For those of you not comfortable with git (or LaTeX), and without the inclination to learn, you can suggest changes and updates using the issue tracker on the repository.

Tout d'abord, le manuel se trouve maintenant sur GitHub, ici : https://github.com/lswest/cli-cookbook

C'est un dépôt public, donc quiconque veut contribuer a seulement besoin de dupliquer le référentiel, d'apporter ses modifications et de m'envoyer alors une demande de mise en ligne. Je me réserve le droit de veto sur l'inclusion de toute commande si elle me semble être un doublon inutile de commandes existantes, ou bien est purement malveillante (j'entends par là des commandes qui se traduiraient par la perte de données, sans aucune sécurité). Pour ceux d'entre vous qui ne sont pas à l'aise avec git (ou LaTeX) et ne veulent pas apprendre, vous pouvez suggérer des modifications et des mises à jour en utilisant le gestionnaire d'anomalies du référentiel.

Installing LaTeX The basic LaTeX installation is supplied through texlive, but a full installation is supplied through texlive-full. Either can be installed with apt-get, as seen below: sudo apt-get install texlive or sudo apt-get install texlive-full«» Installing the IDE I recommend using an IDE when working with LaTeX for the first time, though you can, of course, compile .tex documents using the command-line. However, the IDE makes figuring out shortcuts and commands much easier.

Installation de LaTeX

L'installation de base de LaTeX est fournie par texlive, mais une installation complète est incluse dans texlive-full. Tous les deux peuvent être installés avec apt-get, comme indiqué ci-dessous :

sudo apt-get install texlive

ou

sudo apt-get install texlive-full

Installer l'EDI

Je recommande d'utiliser un EDI [Environnement de Développement Intégré] lorsque vous travaillez avec LaTeX pour la première fois, même si vous pouvez, bien sûr, compiler les documents .tex en utilisant la ligne de commande. Toutefois, l'EDI rend la compréhension des raccourcis et des commandes plus facile.

My preferred IDE is Texmaker, which can be found in the official repository. You can install it with sudo apt-get install texmaker If your version of Ubuntu (or your preferred distribution) doesn't offer it officially, you can find it here: http://www.xm1math.net/texmaker/download.html#linux. As with all things in Linux, there are more choices than just Texmaker, but it will be what I base my explanations on. Install extra packages I used a few extra packages to fancy up the Cookbook (with links and code formatting). The extra packages are: fancyvrb and hyperref. Everything else should be included in a typical LaTeX installation. These packages are contained in texlive-latex-recommended and texlive-latex-base. If you installed just texlive instead of the full installation, you will most likely need to install these separately.

Mon EDI préféré est Texmaker, qui se trouve dans le dépôt officiel. Vous pouvez l'installer avec :

sudo apt-get install texmaker

Si votre version d'Ubuntu (ou votre distribution préférée) ne le propose pas officiellement, vous pouvez le trouver ici : http://www.xm1math.net/texmaker/download.html#linux. Comme pour toutes choses sous Linux, il y a plus de choix que juste Texmaker, mais mes explications seront basées sur lui.

Installer des paquets supplémentaires

J'ai utilisé quelques paquets supplémentaires pour rendre le Cookbook plus sympa (avec des liens et la mise en forme du code). Les paquets supplémentaires sont : fancyvrb et hyperref. Tout le reste devrait être inclus dans une installation typique de LaTeX. Ces paquets sont contenus dans texlive-latex-recommanded et texlive-latex-base. Si vous n'avez installé que texlive au lieu de l'installation complète, vous devrez probablement les installer séparément.

Fork the GitHub repository For this you need a github account, and have git installed. On my repository, you should see a button that reads “fork”. By clicking this you create a repository on your account that's a copy of mine. The second step is to clone the fork (the repository linked to your account). To do so, you can type the following into a terminal: git clone https://github.com/username/cli-cookbook.git Replace username with your username. Alternatively, you can simply copy the HTTPS clone URL off the GitHub page (of your forked repository). This will create a folder called cli-cookbook and fill it with the files you need. Once that's done, open up the .tex file in Texmaker.

Dupliquer le dépôt sur GitHub

Pour faire cela, vous aurez besoin d'un compte github et git doit être installé. Sur mon dépôt, vous devriez voir un bouton « fork ». En cliquant sur celui-ci vous créez un dépôt sur votre compte qui est une copie du mien. La deuxième étape consiste à cloner l'embranchement (le référentiel lié à votre compte). Pour ce faire, vous pouvez taper ce qui suit dans un terminal :

git clone https://github.com/username/cli-cookbook.git

Remplacez username par votre nom d'utilisateur. Ou bien, vous pouvez simplement copier l'URL HTTPS de clone situé sur la page de GitHub (de votre branche de référentiel).

Cela créera un dossier nommé cli-cookbook et le remplira avec les fichiers dont vous avez besoin. Une fois cela fait, ouvrez le fichier .tex avec Texmaker.

Editing the file Usually when creating a file, you'll need to create the preamble (\usepackage, \documentclass, \begin{document}, etc.). However, since you're working off my file, that's all been taken care of. If you want to add a new section (say, for example, you want to add a section for photo editing commands), you would type the following: \section{Name} The Name is then the header you'd like it to have (i.e. Photo Editing). If you want to split it up into sub sections, the command is: \subsection{}, and \subsubsection{} creates, surprisingly enough, a subsection to a subsection. If you plan to refer back to this section later, you'll need to assign it a label. At the end, it could look like this: […] \section{Photo Editing} \subsection{Using Photon to create albums} \label{photon} \subsection{Organizing Albums} As seen in \hyperref[photon]{\ref*{photon}} […]

Modification du fichier

Habituellement lors de la création d'un fichier, vous devrez créer le préambule (\usepackage, \documentclass, \begin{document}, etc.). Mais comme vous travaillez à partir de mon fichier, tout cela a déjà été fait.

Si vous souhaitez ajouter une nouvelle section (disons, par exemple, que vous souhaitez ajouter une section pour les commandes d'édition de photos), vous taperez ce qui suit :

\section{Name}

Le Name sera l'en-tête que vous souhaitez qu'elle ait (ex: Retouche Photo). Si vous voulez qu'elle soit divisée en sous-sections, la commande est : \subsection{} ; \subsubsection{} crée, assez étonnamment, une sous-section de la sous-section. Si vous prévoyez de faire allusion plus tard à cette section, vous devez lui assigner une étiquette. À la fin, ça pourrait ressembler à ceci :

[…]

\section{Photo Editing}

\subsection{Using Photon to create albums}

\label{photon}

\subsection{Organizing Albums}

As seen in \hyperref[photon]{\ref*{photon}}

[…]

This will create a section called Photo Editing, and two subsections called Using Photon to create albums, and Organizing Albums. The \hyperref statement will replace that section of code with the section number of the Photon subsection (i.e. 13.1). Clicking on the link will take you to the page where that section appears. Adding code I made this step slightly more complicated than it needs to be, in order to get the best result. You need to encompass your code like so: \begin{Verbatim}[commandchars=\\\{\}] // Code goes here \end{Verbatim} The Verbatim environment won't wrap text, so you'll need to manually keep an eye on the length of the code once the PDF is compiled. If you have multiple commands after each other, I place a blank line between each step. If you stick to my formatting system, you'll also want to mark the unchanging parts of a command with a red color. Any user input I leave black. So it would look like this: \begin{Verbatim}[commandchars=\\\{\}] \codeHighlight{//unchanging code} //user input \codeHighlight{//more unchanging code} \end{Verbatim} As you can imagine, this will result in //unchanging code //user input //more unchanging code. Logically, you'll want to swap out the text for what you want to say.

Cela créera une section appelée Photo Editing et deux sous-sections appelées Using Photon to create albums (L'utilisation de Photon pour créer des albums) et Organizing Albums. L'argument \hyperref remplacera cette section du code par le numéro de section de la sous-section Photon (c'est-à-dire 13.1). Cliquer sur le lien vous amènera à la page où cette section est affichée.

L'ajout de code

J'ai fait en sorte que cette étape soit un peu plus compliquée que nécessaire, pour que le résultat soit meilleur. Vous devez entourer votre code comme ceci :

\begin{Verbatim}[commandchars=\\\{\}] // Mettez le code ici : \end{Verbatim}</

L'environnement Verbatim ne renvoie pas automatiquement le texte à la ligne suivante, ce qui veut dire que vous devez surveiller la longueur du code une fois le PDF compilé. Si vous avez de multiples commandes, l'une après l'autre, je mets une ligne vierge entre chaque étape. Si vous voulez adopter mon système de formatage, vous devez mettre en rouge les parties d'une commande qui ne changent pas. Je laisse toute entrée utilisateur en noir. Ainsi, il ressemblera à ceci :

\begin{Verbatim}[commandchars=\\\{\}] \codeHighlight{//unchanging code} //user input \codeHighlight{//more unchanging code} \end{Verbatim}

Comme vous pouvez le supposer, le résultat sera //code non modifié //entrée utilisateur //encore du code non modifié. Logiquement, vous voudrez replacer le texte par ce que vous voulez ajouter.

Compiling the PDF Once you've made your changes and are ready to compile the PDF, press the blue arrow next to “Quick Build” in the top bar of Texmaker. If you want to do it by hand, you can run this command: pdflatex cli-cookbook.tex If any errors crop up, you'll need to read the error information to find the correct section of the file and see what could be wrong. I find the most common issue is a lack/overabundance of braces. Return the changes to original repository First, open a terminal and change directory to your local copy of the repository. cd ~/cli-cookbook/

Compiler le PDF

Une fois les modifications faites et que vous voulez compiler le PDF, appuyez sur la flèche bleue à côté de « Quick Build » dans la barre du haut de Texmaker. Si vous voulez le faire à la main, vous pouvez exécuter cette commande :

pdflatex cli-cookbook.tex

Si des notifications d'erreur s'affichent, il faudra bien lire les informations sur l'erreur afin de trouver la bonne section du fichier et voir ce qui ne va pas. Je trouve que le problème le plus fréquent est le manque/la surabondance de crochets.

Le renvoi des modification au dépôt d'origine

Ouvrez un terminal et changez de répertoire pour celui votre copie locale du dépôt.

cd ~/cli-cookbook/

Now, you need to add the newly added/changed files: git add -A Then you need to commit the changes git commit -m “Update message” -a Replace the “Update message” section with a brief summary of what you added. Keep quotes around the message! git push origin master This pushes the changes back to your copy of my repository. If you rename the branches, you'll need to know what you've changed the origin and master names to. By default, this command should work.

Il faut maintenant ajouter les fichiers qui sont nouveaux/modifiés :

git add -A

Puis il faut valider les modifications :

git commit -m “Update message” -a

Remplacez la section « Update message » avec un court résumé de ce que vous avez ajouté. Avec les guillemets autour de votre message !

git push origin master

Cela renvoie les modifications vers votre copie de mon référentiel. Si vous renommez les branches, vous aurez besoin de savoir les noms de l'origine et de master que vous avez choisis. Par défaut, cette commande devrait fonctionner.

Now to actually send a pull request to the original repository: • Visit your repository on the github page. • Click “compare and review” (the green icon with two arrows forming a loop). • Choose the correct repository and branch (lswest:master and username:master, for example). • Review your changes. • Click on “Click to create a pull request for this comparison”. • Enter a title and description. • Click “Send pull request”. As of that point, the ball is now in my court and I need to review the proposed change and merge it or close it. If this article has whetted your appetite on LaTeX, let me know and I will return to this topic another time. Same with git and github – if you want more on that, let me know! Any other questions, comments or suggestions can be addressed to me at lswest34+fcm@gmail.com.

Envoyez une requête pull véritable au référentiel original :

  • Allez voir votre dépôt sur la page github.
  • Cliquez sur « compare and review » (l'icône verte avec deux flèches qui forment une boucle).
  • Sélectionnez les bons dépôt et branche (par exemple, lswest:master et username:master).
  • Relisez vos modifications.
  • Cliquez sur « Click to create a pull request for this comparison ».
  • Tapez un titre et une description.
  • Cliquez sur « Send pull request ».

À ce stade là, la balle est dans mon camp et je dois relire la modification proposée et la fusionner ou la fermer.

Si vous voulez en savoir davantage sur LaTeX grâce à cet article, faites-le moi savoir et je reviendrai à ce sujet une autre fois. Même chose pour git et github, si vous voulez plus de renseignements à leur sujet, dites-le moi ! Vous pouvez m'envoyer d'autres questions, commentaires ou suggestions à lswest34+fcm@gmail.com.

issue76/c_c.txt · Dernière modification : 2014/01/26 12:19 de andre_domenech