3

I want to add many ASCIIs Art images on my document. But If I use verbatim environment, the output is ugly !

enter image description here

How to solve? (I lovely a solution with the possibility to import only my txt file with ascii image in my tex file)

ascii file

                                                           Monde de l'ordinateur
   Monde réel           Monde conceptuel          +--------------------------------------+
                                                  |                                      |
                                                  |                          .-------.   |
+--------------+        +--------------+          |+--------------+         /         \  |
|              |        |              |          ||              |        (           ) |
|    Objets    |        |   Entités    |          ||    Tables    |        |`.       ,'| |
|  Propriétés  |------->| Associations |---------->|   Schémas    |------> |    Base   | |
|   Valeurs    |        |  Attributs   |          ||  Attributs   |        |     de    | |
|              |        |              |          ||              |        |  données  | |
+--------------+        +--------------+          |+--------------+        (           ) |
                                |                 |        |                `.       ,'  |
                                |                 |        |                  `-----'    |
                                |                 +--------+---------------------+-------+
                                |                          |                     |
                                v                          v                     v
                      +------------------+          +-------------+       +-------------+
                      |   Modélisation   |          |Modélisation |       |Modélisation |
                      | conceptuelle des |          | logique des |       |physique des |
                      |     données      |          |   données   |       |   données   |
                      +------------------+          +-------------+       +-------------+

.tex

\documentclass[12pt, french, a4paper]{report}
\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{listings,fancyvrb}
\usepackage{verbatimbox}

\begin{document}

\begin{verbatim}

                                                              Monde de l'ordinateur          
    Monde réel           Monde conceptuel         +--------------------------------------+
                                                  |                                      |
                                                  |                          .-------.   |
+--------------+        +--------------+          |+--------------+         /         \  |
|              |        |              |          ||              |        (           ) |
|    Objets    |        |   Entités    |          ||    Tables    |        |`.       ,'| |
|  Propriétés  |------->| Associations |---------->|   Schémas    |------> |    Base   | |
|   Valeurs    |        |  Attributs   |          ||  Attributs   |        |     de    | |
|              |        |              |          ||              |        |  données  | |
+--------------+        +--------------+          |+--------------+        (           ) |
                                  |               |        |                `.       ,'  |
                                  |               |        |                  `-----'    |
                                  |               +--------+---------------------+-------+
                                  |                        |                     |        
                                  v                        v                     v        
                     +------------------+          +-------------+       +-------------+ 
                     |   Modélisation   |          |Modélisation |       |Modélisation | 
                     | conceptuelle des |          | logique des |       |physique des | 
                     |     données      |          |   données   |       |   données   | 
                     +------------------+          +-------------+       +-------------+ 


\end{verbatim}

\end{document}
  • 1
    Welcome to TeX.SE! Could you please add an MWE? Btw, I really think you should draw the figure yourself, using something like TikZ or PSTricks. – JouleV Mar 24 at 14:39
  • 1
    Welcome! Please, show the code, nobody here is going to retype it based on the image. – egreg Mar 24 at 14:43
  • @JouleV what's MWE? – The33Coder Mar 24 at 14:55
  • @The33Coder MWE (minimal working example) is a compilable code snippet that reproduces the problem. – JouleV Mar 24 at 14:56
  • With \usepackage[utf8]{inputenc}, I don't see any problem with your code. – JouleV Mar 24 at 14:59
3

My suggestion is to use a smaller font size:

\begin{filecontents*}{\jobname.art}
    Monde réel           Monde conceptuel         +--------------------------------------+
                                                  |                                      |
                                                  |                          .-------.   |
+--------------+        +--------------+          |+--------------+         /         \  |
|              |        |              |          ||              |        (           ) |
|    Objets    |        |   Entités    |          ||    Tables    |        |`.       ,'| |
|  Propriétés  |------->| Associations |---------->|   Schémas    |------> |    Base   | |
|   Valeurs    |        |  Attributs   |          ||  Attributs   |        |     de    | |
|              |        |              |          ||              |        |  données  | |
+--------------+        +--------------+          |+--------------+        (           ) |
                                  |               |        |                `.       ,'  |
                                  |               |        |                  `-----'    |
                                  |               +--------+---------------------+-------+
                                  |                        |                     |        
                                  v                        v                     v        
                     +------------------+          +-------------+       +-------------+ 
                     |   Modélisation   |          |Modélisation |       |Modélisation | 
                     | conceptuelle des |          | logique des |       |physique des | 
                     |     données      |          |   données   |       |   données   | 
                     +------------------+          +-------------+       +-------------+ 
\end{filecontents*}

\documentclass[12pt, french, a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}

\usepackage{fancyvrb}

\usepackage{lipsum} % for context

\begin{document}

\lipsum[3]

\begin{center}
\BVerbatimInput[fontsize=\scriptsize]{\jobname.art}
\end{center}

\lipsum[3]

\end{document}

The filecontents* environment is just to show that you can use an external file. I named it \jobname.art just not to risk clobbering my files.

enter image description here

3

mwe

You could improve these diagrams a bit using an ASCII to SVG converter and then convert it to PDF to use as a simple image. I never made it before, but with asciitosvg-grid and your sample the result is not perfect but promising. Your mileage may vary with other diagrams and maybe with other similar tools.

I changed a bit the original:

                                                      Monde de l'ordinateur
   Monde réel           Monde conceptuel          .--------------------------------------.
                                                  |                                      |
                                                  |                          .-------.   |
.--------------.        .--------------.          |.--------------.         /         \  |
|              |        |              |          ||              |        .           . |
|    Objets    |        |   Entités    |          ||    Tables    |        |` ------- ´| |
|  Propriétés  +------->| Associations +---------->|   Schémas    |------> |    Base   | |
|   Valeurs    |        |  Attributs   |          ||  Attributs   |        |     de    | |
|              |        |              |          ||              |        |  données  | |
.--------------.        .-----+--------.          |.-------+------.        .           . |
                              |                   |        |                \         /  |
                              |                   |        |                 .-------.   |
                              |                   .--------+---------------------+-------.
                              v                            |                     |
                                                           |                     v
                      .------------------.          .----- v ------.       .--------------.
                      |                  |          |              |       |              | 
                      |   Modélisation   |          | Modélisation |       | Modélisation |
                      | conceptuelle des |          |  logique des |       | physique des |
                      |     données      |          |   données    |       |   données    |
                      |                  |          |              |       |              | 
                      .------------------.          .--------------.       .--------------.

... in order to produce rounded boxes and avoid and put the three vertical arrowheads at different heights (otherwise first two are lost, it seems a converter bug). Minor pitfalls like add some arrowhead can be fixed manually editing the pdf in Inkscape with minor efforts, but the showed here is the original without any retouch.

The code of the MWE:

\documentclass[12pt, french, a4paper]{report}
\usepackage{graphicx}
\begin{document}
\fbox{\includegraphics[width=\linewidth]{foo.pdf}}
\section*{Instructions}
\begin{verbatim}

    $ asciitosvg < foo.txt > foo.svg

    $ inkscape foo.svg --export-pdf=foo.pdf

\end{verbatim}
\end{document}
  • Your approach is very interesting because I want to add svg images too – The33Coder Mar 25 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.