Discussion:
[Docutils-users] Unicode box drawing characters in PDF (via LaTeX)
Trent W. Buck
2008-06-22 13:31:54 UTC
Permalink
Has anyone got Unicode box art working in a reST to PDF toolchain?

Because ICBF adding diagram support to my document preparation
toolchain, I drew this network diagram as "ascii" art, which I include
in my reST source document as a literal block::

PPPoE link (to Internet)

│ Potential second PPPoE link (to Internet)
│ │
┌─┴──┴─────────┐
│Foo ├──┬──┬─── DMZ (123.4.45670/24)
└─┬──┬──┬──────┘ │ [customer DMZ servers]
│ │ │ ┌┴───────────────┐
│ │ │ │Foo │
│ │ │ └────────────────┘
│ │ │
│ │ └┬─── Test (NATted 192.168.235.0/24)
│ │ [engineer test servers]
│ │
│ └┬─── Wireless
│ [engineer laptops]

└┬──┬─── Office (NATted 192.168.155.0/24)
│ [engineer workstations]
┌┴──────────────┐
│Foo │
└───────────────┘

I used Unicode box drawing characters because they look better and are
less ambiguous (true ascii art only has + as a connector, whereas
Unicode has several "T" and corner connectors).

This renders nicely to HTML (using -o utf-8:strict), but neither
rst2latex nor rst2newlatex produce useful PDFs -- the former crashes
pdflatex, and the latter generates a PDF with "escaped" gibberish
(e.g. âŤĆ) in the literal block insted of the box art.

I tried adding \include{usc} after the inputenc line (of rst2latex's
output), but this only succeeded in generating a PDF with [U+2502]-style
escaped gibberish.

Before I spend any more time grovelling through the TeX generated by
docutils, I thought I'd ask: has anyone got Unicode box art working in a
reST to PDF toolchain? If so, how?
G. Milde
2008-06-23 07:23:50 UTC
Permalink
Post by Trent W. Buck
Before I spend any more time grovelling through the TeX generated by
docutils, I thought I'd ask: has anyone got Unicode box art working in a
reST to PDF toolchain?
Yes.
Post by Trent W. Buck
If so, how?
* generate LaTeX code with --output-encoding=utf-8:strict.

* In the latex file, edit the preamble to load "ucs" with "postscript"
option and also load the pstricks package::

\usepackage{shortvrb}
- \usepackage{ucs}
+ \usepackage[postscript]{ucs}
+ \usepackage{pstricks}
\usepackage[utf8x]{inputenc}

* Convert to PDF with `latex`, `dvips`, and `ps2pdf`.
The `rubber` building system for LaTeX documents is a help here, just run
`rubber --ps --pdf <your-box-file>.tex`

Günter
Trent W. Buck
2008-06-23 12:40:51 UTC
Permalink
Post by G. Milde
Post by Trent W. Buck
Before I spend any more time grovelling through the TeX generated by
docutils, I thought I'd ask: has anyone got Unicode box art working
in a reST to PDF toolchain?
* generate LaTeX code with --output-encoding=utf-8:strict.
Yup, already doing that.
Post by G. Milde
* In the latex file, edit the preamble to load "ucs" with "postscript"
\usepackage{shortvrb}
- \usepackage{ucs}
+ \usepackage[postscript]{ucs}
+ \usepackage{pstricks}
\usepackage[utf8x]{inputenc}
Neither rst2latex nor rst2newlatex include a ucs line, here, using
Debian's 0.4-6 package. Are you using a svn snapshot?
Post by G. Milde
* Convert to PDF with `latex`, `dvips`, and `ps2pdf`.
The `rubber` building system for LaTeX documents is a help here, just run
`rubber --ps --pdf <your-box-file>.tex`
Hmm, I'd been using rubber, but with --inplace --pdf rather than --ps
--pdf.
G. Milde
2008-06-23 13:20:45 UTC
Permalink
Post by Trent W. Buck
Post by G. Milde
Post by Trent W. Buck
Before I spend any more time grovelling through the TeX generated by
docutils, I thought I'd ask: has anyone got Unicode box art working
in a reST to PDF toolchain?
* generate LaTeX code with --output-encoding=utf-8:strict.
Yup, already doing that.
Post by G. Milde
* In the latex file, edit the preamble to load "ucs" with "postscript"
Neither rst2latex nor rst2newlatex include a ucs line, here, using
Debian's 0.4-6 package. Are you using a svn snapshot?
Yes. But, as you need to edit the generated latex anyway, you might be OK
with 0.4-6. Juas make sure to replace the line that loads package inputenc
with
Post by Trent W. Buck
Post by G. Milde
\usepackage[utf8x]{inputenc}
and also load ucs and pstricks

\usepackage[postscript]{ucs}
\usepackage{pstricks}

.
Post by Trent W. Buck
Post by G. Milde
* Convert to PDF with `latex`, `dvips`, and `ps2pdf`.
The `rubber` building system for LaTeX documents is a help here, just run
`rubber --ps --pdf <your-box-file>.tex`
Hmm, I'd been using rubber, but with --inplace --pdf rather than --ps
--pdf.
While --inplace or not will not influence the box-drawing characters, you
need the --ps --pdf as pstricks (used to draw the boxes) is incompatible
with pdflatex (see the rubber man or info pages for details).

Günter
Trent W. Buck
2008-06-25 03:04:26 UTC
Permalink
Post by G. Milde
Post by Trent W. Buck
Post by G. Milde
Post by Trent W. Buck
Before I spend any more time grovelling through the TeX generated by
docutils, I thought I'd ask: has anyone got Unicode box art working
in a reST to PDF toolchain?
* In the latex file, edit the preamble to load "ucs" with "postscript"
Neither rst2latex nor rst2newlatex include a ucs line, here, using
Debian's 0.4-6 package. Are you using a svn snapshot?
Yes. But, as you need to edit the generated latex anyway, you might be OK
with 0.4-6. Juas make sure to replace the line that loads package inputenc
with
Using rst2newlatex, works with trunk r5573 but not with Debian's 0.4-6.
I've rolled out that trunk snapshot to a couple of my boxes, which will
do for now.

Thanks for your help.

Loading...