Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've finally managed to install Inkscape 0.48 on my Mac OS X Mountain Lion. My TeX distribution is TeX Live.

I've installed TexText 0.4.4. and I can use the extension to write simple LaTeX text (I tried using \emph{}, worked fine).

The command for writing Manchu text using this package is {\bth manju gisun} where manju gisun is the Manchu text to be typeset (entered in transcription).

However, I can't use it with the package manju which I downloaded and installed from

http://www.ctan.org/tex-archive/language/manju

I add the following preamble to TexText:

\usepackage{fontspec}
\usepackage{manju}

With this preamble (and \documentclass{article}) I am able to successfully type Manchu when I compile with XeLaTeX in my editor.

But in Tex Tex it doesn't work, and I get the following error message:

! Undefined control sequence.
l.7         {\bth
              manju gisun}
? 
! Emergency stop.
l.7         {\bth
              manju gisun}
!  ==> Fatal error occurred, no output PDF file produced!

Does this mean that the manju package is incompatible with TexText?

UPDATE

I have also tried this with the "montex" mls package, which has replaced manju. However, the result remains the same: error.

UPDATE

Here is a minimal example with mls, which works when I compile it with XeLaTeX in my editor:

\documentclass{article}
\usepackage{mls}
\begin{document}
\bithe{manju gisun} % \bithe{} is the command for entering Manchu text in mls.
\end{document}

In Tex Text in Inkscape, I omit \documentclass{article}, \begin{document}, and \end{document}, leaving only \usepackage{mls} in the preamble and \bithe{manju gisun} in the main body. This gives the above error.

UPDATE

Just to clarify what I'm ultimately seeking to do, by any means possible:

I'm trying to reconstruct this page: Da Qing quanshu

Other people seem to use Adobe Indesign for this purpose, a program I don't have access to, as in this example: enter image description here

share|improve this question
    
Can you add a complete example? –  egreg Jan 27 '13 at 22:20
    
@egreg I just added one; sorry about that. –  Mårten Jan 28 '13 at 1:36
    
@Mårten I have TeX Text v0.4.4 and the pdlatex compiler is called by default, not xelatex. In order to use the latter, changes to the file textext.py (which can be found in \Inkscape\share\extensions) would probably be necessary. Also, have you considered exporting graphics to a PDF with all the text put into a .tex file as opposed to using TeX Text? There are various advantages to the PDF+LaTeX approach. –  nnunes Jan 28 '13 at 3:10
    
@NunoNunes I should try to change the compiler to xelatex. However, I can't find the file textext.py using locate in the Mac OS terminal. I installed Inkscape through macports; is the file located somewhere else? As for the PDF+LaTeX approach, I have tried it, but it's difficult to get the Manchu text to align properly, since the output will look very different from the command \bithe{TEXT}. What I want to do is to build pages that look like this: db.tt/fwitsmQc (I don't have Adobe Indesign, which people usually use for this kind of stuff, as in: tinyurl.com/b8vy7yg) –  Mårten Jan 28 '13 at 14:49
    
@Mårten Did you follow these instructions? If yes, you should find textext.py in ~/.inkscape/extensions/ or ~/.inkscape/extensions/textext-0.4.4. I can call the xelatex compiler by modifying line 730 of textext.py, but TeX Text will complain if fontspec is loaded. –  nnunes Jan 28 '13 at 23:53
add comment

1 Answer 1

up vote 4 down vote accepted

The following answer is a possible workaround (or a poor man's thread-bound Chinese book) using the PDF+LaTeX approach to Inkscape and pdflatex. Some parts of it, if not all, can probably be adapted to xelatex.

One strategy to solve the issue of text alignment in Inkscape is to use zero-width \makebox boxes in combination with \colorbox and \raisebox commands, since the contents of LR (left-right) boxes can be arbitrarily complex [The LaTeX Companion, p. 860].

preamble

The new declarations you need depend on the problem at hand. Although I'm unfamiliar with Mongolian and Manju (and what exactly are the language requirements to recreate a thread-bound Chinese book), I had a look at the montex manual and defined three new commands, \ibox, \icbox and \ipbox.

\documentclass{article}

\usepackage{calc}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}

\usepackage[latin1]{mls}

%% LR-box and paragraph box commands to lay text in Inkscape
%%
%% LR-box: #1 = (optional) value of \fboxsep
%%         #2 = horizontal alignment relative to anchor, [c], [s], [l], [r]
%%         #3 = text
\newcommand{\ibox}[3][0mm]{{\setlength{\fboxsep}{#1}%
\makebox[0pt][#2]{\raisebox{-1.0\height}[0pt]{\colorbox{White}{#3}}}}}
\newcommand{\icbox}[3][0mm]{{\setlength{\fboxsep}{#1}%
\makebox[0pt][#2]{\raisebox{0.5\width}[0pt]{\colorbox{White}{#3}}}}}
%%
%% paragraph box: #1 = (optional) value of \fboxsep
%%                #2 = horizontal alignment relative to anchor, [c], [s], [l], [r]
%%                #3 = height above anchor as a fraction of box height
%%                #4 = text
\newcommand{\ipbox}[4][0mm]{{\setlength{\fboxsep}{#1}%
\makebox[0pt][#2]{\raisebox{#3\totalheight - 1.0\totalheight}[0pt]{\colorbox{White}{#4}}}}}

The first two commands, \ibox and \icbox, are ideally suited for the following montex commands:

\bosoo
\mbosoo
\mobosoo
\mabosoo

The first argument of both commands is optional, whilst the second argument controls horizontal text alignment relative to the object anchor (in Inkscape): [l] makes text stick out to the right; [c] centres it; [r] makes text stick out to the left. The only difference between the two commands is that \ibox lays text below the object anchor, whilst \icbox centres the text vertically relative to it.

\ipbox is better suited for vertical text boxes constructed with \mobox or \mabox. The first argument is optional, and the third argument is used to control vertical alignment of the box about the anchor,

\ipbox{...}{<value>}{...}

where <value> is a fraction of the total box height, so:

  • <value> = 0 lays text below the anchor
  • <value> = 0.5 centres text vertically
  • <value> = 1.0 lays text above the anchor

patch for Inkscape (optional)

The PDF+LaTeX option generates two files with extensions .pdf and .pdf_tex. If you have many files, re-exporting all SVG files to PDF becomes time consuming. Below you'll find a patch for Inkscape (add it to your preamble), so that when you modify one of your SVG files, running pdflatex on your main .tex file will cause Inkscape to re-export that SVG file to PDF automatically.

\usepackage{import} % provides \import and \subimport to establish
                    % input relative to a directory

%% Inkscape patch that re-exports <file>.svg to PDF+LaTeX in Inkscape
%% whenever the SVG file is updated
%% NOTE: the current patch requires that all three files (i.e., .PDF,
%%       .PDF_TEX, and .SVG) have the same name and be present in the
%%       same directory
%%
%% modified from:
%%  http://anorien.csc.warwick.ac.uk/mirrors/CTAN/info/svg-inkscape/InkscapePDFLaTeX.pdf
%%
%% \executeiffilenewer compares the modification date of SVG and PDF files
\newcommand{\executeiffilenewer}[3]{%
  \ifnum\pdfstrcmp%
    {\pdffilemoddate{#1}}%
    {\pdffilemoddate{#2}}%
    >0%
    {\immediate\write18{#3}}%
  \fi%
}
%% \includesvg is used to include graphics
%% syntax: \includesvg{<file>}, \includesvg[path/to/file/]{<file>}
\newcommand{\includesvg}[2][]{%
  \executeiffilenewer{#1#2.svg}{#1#2.pdf}%
    {inkscape -z -D --file=#1#2.svg --export-pdf=#1#2.pdf --export-latex}%
  \subimport{#1}{#2.pdf_tex}%
}

For the patch to work you'll need to (1) add Inkscape to the search path of your operating system and (2) pass the command line argument -shell-escape (or perhaps --shell-escape) to the pdflatex compiler. The latter depends on your settings: operating system and editor. You'll find instructions for Texmaker (or TeXStudio) here, and for TeXworks (on Windows) here (see step 2).

the Inkscape environment

Here's a screenshot of how I included text objects in Inkscape:

  • The red circle indicates the anchor position of that text object. The anchor position is controlled in Inkscape by the setting the type of text alignment (left, center, right). It determines the point relative to which text is to be placed by \ibox, etc..
  • Yellow, dashed lines are auxiliary lines for text alignment (saved to another layer on Inkscape). Anchor of text objects is aligned with these lines.
  • Font size on Inkscape has no effect on final result.
  • Ensure Inkscape's bounding box sits tightly around the main frame (it's ok if some text objects stick out of the frame). One way to do it: select the entire drawing except(!) for the text objects, then go to Document Properties, Resize page to content, and click on Resize page to drawing or selection.

enter image description here

Included strings (from top to bottom, left to right):

\ibox{c}{\LARGE\mabosoo{uindur}}

\ibox{c}{\small\mabosoo{uindur gegen}}

\ibox{c}{\small\mabosoo{zanabazar}}

\ibox{c}{\Large\mabosoo{ugar}}

\ibox{c}{\large\mabosoo{17..18 ugar zagun-u}}

\ipbox{c}{0.5}{\mobox{3.75cm}{%
\noindent\raggedleft
cinggis xagan-u aldan urug-un izagur surbulzidan abadai
saiin nuyan xan-u kuiu}}

File saved as cnbook.svg, and then exported to PDF with option PDF+LaTeX (saved as cnbook.pdf). You can download a copy of these files here.

inclusion of graphics in LaTeX

For including graphics without the patch, place a copy of all three Inkscape files in the same directory as your main .tex file. Then use:

\begin{document}

\large

\begin{figure}[h!]\centering
%\def\svgwidth{<desired width>} % \svgwidth is forgotten outside the figure environment
\input{cnbook.pdf_tex}
\end{figure}

\end{document}

For including graphics with the patch, replace \input by \includesvg. For example, if you place a copy of all three Inkscape files in a child folder graphics, then use

\includesvg[graphics/]{cnbook}

End result:

enter image description here


vertical display of CJK characters

The solution is to place \rotatebox inside the argument of \ibox (not the other way around). However, this command was declared with Mongolian and Manju in mind, so you may need to tweak it for other languages. For Chinese characters in the Ming typeface \ibox may look a bit odd, consider:

%% compiler: xelatex

\usepackage{graphicx}
\usepackage{rotating}
\usepackage[dvipsnames]{xcolor}

\usepackage{fontspec}
\usepackage{xeCJK}
   \setCJKmainfont[RawFeature={vertical}]{宋体}

%% same as before
\newcommand{\ibox}[3][0mm]{{\setlength{\fboxsep}{#1}%
\makebox[0pt][#2]{\raisebox{-1.0\height}[0pt]{\colorbox{Yellow}{#3}}}}}
%%
%% LR-box: #1 = (optional) value of \fboxsep
%%         #2 = horizontal position relative to anchor
%%         #3 = height above anchor as a fraction of box height
%%         #4 = text
\newcommand{\icjk}[4][0mm]{{\setlength{\fboxsep}{#1}%
\makebox[0pt][c]{\raisebox{#3\totalheight}{\rotatebox{-90}{\raisebox{#2}[0pt]{#4}}}}}}

\begin{document}

aaaM\ibox{c}{\rotatebox{-90}{latin}}%
aaaM\ibox{c}{\rotatebox{-90}{大清全書}}%
aaaM\icjk{0pt}{0}{大清全書}%
aaa

\end{document}

enter image description here

With \icjk, you can control easily the horizontal and vertical alignment of the characters:

\icjk{0pt}{0}{大清全書}\rule{1cm}{0.5pt}
\icjk{0pt}{0.5}{大清全書}\rule{1cm}{0.5pt}
\icjk{0pt}{1.0}{大清全書}

enter image description here

Inkscape screenshot next to PDF output:

\icjk{0pt}{0.5}{\Huge{}大清全書} % first column
\icjk{0pt}{0}{\LARGE{}大清全書} % second column

enter image description here

share|improve this answer
    
If you find this strategy useful, it might be easier to include montex commands inside the declarations of \ibox, \icbox and \ipbox. This way you can lay text in Inkscape in a less verbose manner. –  nnunes Jan 29 '13 at 2:28
    
This is wonderful and exactly what I need. However, I don't quite understand, so I fail to produce it. How do I "(1) add Inkscape to the search path of your operating system and (2) enable --shell-escape"? I tried to use \input instead as you suggested, while deleting the code for the patch from the preamble, but the placement of the Inkscape illustration is almost completely outside the page. Could you please give me a minimal example without the patch so that I can work that part out first, and then work in the patch when I got the simpler version working? Thank you so much! –  Mårten Jan 29 '13 at 4:28
    
@Mårten Done. You're very welcome. –  nnunes Jan 29 '13 at 14:28
    
Thank you so much! That works PERFECTLY. Fantastic. However, I hate to say that now I ran into another difficulty: getting the CJK characters to display vertically (as in the picture I'm reconstructing, posted above). I tried to choose vertical text in the box in Inkscape, use \\ after every character inside the \ibox{c}{大\\清\\全\\書}, use \setCJKmainfont[RawFeature={vertical}] for my CJK font (I use xeCJK), and put the text in a \rotatebox{-90}{\ibox{c}{大清全書}}, but none of it worked. Would you know how to do this? –  Mårten Jan 29 '13 at 16:31
    
Well, first of all I will make sure to thank you when I use these illustrations for a presentation in a Manchu studies seminar in 2 weeks, and later when I eventually publish on this. Again, thank you so much! This will help me for years to come. I've built the page: db.tt/lpA5iWxi –  Mårten Jan 30 '13 at 15:12
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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