issue108:tutoriel2
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue108:tutoriel2 [2016/04/30 18:16] – créée auntiee | issue108:tutoriel2 [2016/05/10 14:16] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Last year, I created a member directory for the Ontario Courthouse Library Association, | + | **Last year, I created a member directory for the Ontario Courthouse Library Association, |
You may have data that is in a database or spreadsheet that you would like to extract and display in a different format. LaTeX can display fantastic looking tables if you want to do that. The more I worked on this and made Google searches on LaTeX and CSV, I found out just how versatile LaTeX can be with a CSV file. But for now, I want to create a directory from data in a spreadsheet. | You may have data that is in a database or spreadsheet that you would like to extract and display in a different format. LaTeX can display fantastic looking tables if you want to do that. The more I worked on this and made Google searches on LaTeX and CSV, I found out just how versatile LaTeX can be with a CSV file. But for now, I want to create a directory from data in a spreadsheet. | ||
- | Since my data was in a LibreOffice Calc file, I clicked on File > Save as > All Formats BOX > Text CSV (.csv). With the aid of search and replace in my text editor, I was able to eliminate all of the commas by replacing them with a space. Then, after creating a preamble in my LaTeX editor, I copied and pasted my data into a LaTeX file and proceeded to insert the LaTeX code, line by line, until my data looked like that shown above. | + | Since my data was in a LibreOffice Calc file, I clicked on File > Save as > All Formats BOX > Text CSV (.csv). With the aid of search and replace in my text editor, I was able to eliminate all of the commas by replacing them with a space. Then, after creating a preamble in my LaTeX editor, I copied and pasted my data into a LaTeX file and proceeded to insert the LaTeX code, line by line, until my data looked like that shown above**. |
- | I did not think that it would take a long time to do this, but, as it turned out, this ended up being a lot of typing, heck, it had way too many line returns. Even though the finished product was a success there had to be a faster way to do this. I was working to make the code easier to read for humans, which is good, but what if LaTeX and my computer did not need it to look that way? | + | L'an dernier, j'ai créé un répertoire des membres de l' |
+ | |||
+ | Vous pouvez avoir des données stockées dans une base de données ou un tableur, que vous voudriez extraire pour les afficher dans un format différent. LaTeX peut afficher des tables à l' | ||
+ | |||
+ | Comme mes données sont dans un fichier LibreOffice Calc, j'ai cliqué sur Fichier > Enregistrer sous > Liste déroulante Tous formats > Texte CSV (.csv). Dans l' | ||
+ | |||
+ | **I did not think that it would take a long time to do this, but, as it turned out, this ended up being a lot of typing, heck, it had way too many line returns. Even though the finished product was a success there had to be a faster way to do this. I was working to make the code easier to read for humans, which is good, but what if LaTeX and my computer did not need it to look that way? | ||
Let's go back to the spread-sheet, | Let's go back to the spread-sheet, | ||
Ligne 11: | Ligne 17: | ||
Before we go any further, do a search and replace on the entire file replacing any commas with a bar “ | ” and a space before and after it. This is to give a new separation character between city and province so that “Guelph, ON” becomes “Guelph | ON”. | Before we go any further, do a search and replace on the entire file replacing any commas with a bar “ | ” and a space before and after it. This is to give a new separation character between city and province so that “Guelph, ON” becomes “Guelph | ON”. | ||
- | Into the cells, type in the code needed for each line of text (shown below). | + | Into the cells, type in the code needed for each line of text (shown below).** |
+ | |||
+ | Je n' | ||
+ | |||
+ | Revenons au tableur et, pour les besoins de cet article, nous regarderons seulement les trois premières colonnes, avec l' | ||
+ | |||
+ | Avant d' | ||
+ | Dans les cellules, tapez le code nécessaire à chaque ligne de texte (voir ci-dessous). | ||
- | Cell A has the code to begin the boldface format command “\textbf{“, | + | **Cell A has the code to begin the boldface format command “\textbf{“, |
Save this as a .CSV file and open with a text editor and it should look like this: | Save this as a .CSV file and open with a text editor and it should look like this: | ||
Ligne 27: | Ligne 40: | ||
We end up with this: | We end up with this: | ||
+ | |||
+ | \textbf{Wellington Law Association }\\ 74 Woolwich St. \\ Guelph, ON N1H 3T9 \\** | ||
+ | |||
+ | Dans la cellule A, le code pour commencer la commande du format en caractère gras « \textbf{ » ; dans la cellule C, la parenthèse fermant la commande du code de format commencé à la cellule A, suivi d'un code de changement de ligne « \\ ». Les cellules E et G n'ont qu'un code de changement de ligne « \\ », mais elles pourraient avoir plus - je veux rester simple pour le moment. | ||
+ | |||
+ | Sauvez ceci en fichier .CSV et ouvrez-le avec un éditeur de texte ; il devrait ressembler à ceci : | ||
+ | |||
+ | \textbf{, | ||
+ | |||
+ | Faites les étapes suivantes de Rechercher et remplacer : | ||
+ | • remplacer chaque virgule par une espace, | ||
+ | • remplacer « { » par « { » de sorte que « { Wellington » ressemble à « {Wellington », | ||
+ | • remplacer le « | » par une virgule. | ||
+ | Ça marche dans gEdit, mais pas dans Geany, pour une raison indéterminée. | ||
+ | |||
+ | À la fin, nous avons ceci : | ||
\textbf{Wellington Law Association }\\ 74 Woolwich St. \\ Guelph, ON N1H 3T9 \\ | \textbf{Wellington Law Association }\\ 74 Woolwich St. \\ Guelph, ON N1H 3T9 \\ | ||
- | The advantage of entering LaTeX code this way is that you can copy and paste or paint the needed code for your file very quickly, for each column, instead of line by line like I did the first time around. You can start off by experimenting with a file made up of one row of data until you are happy with it, and then copy the code into the full data file. | + | **The advantage of entering LaTeX code this way is that you can copy and paste or paint the needed code for your file very quickly, for each column, instead of line by line like I did the first time around. You can start off by experimenting with a file made up of one row of data until you are happy with it, and then copy the code into the full data file. |
After the data is manipulated to look pretty, press Ctrl A to select all, Ctrl C to copy, and then paste it into a file that holds your preamble and then save the file as a .tex file. Then process it through your favourite LaTeX editor. To see what we can end up with, here is a page from the directory I made: | After the data is manipulated to look pretty, press Ctrl A to select all, Ctrl C to copy, and then paste it into a file that holds your preamble and then save the file as a .tex file. Then process it through your favourite LaTeX editor. To see what we can end up with, here is a page from the directory I made: | ||
Ligne 38: | Ligne 67: | ||
If the data that you have is in another program such as an e-mail client' | If the data that you have is in another program such as an e-mail client' | ||
- | Let’s highlight some of the code I used to make this directory. | + | Let’s highlight some of the code I used to make this directory.** |
- | Here are some comments on the nifty code in the preamble: | + | L' |
+ | |||
+ | Une fois que les données ont été manipulées pour un résultat agréable, appuyez sur Ctrl A pour tout sélectionner, | ||
+ | |||
+ | Vous pouvez prendre les données tabulaires et les formater comme table de plusieurs façons. Je voudrais souligner que ce processus est une façon de prendre les données d'un tableur et les afficher de façon non tabulaire. | ||
+ | |||
+ | Si les données que vous avez sont dans un autre programme, tel que le répertoire de vos contacts de messagerie, vous pouvez probablement les exporter dans un fichier CSV, puis les importer dans un tableur. | ||
+ | |||
+ | Regardons plus précisément un peu du code que j'ai utilisé pour réaliser ce répertoire : | ||
+ | |||
+ | **Here are some comments on the nifty code in the preamble: | ||
\usepackage[paperwidth=3.5in, | \usepackage[paperwidth=3.5in, | ||
Ligne 54: | Ligne 93: | ||
\makeindex | \makeindex | ||
+ | |||
This lets us index data on an index page with the \index{ } command | This lets us index data on an index page with the \index{ } command | ||
+ | And in the data itself: | ||
+ | \newpage | ||
+ | I added this to the end of every row, resulting in one record per page.** | ||
- | And in the data itself: | + | Voici quelques commentaires sur le chouette code du préambule |
- | \newpage | + | \usepackage[paperwidth=3.5in, |
+ | définit la taille de la page pour les appareils au format de poche. | ||
- | I added this to the end of every row, resulting in one record per page. | + | \setlength{\parindent}{0pt} |
+ | arrête l' | ||
- | This process turns LaTeX into a very fast and powerful tool for displaying spreadsheet data in a non-tabular way. It was one of those “A HA!!” moments when I realised that we do not always need to create a LaTeX source document that caters to the human eye, even though we create a beautiful looking document with code that looks like a dog's breakfast. | + | \usepackage{hyperref} |
+ | permet l' | ||
+ | |||
+ | \usepackage{makeidx} | ||
+ | |||
+ | \makeindex | ||
+ | |||
+ | Ceci permet d' | ||
+ | |||
+ | Et dans les données elles-mêmes : | ||
+ | |||
+ | \newpage | ||
+ | |||
+ | j'ai ajouté ceci à la fin de chaque ligne, de façon à avoir une entrée de données par page. | ||
+ | |||
+ | **This process turns LaTeX into a very fast and powerful tool for displaying spreadsheet data in a non-tabular way. It was one of those “A HA!!” moments when I realised that we do not always need to create a LaTeX source document that caters to the human eye, even though we create a beautiful looking document with code that looks like a dog's breakfast. | ||
However, after we produce a document this way, it may be advisable to keep the spreadsheet file that contains the LaTeX code as this will make it easier to edit the information at a later date. The code that we create this way does not look pretty in the LaTeX editor, but the end results look great. | However, after we produce a document this way, it may be advisable to keep the spreadsheet file that contains the LaTeX code as this will make it easier to edit the information at a later date. The code that we create this way does not look pretty in the LaTeX editor, but the end results look great. | ||
Ligne 73: | Ligne 133: | ||
Until next time, enjoy exploring LaTeX. | Until next time, enjoy exploring LaTeX. | ||
- | I've also created a YouTube video explaining this procedure: https:// | + | I've also created a YouTube video explaining this procedure: https:// |
+ | |||
+ | Cette façon de faire transforme LaTeX en un outil rapide et puissant pour afficher les données d'un tableur d'une manière non tabulaire. C' | ||
+ | |||
+ | Cependant, après avoir réalisé le document de cette façon, je ne peux que recommander de conserver le fichier de tableur contenant le code LaTeX pour faciliter l' | ||
+ | |||
+ | Quant à l' | ||
+ | |||
+ | En attendant, amusez-vous bien en explorant LaTeX. | ||
+ | |||
+ | J'ai aussi créé une vidéo YouTube expliquant la démarche |
issue108/tutoriel2.1462032989.txt.gz · Dernière modification : 2016/04/30 18:16 de auntiee