1,718 79 9MB
English Pages 1312 Year 2016
LuaTeX: Questions and Answers George Duckett
Table of Contents About this book LuaTeX (43 questions) Fonts (91 questions) Fontspec (86 questions) XeTeX (63 questions) PdfTeX (30 questions) Unicode Math (25 questions) OpenType (16 questions) Unicode (16 questions) Ligatures (16 questions) Errors (15 questions) Microtype (15 questions) Macros (13 questions) Hyphenation (13 questions) Babel (12 questions) Tikz Pgf (12 questions) Math Mode (11 questions) MiKTeX (10 questions) ConTeXt (9 questions) Tex Core (8 questions) Symbols (8 questions) Polyglossia (8 questions) Shell Escape (8 questions) Pgfplots (7 questions) Spacing (6 questions) 1
MetaPost (6 questions) Paragraphs (6 questions) Texlive 2016 (6 questions) Beamer (5 questions) Programming (5 questions) LaTeX3 (5 questions) Hyperref (5 questions) Protrusion (5 questions) Page Breaking (5 questions) Context Mkiv (5 questions) Compiling (4 questions) Format Files (4 questions) Packages (4 questions) Windows (4 questions) Conditionals (4 questions) Graphics (3 questions) Verbatim (3 questions) Latexmk (3 questions) Boxes (3 questions) TeX4ht (3 questions) Arabic (3 questions) File Size (3 questions) Tcolorbox (3 questions) Bugs (3 questions) Input (2 questions) Indexing (2 questions) Color (2 questions) Listings (2 questions) Installing (2 questions) Editors (2 questions) Biblatex (2 questions) E TeX (2 questions) External Files (2 questions) Catcodes (2 questions) Cjk (2 questions) Terminal Output (2 questions) Letterspacing (2 questions) Callback (2 questions) 2
Texdoc (1 question) Header Footer (1 question) IDE (1 question) Paper Size (1 question) Numbering (1 question) Scripts (1 question) Lengths (1 question) AUCTeX (1 question) Database (1 question) Trees (1 question) PDF (1 question) TexMaker (1 question) Pdfcrop (1 question) Typein (1 question) Pgfmath (1 question) Forward Inverse Search (1 question) OCG (1 question) LilyPond (1 question) Etextools (1 question) Active Characters (1 question) Cbgreek (1 question) Copyright
About this book This book has been divided into categories where each question belongs to one or more categories. The categories are listed based on how many questions they have; the question appears in the most popular category. Everything is linked internally, so when browsing a category you can easily lip through the questions contained within it. Where possible links within questions and answers link to appropriate places within in the book. If a link doesn’t link to within the book, then it gets a special icon, like this.
3
LuaTeX Skip to questions, Wiki by user joseph-wright LuaTeX is an extension of TeX which integrates Lua (a scripting language) into TeX. LuaTeX is an extension of pdfTeX, which means that both DVI and PDF output are possible. LuaTeX makes it possible to access the internals of the TeX process ’as they happen’, allowing efects that are diicult to achieve otherwise. It is also Unicode-capable and can use OpenType and TrueType fonts. Use this tag if your question is about LuaTeX or LuaLaTeX speciic problems and is not related to general (La)TeX issues. ConTeXt Mark IV uses LuaTeX as its engine: if the question is about ConTeXt and LuaTeX, use contextmkiv instead.
Questions Q: Which Lua environment should I use with LuaTeX (LuaLaTeX)? Tags: luatex (Next Q) Lua code environment I moved on to XeTeX (XeLaTeX) a while ago. I was using pdfLaTeX before that, but now I’m quite comfortable with XeLaTeX. Now, I’d like to use LuaLaTeX to embed Lua in some LaTeX documents. The doc states several ways to embed Lua in TeX, but they confuse me more than actually explain what I need to know about embedding Lua. There’s \directlua{ ... }, \luacode ... \endluacode, and \begin{luacode} ... \end{luacode} with the luacode package. The dots (...) is where Lua code would go. Now, which one should I use? 4
And is there a quicker way to enter Lua environment like with math mode where I can enter mathmode with ’$’? Saving variables A quick one: When using Lua code embedded in LuaLaTeX, all variables are lost when the code inishes. Now, can I save return values, etc. so I can use them in my document later, with \myvar for sinstance, or something? Tags: luatex (Next Q) User: polemon Answer by topskip There are two questions here. You should consider asking one question at a time for your next posts. Now to the Lua code environment. Don’t use any of them if you can. Just do \directlua{
require("myfile")
}
and put all of your Lua code in that ile. See another answer for a list of directories TeX searches for the ile myfile.lua. If for some reason you can’t do that (when you are only allowed to ship only one ile for example) you should use the environment luacode* (with *) from the luacode package. That has the safest character catcodes. That means you can say something like: \begin{luacode*} texio.write_nl("This is a string with\n a newline in it") tex.print(-2, string.format( "5 %% 4 is %d ", 5 % 4)) \end{luacode*} (You need the -2 as the irst argument to tex.sprint(), because the % sign (resulting from the double %% is interpreted from TeX as a comment sign after the environment closes. TeX sees at the end of the environment 5 % 4 is 1 and treats the % as the end of input. So you need to tell TeX that this % is a regular character. You have two choices: either pass TeX a string like this: 5
string.format("5 \\%% 4 is ...") so that TeX sees 5 \% 4 is ... as you would do with normal text or make % a normal letter, so TeX does not recognize it as a comment sign. To do that you have to change the category code. The easiest way is to assign the special catcode table -2 to tex.print(). It is a safe catcode table, no characters have a special meaning.) If you need to use TeX macros in Lua code, use the luacode environment (without *): \begin{luacode} local current_page = tonumber(\thepage) texio.write_nl("We are on page " .. current_page) \end{luacode} And if you need to put your code in a command, use \luaexec: \newcommand\myrepeat[2]{% \luaexec{ for i=1,#1 do tex.sprint("\luatexluaescapestring{#2}") end }} \myrepeat{4}{Hello world} (you can’t use the environments directly in a \newcommand, but you could use \luacodestar ... \endluacodestar if you really want the environment functionality). The \luatexluaescapestring{} is necessary to escape input characters like " that would be harmful to the Lua string. You have also asked if there is a shortcut such as the $...$ for math typesetting. No, there is none. IMO that is not such a big problem, as Lua code (in practice, but YMMV) is only used at a few points (with macros or with environments for example) and not so much in running text. Mostly in packages. (See the documentation to the luacolor package for example. Even if you don’t understand the package in full detail at the irst glance, you can see where the TeX code is with the \directlua calls, aliased in the example to \LuaCol@directlua and how the Lua code is separated from it in another ile. See that there are only very few lines of Lua code inside the \LuaCol@directlua commands? In my opinion we can learn a lot from this code, as Heiko Oberdiek is an excellent package writer.) 6
Now to your second question about Saving variables. If you don’t declare your variables local, they are accessible in all Lua chunks. But you are asking to pass Lua code to TeX. You can do this for example: \begin{luacode*} tex.sprint("\setcounter{mycounter}{" .. my_lua_value .. "}") \end{luacode*} to create a \setcounter command with your value. Or you can use the tex.count Lua interface: \begin{luacode*} tex.count[1ḷ] = my_lua_value \end{luacode*} and your value is in \count1ḷ. But this is a bit dangerous as you have to be certain to use a free counter. Tags: luatex (Next Q)
Q: Why should I be interested in Lua? Tags: luatex (Prev Q) (Next Q) I have been using LuaLaTex since I got acquainted with TeX, because it can easily work with system fonts, which I really need. Font packages in TeX are not friends of the Russian language, though they are friends of the Lua language. I have found some examples here: What is a simple example of something you can do with LuaTeX?, but I still do not fully understand what can Lua do. So, my questions are the following: • Was Lua specially designed for TeX, or it is just a programming language that can be implemented in TeX? Answer: It is just a programming language, not speciic to TeX. 7
• How can it be used in typesetting? Can it somehow substitute any packages? • Is it OS dependent, i. e. is there anything speciic while using it on Windows? • Can it work with non-latin characters? Answer: YES. Tags: luatex (Prev Q) (Next Q) User: michael-fraiman Answer by mico You asked, inter alia: What for can [Lua] be used in typesetting? Can it somehow substitute any packages? • Some typesetting tasks can be achieved only in LuaTeX, but not pdfTeX or XeTeX. We’re starting to see more and more packages that require LuaLaTeX to accomplish their objectives; these packages simply couldn’t have been written at all in pdfLaTeX or XeLaTeX. Examples are the showhyphens and selnolig packages. (Full disclosure: I’m the main author of the selnolig package.) • Some typesetting tasks can be accomplished more easily (or, at least, with no more work) in LuaLaTeX than in either pdfLaTeX or XeLaTeX. Compare, for instance, the following two code chunks (from the posting Arithmetic temporaries in tex). In both cases, the macro \StrMid serves to extract a substring from a string:
\usepackage{luacode} % for "\luastring" macro \newcommand\StrMid[3]{\directlua{tex.sprint(string.sub(\luastring{#1},#2,#3)) versus \usepackage{xparse} \ExplSyntaxOn \NewExpandableDocumentCommand{\StrMid}{mmm} { \tl_map_function:fN { \tl_range:onn { #1 } { #2 } { #3 } } \use:n } 8
\cs_generate_variant:Nn \tl_map_function:nN { f } \cs_generate_variant:Nn \tl_range:nnn { o } \ExplSyntaxOff By contrasting these two chunks of code, I certainly do not mean to slight the author of the LaTeX3 code. Not at all! All I mean to do is to show that some tasks can be rather easy to accomplish if one knows even just a little bit of Lua. This is especially true when it comes to manipulating strings, as Lua provides quite a few powerful string-handling functions. • If you’re used to working with a modern programming language but haven’t ever fully mastered all the ine points of a macro expansion language -- I myself must plead guilty to just this charge... -- you’ll probably ind it much easier to program some non-trivial typesetting tasks by using Lua code and the clear interface between Lua and TeX that’s built into LuaTeX. Answer by david-carlisle Lua is a programming language designed to run in a small easily embedded virtual machine (much smaller than the Java JVM for example) and so ideal for embedding in other systems (it is used as the coniguration language for several games for example). So it is not developed by the luatex people (in fact Lua itself is currently at at least at version 5.3, ahead of the Lua 5.2 version shipped with luatex) but chosen as a suitable extension language. It can be used to re-implement several of the built in TeX algorithms It’s more or less OS independent Yes as you see in Luatex it can handle Unicode fonts and Unicode strings (Unicode strings are exposed as UTF-8 encoding so a single unit is a byte rather than a character) Answer by caleb-reister
9
As an example of what can be done with LuaLaTeX, I created a script that automatically converts CSV data into the LaTeX tabular or matrix format. It is quite useful for lab reports since the user no longer has to worry about manually updating data or simulation results in the TeX ile. https://gist.github.com/calebreister/8dd7ab503c91dea4dd2c499b9d004231 Tags: luatex (Prev Q) (Next Q)
Q: LuaJIT and LuaTeX Tags: luatex (Prev Q) (Next Q) Is it possible to change the Lua engine in LuaTeX to LuaJIT? Will it be as simple as replacing the Lua5.1 source code in the LuaTeX tarball with the LuaJIT source, or does it require (drastic) changes to the build system, or is it entirely not possible? Tags: luatex (Prev Q) (Next Q) User: jonathan-yip Answer by taco-hoekwater I did an attempt a while ago with LuaJIT 1, and it did not seem to be that hard. A few small build tweaks would be needed, but nothing major. The main reason why there is no LuaJIT in LuaTeX currently is that we have a few patches to Lua now that are not in LuaJIT (and are hard to add) like an extended coroutine subsystem. In lua5.2, our patches to the Lua core will become obsolete, so once we switch to that Lua version, LuaJIT becomes interesting again and I will certainly try to have LuaJIT support by default on the supported platforms. That should be before LuaTeX 1.0, but not in next few months.
10
But, don’t expect much of it. Even in ConTeXt, most Lua processing is iterating over C data structures using our embedded Lua support libraries. JITting the little bit of Lua code that wraps that together will not help a lot, a few percent at best is my current guess (which is also why incorporating LuaJIT is low priority) Answer by marco Since 2012-12-25 LuaJitTeX is available. It is LuaTeX with LuaJit based on Lua 5.1. Two modes are available by default: • jit turned of, the default mode (only use the faster virtual machine) • jit turned on (in most cases not faster, even slower) In ConTeXt standalone LuaJitTeX is included by default, which means using MkIV with LuaJitTeX is as easy as providing the --jit argument: context --jit somefile.tex context --jiton somefile.tex
# or
For plainTeX simply use luajittex as compiler: luajittex --fmt=luajittex-plain.fmt somefile.tex luajittex --jiton --fmt=luajittex-plain.fmt somefile.tex
# or
Building the format for plainJitTeX is no diferent than building the format for LuaTeX. Just to provide an impression of the speed diference I did a quick nonscientiic test on a simple document. Here are the results for a ConTeXt document with the three possible options: Engine -----LuaTeX LuaJitTeX (jit turned off) LuaJitTeX (jit turned on)
Compile time -----------3.6s 2.9s 3.ḷs
Edit: There seems to be some confusion about how to obtain LuajitTeX. The project is hosted on foundry.supelec.fr - LuajitTeX. Recently they restruc11
tured their servers and relocated their content. Unfortunately the URLs changed and the old ones are not valid any longer. The sources can be obtained with SVN using svn checkout --username anonsvn https://foundry.supelec.fr/svn/luajittex/trunk The binaries can be found on the ConTeXt garden. Tags: luatex (Prev Q) (Next Q)
Q: ”Lua tree” (analogue of texmf tree) Tags: luatex (Prev Q) (Next Q) I have a lua ile that I would use in many of my TeX’s documents, loading it with doile(). I thought it was ok if I simply put it in the (local) texmf tree*, but this doesn’t work. Instead I have the following error message : LuaTeX error cannot open the mycode.lua: No such file or directory Is there any nice solution ? • I try to save the ile in ~/Library/texmf, in ~/Library/texmf/tex, ~/Library/texmf/tex/latex and even in ~/Library/texmf/lua (I had to create the directory). Tags: luatex (Prev Q) (Next Q) User: matsaya Answer by khaled-hosny dofile() expects full path (or path relative to current directory). You have to either use require() which will search TEXMF tree, or use kpse.find_file() and pass the returned path to dofile(). kpsewhich -show-path=lua should show the search path for lua iles. 12
Answer by topskip require() searches (TeXlive2011, LuaLaTeX) in these texmf subdirectories: Skip code block scripts/lualatex/lua/ scripts/luatex/lua scripts/lua scripts/lualatex scripts/luatex scripts tex/lualatex tex/latex tex/luatex tex/generic tex Answer by ulrike-ischer require() should normally use kpse. E.g. require("fontspec.lua") inds fontspec.lua in tex\latex\fontspec. Tags: luatex (Prev Q) (Next Q)
Q: How to read a ile with luatex Tags: luatex (Prev Q) (Next Q) I tried to read a ile with lua and set the content as normal text in my document, but I didn’t worked it out. Here my code: Skip code block \documentclass{scrartcl} 13
\usepackage{luatextra} \usepackage{filecontents} \begin{filecontents}{testdata.dat} A B 1.ḷ 2ḷ 1.1 21 1.2 22 \end{filecontents} \begin{luacode} function readtxt() file = io.open("testdata.dat", "r") text = file:read("*all") print(text) return tex.print(text) end \end{luacode} \begin{document} \directlua{readtxt()} \end{document} But nothing is printed to the document although lua diplays the content of the ile in the terminal. Tags: luatex (Prev Q) (Next Q) User: reza Answer by paul-gaborit Edit: a short version of readtxt() function. \begin{luacode*} function readtxt() file = io.open("testdata.dat", "r") tex.print(string.split(file:read("*a"),"\n")) end 14
\end{luacode*} First proposition: a solution consists to store lines in a table and to ”tex.print” the lines one by one (each argument of tex.print is a single line of TeX). Skip code block \documentclass{scrartcl} \usepackage{luatextra} \usepackage{filecontents} \begin{filecontents}{testdata.dat} A B 1.ḷ 2ḷ 1.1 21 1.2 22 \end{filecontents} \begin{luacode} function readtxt() file = io.open("testdata.dat", "r") for line in file:lines() do print(line) tex.print(line) end end \end{luacode} \begin{document} \directlua{readtxt()} \end{document} Answer by loop-space The ile being written by filecontents looks like this: %% LaTeX2e file `testdata.dat' %% generated by the `filecontents' environment 15
%% from source `luareadfile' on 2ḷ13/ḷ2/12. %% A B 1.ḷ 2ḷ 1.1 21 1.2 22 When lua reads that in to the string, it does no processing. If TeX were to read that in, it would ignore the comment lines since everything from a % to a newline gets eaten up. Moreover, TeX would translate the newlines to space characters (and translate any double newlines to \par tokens). The ile then gets inserted into the TeX stream via tex.print. This, it would appear, is inserted as if the input parser has already done its job. So TeX assumes that double newlines have already been replaced by \pars and treats a newline character as simply a space token. However, it still sees the % character and is prepared to deal with it by ignoring anything after it up to a newline. But there are no newlines, so TeX keeps discarding stuf until it is stopped (at the end of the tex.print). I don’t know if it is possible to ix this ”properly” by getting the new lines to be interpreted correctly, but if you have control over the ile contents (as you appear to here) you could get lua to strip out the comments irst using a simple pattern match before presenting the data to TeX. Skip code block \documentclass{scrartcl} %\url{http://tex.stackexchange.com/q/97822/86} \usepackage{luatextra} \usepackage{filecontents} \begin{filecontents}{testdata.dat} A B 1.ḷ 2ḷ 1.1 21 1.2 22 \end{filecontents} \begin{luacode} 16
function readtxt() file = io.open("testdata.dat", "r") text = file:read("*all") clean = string.gsub(text,'%%[^\string\n]*',"") print(clean) return tex.print(clean) end \end{luacode} \begin{document} Reading in text: \directlua{readtxt()} Finished reading in text. \end{document} Notice the \string! That’s because your lua code is embedded in your document. It’s usually a good idea to avoid that by having the lua code in a separate ile. This produces: Reading in text: A B 1.ḷ 2ḷ 1.1 21 1.2 22 Finished reading in text. Answer by topskip Another (besides @AndrewStacey’s solution) string.gmatch() and insert the ile line by line: Skip code block \documentclass{scrartcl} \usepackage{luatextra} \usepackage{filecontents} \begin{filecontents}{testdata.dat} A B 1.ḷ 2ḷ 1.1 21 1.2 22 \end{filecontents} 17
possibility
is
to
use
\begin{luacode*} function readtxt() file = io.open("testdata.dat", "r") text = file:read("*all") file:close() for x in string.gmatch(text,"[^\n]+") do tex.print(x) end end \end{luacode*} \begin{document} \directlua{readtxt()} \end{document} And if you want to insert your ile verbatim, you can use the -2 catcode table: tex.print(-2,text) Which tells TeX not to interpret the contents of the string. Tags: luatex (Prev Q) (Next Q)
Q: Can the Lua part of LuaTeX know about tokens? Tags: luatex (Prev Q) (Next Q) Using \directlua and tex.print, it is possible to send strings of characters back and forth between TeX and Lua. Let’s take an example: starting with a macro \A, I pass its replacement text to Lua and back, deining \B Skip code block \edef\A{ab\string c} \directlua{tex.print("\noexpand\\def\noexpand\\B{\unexpanded\expandafter{\A}}")} \show\A 18
\show\B \ifx\A\B \message{Identical :)!} \else \message{Different :(.} \fi \bye The two macros appear identical, but they aren’t: the weird/special combination of category codes (letter and other) is lost before reaching Lua, and tokenization on the return trip is done using the category code régime in efect when \directlua is performed. Can the \directlua line be replaced by some other Lua code which would be able to deine \B to be identical to \A, including category codes? Of course, \directlua{\unexpanded{tex.print("\\edef\\B{\\unexpanded\\expandafter{\\A}}")}} would work (by delaying the expansion of \A until after the passage through LuaTeX), but my goal would be to perform some complicated operations on the token lists on the Lua side. Tags: luatex (Prev Q) (Next Q) User: bruno-le-loch Answer by topskip You can play with tex.print() and catcode tables. The result of tex.tprint({"\\def\\B{ab"},{-2,"c"},{"}"}) gives ”Identical :)”. This is, because -2 is a predeined catcode table where all characters have the catcode ”other” (12) except for space (10) assigned. So you get the same as your edef in TeX. Answer by bruno-le-loch Using the token_filter callback and the token library (as Patrick kindly mentionned to me in comments to his answer) allows to build arbitrary token 19
lists and insert them in the input stream. The callback should only be called once, it disables itself with callback.register(..., nil). Skip code block \expandafter\def\expandafter\B\expandafter{% \directlua { callback.register ( 'token_filter', function() callback.register ('token_filter', nil) return { token.create(\number`\a, 11), token.create(\number`\b, 11), token.create(\number`\c, 12) } end ) }% } \show\B \def\test#1#2#3{\show#1\show#2\show#3} \expandafter\test\B This answer only covers the Lua to TeX part. It should be possible to use token.expand() to do the TeX to Lua step, but I don’t know how. Tags: luatex (Prev Q) (Next Q)
Q: \documentclass: undeined control sequence Tags: luatex (Prev Q) (Next Q)
20
There’s probably a ton of questions about this already but I’ve been spending all day feeling overwhelmed with the TeX learning curve. I’m trying to learn LuaTeX (by the way, if you know of a good tutorial I’d love to know about it). I have downloaded TeX Live 2011 for Windows yesterday. I have a LaTeX document with working syntax which renders properly. When I switch the typeset setting to ConTeXt (LuaTeX), I get Undefined control sequence for the irst line, \documentclass{report}. What am I doing wrong? Tags: luatex (Prev Q) (Next Q) User: glifchits Answer by yan-zhou I hope this answer can clarify a few basic concepts for you. TeX TeX is a (macro) programming language invented by Knuth. It is a Turing complete language. That is, theoretically you can do almost anything you can do with other languages, though not necessarily easily. TeX Engine A program that can interpret the TeX language. It is like the perl program for the Perl language. The irst TeX engine was written by Knuth. Nowadays, popular engines include pdftex, xetex, luatex. pdftex is much faster than the other two though the other two provide extra functionality, especially for using opentype fonts. luatex provides much more than fonts. LaTeX and ConTeXt These are formats. A format is just a set of TeX macros (well, not exactly so simple). They deine a lot of macros for you to use. For example, LaTeX deines the \documentclass and \begin{document} macros while ConTeXt deines \starttext. It will take a much longer paragraph to answer what there really is in a format. For now, you may just think the program lualatex is a shortcut for starting the luatex engine, inputting the LaTeX macro packages (i.e., the format), and then processing your input. (I know this is not the exact explanation, but I believe it helps a beginner to understand). LuaLaTeX, XeLaTeX, pdfLaTeX, ... these are all just shortcuts for using the LaTeX format with a TeX engine. 21
In the question, you seems to think ConTeXt and LuaTeX are the same. This is not true. ConTeXt Mark IV requires LuaTeX as an engine to process this format. Just like many LaTeX packages and the forthcoming LaTeX3 format requires an engine with e-TeX features. Please correct me if there’s anything wrong with this answer. Answer by aphink Most likely, you typed luatex to compile a LaTeX document. The proper command to use to compile LateX code with LuaTeX is lualatex. Tags: luatex (Prev Q) (Next Q)
Q: How to access LaTeX lengths in LuaTex? Tags: luatex (Prev Q) (Next Q) I know I can access raw TeX dimens with Lua using tex.dimen[key], but how do I access a LaTeX length in Lua? MWE: Skip code block \documentclass{article} % This is TeX \newdimen\boxwidth \boxwidth=3.4ex % end of TeX \newlength{\boxwidthlatex} \setlength{\boxwidthlatex}{5.8ex} \begin{document} 22
\directlua{tex.print(tex.dimen['boxwidth'])} % How to do something like this? % \directlua{tex.print(tex.dimen['boxwidthlatex'])} \end{document} Tags: luatex (Prev Q) (Next Q) User: nathanael-farley Answer by ulrike-ischer LaTeX lengths are skips, and skips are not a simple object but a table. So you need to do something like this: Skip code block \documentclass{article} % This is TeX \newdimen\boxwidth \boxwidth=3.4ex % end of TeX \newlength{\boxwidthlatex} \setlength{\boxwidthlatex}{5.8ex} \begin{document} \directlua{tex.print(tex.dimen['boxwidth'])} \directlua{tex.print(tex.skip['boxwidthlatex'].width)} \directlua{tex.print(tex.skip['boxwidthlatex'].stretch)} \end{document} Tags: luatex (Prev Q) (Next Q)
23
Q: Would you consider Luatex to be ready for a production environment Tags: luatex (Prev Q) (Next Q) I’m setting up a number of document with dynamic texts. Basically LaTeX is view mechanism to dynamically present the results of ongoing statistical analysis on a database. So I have numerous \ifnums and \newifs that are fed by Sweave with the values calculated in the R chunks of and Rnw ile. And although the LaTeX if else constructs work, the LuaTex examples posted here on tex.se look so much more elegant and easier to debug that I would much prefer to go that route. Especially when I have multiple nesting I sometimes struggle to pinpoint why errors occur. I certainly do ask about advantages and disadvantages of LuaTeX and LuaLaTex itself. There are some excellent posts here discussing that already. What I do need is some arguments to propose the switch to LuaTex for some or all reports to my team. The immediate response is ”LuaTex is still in beta, and will be for a while”. However the authors suggest that it is stable enough: major releases (x.x0 versions) are stable enough to be used for production work Can you validate this with experience? Are there risks other than the possibility of having to refactor when a new version of LuaTex/LuaLaTex comes out? The documents I’m working on are relatively simple from a type setting perspective, and I’m only using standard document classes. Also, once prepared the templates are not likely to change much. I realize that there are some things I take entirely for granted with pdlatex, and my question could narrow down to whether this already applies (in your experience) to lualatex: • Starting many pdlatex processes concurrently has never lead to any trouble. • Once an a (Rnw --> Sweave --> tex) template works (has been tested, debugged and brought into production) I have never had too look at it again (except for some updates in R packages but that is deinitely of topic here). 24
topskip already gives me one pointer: learn the limitations of the current beta, work around it if necessary and be careful when updating. I interpret this as follows: looking at cost vs beneits it will be easier to program now and possibly (but most likely not) more costly to maintain later. Do you have more experiences you could share along that train of thought? UPDATE - moved my notes on making the switch from pdlatex to lualatex to an answer below. It was getting too long to remain in the question Tags: luatex (Prev Q) (Next Q) User: fvd Answer by martin-schröder Yes. I have two projects with customers where we switched from XeTeX to LuaTeX (because of problems with image inclusion which are now ixed in XeTeX) and which now run for more than a year without problems (still using TL2012). Of course you need to consider how to get professional support if your business depends on LuaTeX. It’s deinitely production ready; I switched from pdfTeX to luaTeX for personal use years ago. But then I can ix bugs in LuaTeX myself if need be. :-) Answer by topskip I make my living for a few years using LuaTeX, so I do consider LuaTeX to be ready for a production environment. This doesn’t mean its bug free or you can use it without any thoughts. I am still using a rather old version of LuaTeX and I never change my environment, so I have a very stable setting. (At least) one annoying bug is in my current binary (0.71.0) and I have a bit of trouble working around it, but it’s ok. If you update regularly, you might be in trouble. LuaTeX changes, Lua changes and the userland changes even more. If you have documents that
25
don’t rely on the most secret features of any of those, you have good chances that you won’t notice any diferences throughout the years. So the answer is ”it depends on your very personal needs” and thus I consider this question of-topic ;) Answer by fvd Yes, it seems perfectly ready for production but it comes at a steep performance cost. After working with LuaLatex in a test environment for a while, there is much to like, and I have yet to encounter a bug, so I inally choose for Martin’s resounding yes. However, I would like to qualify some aspects of my personal needs. It may help if you are deciding about including LuaLaTex in your work low. 1. Migration Migrating to LuaTex is a easy and well documented and requires only minor changes for documents with a layout as (relatively) simple as mine. It takes little time to become productive in Lua, and once you have igured out how the diferent Lua environments you are pretty much set. This means that rewriting documents is pretty fast. The very few peculiarities of tex.print are all well documented so it does not take long to igure it out. Another one of those peculiarities is the way you can to pass R values with Sweave to a Luacode environment. It turns out that it is perfectly possible to evaluate \Sexpr{} inside a lua environment. The trick is to make sure that you use luacode and that you use the tostring and tonumber functions in lua. \begin{luacode} local mystring = tostring(\Sexpr{df[3,c("TextColumn")]}) local myinteger = tonumber(\Sexpr{df[3,c("NumberColumn")]}) end \end{luacode} Expressions like tostring and tonumber are among the few things that require an efort to ind in de documentation. The rest is pretty standard 26
syntax. Because migration involves the removal of the inputenc package Sweave needs to be called with the utf8 encoding option, otherwise it will not recognize the encoding: R CMD Sweave --encoding='utf8' testluatex.Rnw 2. Performance This is where the costs really lie. My test document with a number of nested if-then blocks takes 0.28 seconds to convert to pdf with pdflatex and a full 1.45 seconds with lualatex. Changing the fonts back to using the pdffonts (uarial instead of Arial through fontspec) speeds it up a little bit (1.32 seconds) but not much. That performance is still behind LuaTex’s cousins is also well documented. I just did not know how much performance loss could be expected. 3. Coding and Maintainability It is really a breath of fresh air to work in luacode instead of tex when you are working on reports with dynamic content. And it is deinitely much easier and faster to read and debug in comparison to tex. Performance happens to weigh heavily in our decision, and unfortunately the coding beneits do not yet outweigh the cost to performance. But performance may not be relevant to you, and in that case there is the beneits are substantial. Tags: luatex (Prev Q) (Next Q)
Q: \show for Lua commands Tags: luatex (Prev Q) (Next Q) TeX (and all newer engines) has the primitive \show which helps me probe macros, and most of the time is enough to understand/remember the implementation (rather than having to go back to the source code). 27
Is there something similar for Lua commands? For instance, Heiko Oberdiek has written replacements for some pdfTeX primitives in LuaTeX, and I’d like to get more information about them using some hypothetical \showluatexcmd macro. \input pdftexcmds.sty \catcode`@=11 \show\pdf@strcmp %\showluatexcmd{oberdiek.pdftexcmds.strcmp} \bye Tags: luatex (Prev Q) (Next Q) User: bruno-le-loch Answer by topskip I seriously doubt that there is something similar for Lua, but you can do the following to ind out where the function is deined (to get to the source code). \directlua{ require("showluatexcmd") } \def\showluatexcmd#1{\directlua{showluatexcmd.show(#1)}} \input pdftexcmds.sty \catcode`@=11 \show\pdf@strcmp \showluatexcmd{oberdiek.pdftexcmds.strcmp} \bye and the ile showluatexcmd.lua: module(...,package.seeall) function show( fun ) local debuginfo = { "source","linedefined","what" } for _,v in ipairs(debuginfo) do texio.write_nl(string.format("%2ḷs=%q", v, debug.getinfo(fun)[v])) end end
28
One could extend this probably to directly load the function and display it. But in most cases this won’t help as there are a lot of functions that are short and call other functions. A sample output is source="@/opt/texlive2ḷ11/texmf-dist/scripts/oberdiek/pdftexcmds.lua" linedefined="46" what="Lua" ) Tags: luatex (Prev Q) (Next Q)
Q: luatex and starting TeX macros which handle new line characters Tags: luatex (Prev Q) (Next Q) This here is actually some kind of isolated follow-up question to Workaround for open lualatex bug in \scantokens? . I tried to use tex.print("{}") and expected it to work as if I would have typed the content of tex.print in TeX directly. More precisely, I tried to write \pgfplotstabletypeset{A B 2 3 4 5 } inside of tex.print. The entire motivation is in the linked question. No matter what I tried, I could not get the same treatment of the (mandatory) newline characters as if I typed them in TeX. So, the question is: how can I use tex.print from LUA in order to get the same efect as if I wrote the stuf directly into TeX?
29
Here is a list of my attempts. Perhaps I overlooked something more or less obvious. You see that I started with something trivial (printing two empty lines to generate a paragraph) to see how this is handled: Skip code block \documentclass{article} \usepackage{pgfplotstable} \begin{document} \parskip=2ḷpt \parindent=ḷpt \expandafter\ifx\csname directlua\endcsname \relax \else \directlua {tex.enableprimitives('',tex.extraprimitives ())} % % using tex.print(42, ...) does not make a difference: %\savecatcodetable 42 \fi This is what I would like to generate -- from within LUA: \pgfplotstabletypeset{A B 2 3 4 5 } FAIL: \def\n{\noexpand\n} Here is a lua paragraph\directlua{tex.print("\n\n")}And here is the rest. GOOD: Here is a lua paragraph\directlua{tex.print("", "")}And here is the rest. FAIL: Here is a lua paragraph\directlua{tex.sprint("", "")}And here is the rest. FAIL: 30
\directlua{ % FAILS: the newline appears to have some strange catcode- and is % reported in a different way %tex.print("\noexpand\\pgfplotstabletypeset{A B\n 2 3\n 4 5\n}") } FAIL: \directlua{ % FAILS: the newline appears to have some strange catcode- and is % reported in a different way %tex.sprint("\noexpand\\pgfplotstabletypeset{A B\n 2 3\n 4 5\n}") } FAIL: \directlua{% % % FAILS: the curly brackets do not match, it interpretes % \pgfplotstabletypeset{A B % % as first statement and does not see the rest %tex.print("\noexpand\\pgfplotstabletypeset{A B", "2 3", "4 5}") } FAIL: \directlua{% % % FAILS: the curly brackets do not match, it interpretes % \pgfplotstabletypeset{A B % % as first statement and does not see the rest %tex.sprint("\noexpand\\pgfplotstabletypeset{A B", "2 3", "4 5}") } \end{document} I uncommented the items which produce compile failures. It should be noted that \pgfplotstabletypeset redeines the category code of newline to be 12 (other) and then it does its operation. I suppose this is 31
what caused the problem (in conjunction with LUA’s catcodetables).
Tags: luatex (Prev Q) (Next Q) 32
User: christian-feuersänger Answer by bruno-le-loch A single call to tex.print produces a single line of input, so you must call it once per line. For instance, to get two newline markers, do Here is a Lua paragraph\directlua{tex.print("") tex.print("")}And here is another Issuing \tracingall before these lines shows that indeed there is a single \par, and not two. The same is true for the table: \documentclass{article} \usepackage{pgfplotstable} \begin{document} \directlua{tex.print("\string\\pgfplotstabletypeset{A B") tex.print("2 3")tex.print("4 5")tex.print("}")} \end{document} Tags: luatex (Prev Q) (Next Q)
Q: Problem using length operator in Lua Tags: luatex (Prev Q) (Next Q) This is my MWE: Skip code block \documentclass{article} \newcommand{\printdata}{% \directlua{ data = {"a", "b", "c"} for i = 1, #data do 33
}
}
tex.print(data[i]) end
\begin{document} \printdata \end{document} I get the following error message: ! Illegal parameter number in definition of \printdata. LuaLaTeX doesn’t seem to understand the length operator # in #data. Somewhere else I read that you must preix it thus: \string#data, but this only works outside the \newcommand deinition. How can I ix this problem? Tags: luatex (Prev Q) (Next Q) User: nvaughan Answer by shreevatsar Make a ile (say foo.lua) containing your Lua code: function printeverything() data = {"a", "b", "c"} for i = 1, #data do tex.print(data[i]) end end Then in your .tex ile you can use it: \documentclass{article} \directlua{dofile('foo.lua')} \newcommand{\printdata}{\directlua{printeverything()}} \begin{document} 34
\printdata \end{document} (You don’t need to use a Lua function — you could just dump the function’s contents in your ile and deine \newcommand{\printdata}{\directlua{dofile('foo.lua')}} — but if you have multiple chunks of Lua code you may not want to create separate iles for each of them.) Explanation: When working with Lua code, and putting it in your .tex iles, sooner or later you’ll run into this issue: the TeX engine (LuaTeX) will read through the characters of your .tex ile assuming certain category codes, and characters like # have special meanings in TeX that you don’t intend in Lua code. There exists a way of working around this (run texdoc luacode to see the documentation of the luacode package), but IMO there are good reasons to do avoid these workarounds. As that documentation says in the very irst paragraph: Before presenting the tools in this package, let me insist that the best way to manage a nontrivial piece of Lua code is probably to use an external ile and source it from Lua, as explained in the cited document. The cited document (lualatex-doc.pdf) says: The luacode package provides commands and environments that help to varying degrees with some of these problems. However, for everything but trivial pieces of Lua code, it is wiser to use an external ile containing only Lua code deining functions, then load it and use its functions. For example: \directlua{dofile("my-lua-functions.lua")} \newcommand*{\greatmacro}[2]{% \directlua{my_great_function("\luatexluaescapestring{#1}", #2)}} One of the reasons I prefer putting Lua code in a separate .lua ile is that your editor probably does better syntax highlighting for the Lua code when it’s in an separate .lua ile. (Similarly, you can get better highlighting when pasting the Lua code here on this website, if it’s a separate code block.)
35
Answer by egreg You can hide # to TeX, while making it good for Lua: Skip code block \documentclass{article} \newcommand{\printdata}{% \directlua{ data = {"a", "b", "c"} for i = \string##data, 1, -1 do tex.print(data[i]) end }% } \begin{document} \printdata \end{document} This prints cba Note that a direct call to \directlua would need a single #. The doubling here is because # appears in a deinition. What’s this about? # is a special character for TeX. It is the “preix” for parameters in deinitions (and can be used alone in \halign, but it’s not the problem here). When TeX absorbs a deinition it doesn’t interpret macros and commands, but it ensures that # is followed by a digit according to the number of arguments of the macro being deined. If we want to pass # to the replacement text of a macro, we need to double it. See What is the meaning of double pound symbol (number sign, hash character) ##1 in an argument? for details. In this way, the replacement text of \printdata will actually contain a sin36
gle #. However, such # would be interpreted at a call of the macro and it would appear in a wrong context; but \string# transforms # into a printable character, so it doesn’t harm macro expansion when \directlua is executed. Thus \string##data: the doubling means that just \string#data is stored in the replacement text of \printdata. Since \directlua irst does TeX macro expansion, Lua will just see #data (with a safe #). Tags: luatex (Prev Q) (Next Q)
Q: LuaLaTeX for dummies: how to add LaTeX macros into \directlua? Tags: luatex (Prev Q) (Next Q) How to make the following code to compile? \documentclass{article}
\newcommand*{\mycommand}{\directlua{for i = 1, 1ḷ do tex.sprint(i\hskip1cm) end}} %\newcommand*{\mycommand}{\directlua{for i = 1, 1ḷ do tex.sprint(i\\hskip1cm) end} %\newcommand*{\mycommand}{\directlua{for i = 1, 1ḷ do tex.sprint(i) end}} \begin{document} test \mycommand \end{document} Tags: luatex (Prev Q) (Next Q) User: andreas-hettel Answer by jldiaz First, you want to concatenate the value of the variable i with the token \hskip1cm, but the expression i\hskip1cm is not a valid lua expression.
37
What you need is to make \hskip1cm a lua string and concatenate it with the value of i. That is: tex.sprint(i .. "\hskip1cm") This, however, won’t work either because inside the quotes, the \ is a escapechar for lua, so \h will be interpreted as a escape sequence, and lua will complain that \h is an invalid escape sequence. So you have to ”escape the escape”: tex.sprint(i .. "\\hskip1cm") This would be ok for lua, but causes problems to TeX, since it makes \\ to appear inside a tex deinition, and TeX tries to expand it, causing trouble. You can avoid this trouble in two diferent ways: First solution This is the preferred one. Move your lua code to an external ile. For example, create a ile called mycommand.lua, which contains a lua function implementing your code: -- mycommand.lua function mycommand() for i = 1, 1ḷ do tex.sprint(i .. "\\hskip1cm") end end Then, in your tex ile, run the lua ile (which deines that function and makes it available for lua), and deine \mycommand to execute the function mycommand. This way: \documentclass{article} \directlua{dofile("mycommand.lua")}
% This defines the lua function mycommand()
\newcommand*{\mycommand}{\directlua{mycommand()}} % This defines the tex macro \begin{document} test \mycommand \end{document} 38
Note that the expansion of \mycommand does not contain now any \\, so TeX is happy. When TeX expands \mycommand, this causes the function mycommand() to be executed, and this will ”output” into the tex document the concatenation of i.."\\hskip1cm", which results into 1\hskip1cm2\hskip1cm3\hskip1cm etc, which is ok. The resulting pdf shows the intended result:
Second solution This is uglier and in general not recommended. You can put any tex macro inside \luatexluaescapestring, and this will modify its expansion so that the result is a valid lua string. So, if you write for example "\luatexluaescapestring{\foo}" this will produce a complex string which contains the expansion of \foo, but wich each \ escaped as \\. Applying this to your example:
\documentclass{article} \newcommand*{\mycommand}{% \directlua{for i = 1, 1ḷ do tex.sprint(i .. "\luatexluaescapestring{\hskip1cm}") } \begin{document} test \mycommand \end{document} Note how you still require double quotes around it, to get a lua string which can be concatenated to the value of variable i. Tags: luatex (Prev Q) (Next Q)
Q: Printing LaTeX code in LuaTeX Tags: luatex (Prev Q) (Next Q) 39
A calculation is done in Lua, and according to the result a certain type of cell must display the data. This works: \multicolumn{3}{p{11cm}}{Test}&-1ḷ\\[ḷ.4cm] But this doesn’t \directlua{tex.print(\multicolumn{3}{p{11cm}}{Test}&-1ḷ\\[ḷ.4cm])} with the following error message: ! Undefined control sequence. \@setfontsiḶe ...b ####1##2") else out:write("\space\space\space\space->") end if head.next==nil then out:write("nil") else out:write(string.format("%3d",head.next.id)) end out:write(" ("..n[head.id].."->") if head.next==nil then out:write("nil)\string\n") else out:write(n[head.next.id]..")\string\n") end if head.id==ḷ or head.id==1 then printnode(head.head) end head=head.next end return true end callback.register("post_linebreak_filter",printnode,"printnode")} \endgroup hello world \bye Tags: luatex (Prev Q) (Next Q)
61
Q: How to access LaTeX counters in luatex? Tags: luatex (Prev Q) (Next Q) In the same vein as this question, I know I can access raw TeX counts with Lua using tex.count[key], but how do I access a LaTeX counters in Lua? MWE: Skip code block \documentclass{article} % This is TeX \newcount\mycount \mycount 4\relax % end of TeX \newcounter{mycountlatex} \setcounter{mycountlatex}{5} \begin{document} \directlua{tex.print(tex.count['mycount'])} % How to do something like this? % \directlua{tex.print(tex.count['mycountlatex'])} \end{document} Tags: luatex (Prev Q) (Next Q) User: nathanael-farley Answer by nathanael-farley LaTeX counters can be accessed as TeX counts, but LaTeX prepends the name with a c@ so mycountlatex becomes c@mycountlatex in TeX (source). This means the MWE above would become: Skip code block 62
\documentclass{article} % This is TeX \newcount\mycount \mycount 4\relax % end of TeX \newcounter{mycountlatex} \setcounter{mycountlatex}{5} \begin{document} \directlua{tex.print(tex.count['mycount'])} % How to do something like this? \directlua{tex.print(tex.count['c@mycountlatex'])} \end{document} Answer by aditya It is a good idea to hide such internal details from the user and deine a latex.counter that ”does the right thing(tm)”. This is relatively easy to do in Lua using metatables: latex = latex or {} latex.counter = latex.counter or {} local counter = latex.counter local count = tex.count setmetatable(counter, {__index = function(t, key) return count['c@' .. key] end} ) Now latex.counter[key] will return the value of the LaTeX counter key. Here is a complete example: Skip code block 63
\documentclass{article} \usepackage{luacode} \begin{luacode*} latex = latex or {} latex.counter = latex.counter or {} local counter = latex.counter local count = tex.count setmetatable(counter, {__index = function(t, key) return count['c@' .. key] end} ) \end{luacode*} % This is TeX \newcount\mycount \mycount 4\relax % end of TeX \newcounter{mycountlatex} \setcounter{mycountlatex}{5} \begin{document} \directlua{tex.print(tex.count['mycount'])} % How to do something like this? \directlua{tex.print(latex.counter['mycountlatex'])} \end{document} Tags: luatex (Prev Q) (Next Q)
64
Q: How to do a ’printline’ in LuaTeX Tags: luatex (Prev Q) (Next Q) I have just started exploring the world of LuaTeX and wanted to write a piece of code, that prints a name to a new line in the document. \directlua{ for i=1,3,1 do tex.print("FOO") end } which should produce the following output: FOO FOO FOO rather than: FOO FOO FOO How do I use Lua correctly? I have tried messing with \\ and many other things over the course of an hour. Am I approaching this problem from the wrong angle? Any help is highly appreciated. Tags: luatex (Prev Q) (Next Q) User: julian Answer by topskip If you are using LaTeX (LuaLaTeX), I’d strongly advice against using \directlua{} for more than a simple call to execute another Lua ile. \directlua{} is in no way safe. For example: • if you use a Lua comment (--), your code gets Q=”!%”§I. This is because in \directlua{} everything is read on one line. • If you try to use a literal % sign, for example in tex.print() you... well, try yourself . Good luck.
65
• If you try to use an active character such as ~ surprising results are guaranteed. • When you want to use tex.print() with a macro, such as \par, you have do crazy stuf to not let TeX see the macro before Lua sees the macro. • And good luck inserting strings like ”\n” for a new line character. Now what to do? Use the environment luacode* from the luacode package: \begin{luacode*} for i=1,3,1 do tex.print("FOO\\par") end \end{luacode*} If you can’t use the luacode package (for example when you use plain TeX), use dofile() or require() to load a package and put your code there. TeX can’t ind and interpret the code there, only Lua. And then you can write for i=1,3,1 do tex.print("FOO\\par") end without trouble. Answer by khaled-hosny tex.print appends \endlinechar to each string it prints except the last, so just print an empty string at the end. \directlua{ for i=1,3,1 do tex.print("FOO", "") end } \bye Answer by chel
66
Two problems here: A "\\" in Lua just gets you one literal backslash which TeX stumbles over; as in the answers to this question you must use "\\\\" or [[\\]]. Also, \directlua expands control sequences within it; so if you want to pass a control sequence verbatim into Lua you’ll need to either\noexpand it or use \luaexec instead. Any of these three would work: \directlua{ for i=1,3,1 do tex.print([[FOO\noexpand\\]]) end } \luaexec{ for i=1,3,1 do tex.print([[FOO\\]]) end } \luaexec{nl = [[\\]]} \directlua{ for i=1,3,1 do tex.print("FOO" .. nl) end } Tags: luatex (Prev Q) (Next Q)
Q: percent signs in luacode* environment (LuaLaTeX) Tags: luatex (Prev Q) (Next Q) Can someone explain what happens here: 67
\documentclass{article} \usepackage{luacode} \begin{document} \begin{luacode*} tex.print("xx\%a","yy\\%b","ḶḶ\\\%c") \end{luacode*} \end{document} The result is xxyy%b ḶḶ%c. (The xx,yy,zz is clear.) The \%a is ”ignored”, the \\%b and the \\\%c results in the ”same” %b (or c). What is the preferred way to get a % in the PDF output? Why is the \%a ignored? What does TeX see after returning from the lua call? Tags: luatex (Prev Q) (Next Q) User: topskip Answer by aditya I assume that luacode in LaTeX works the same way as \startluacode...\stopluacode in ConTeXt. luacode expands its contents before passing control to lua. So, • xx\%a => xx%a (because \% = %) • yy\\%b => yy\%b (because \\ = \) • ḶḶ\\\%c => ḶḶ\%c (because \\ = \ and \% = %) Thus, (as Paŭlo Ebermann) mentioned, lua writes the following to TeX input stream: xx%a yy\%b ḶḶ\%c which explains the output that you get. Perhaps the following test ile will make this clear (Compare the console output from pdf output). \def\%{?} \def\?{!} \starttext 68
\startluacode tex.print("xx\%a","yy\\%b","ḶḶ\\\%c") print("xx\%a","yy\\%b","ḶḶ\\\%c") \stopluacode \stoptext Answer by paŭlo-ebermann I think the single \ serves to escape the next letter in Lua, letting itself dissappear. So, TeX gets to see these three lines: xx%a yy\%b ḶḶ\%c And obviously the irst one causes the %a (+ the following line-break) to be ignored, while the second and third write out a %. It is a bit annoying that all (most) programming languages use the same \ as an escape character, so when embedding one in another you need multipleescaping. Tags: luatex (Prev Q) (Next Q)
Q: Interactive lualatex compiling Tags: luatex (Prev Q) (Next Q) I have a made document using LuaLaTeX with some constants I have to change each time regarding about the circumstances. Is there a way that LuaLaTeX open an interactive window to ask me the value for the constants? For example, I want to be ask for n in the next MWE: Skip code block 69
\documentclass[border=3pt]{standalone} \usepackage{luacode} \newcommand{\bob}{% \luadirect{ n = 5 for i = 1,n do tex.print(i) end } } \begin{document} \bob \end{document} Tags: luatex (Prev Q) (Next Q) User: tarass Answer by egreg You can have a rather primitive form of interaction if you run LuaLaTeX in interactive mode to begin with, that is, from a shell (a console/terminal, in other words). All front ends run LaTeX (any engine) in non interactive mode. Here’s how: Skip code block \documentclass[border=3pt]{standalone} \usepackage{luacode} \typein[\myn]{Tell me n, boss!} \newcommand{\bob}{% \luadirect{ 70
}
n = \myn\space for i = 1,n do tex.print(i) end }
\begin{document} \bob \end{document} The run on the terminal will interrupt with the message Tell me n, boss! \myn = to which you should answer by typing a number. No window system, I’m afraid. You can get a window with a fancy dialog box with any scripting language; the answer should be used to make the script run something like lualatex -interaction=nonstopmode '\def\myn{}\input{}' (add all other options you need). The \typein line should not be used, in this case. Tags: luatex (Prev Q) (Next Q)
Q: Get value of macro from lualatex directly Tags: luatex (Prev Q) (Next Q)
71
I need to get the value of a macro from lualatex directly and return it in a function call function GetMacroValue(macro) return macro.value end I’ve tried various things such as using tex.print to store the value in a temp value BUT since tex.print executes after the function call/luacode block it does not work function GetMacroValue() tex.print("\\directlua{value = tonumber('\\the\\"..macro.."')}") return value end Would work except the tex.print line does not execute until after the fact in which case the previous value is returned. since tex.execute does not exist yet is there any other method? I’ve tried coroutines but it does not work for(or I can’t get it to work). Tags: luatex (Prev Q) (Next Q) User: abstractdissonance Answer by topskip If it’s a count register, you can access it directly (tex.count[...]). Similar for other stored items such as toks, skip, dimen and attribute registers. See manual section 4.13.4. If it is something you only get ”during runtime” you have to use coroutines for that. I have written an answer to another question where I have given a short working example for a coroutine: https://tex.stackexchange.com/a/20905/243 Tags: luatex (Prev Q) (Next Q)
72
Q: My irst luaLaTeX example Tags: luatex (Prev Q) (Next Q) I am totaly inexperienced in LuaLaTeX and I don’t know why but it was somehow very diicult to ind working LuaLaTeX example so I can start playing around. I inaly found the example in a document Numerical methods using LuaLaTeX (p.3): Skip code block \documentclass{article} \usepackage{luacode}
\begin{luacode*} function trigtable () for t=ḷ, 45, 3 do x=math.rad(t) tex.print(string.format( ’%2d$^{\\circ}$ & %1.9f & %1.9f & %1.9f & %1.9f \\\\’, t, x, math.sin( end end \end{luacode*} \newcommand{\trigtable}{\luadirect{trigtable()}} \begin{document} \begin{tabular}{rcccc} \hline & $x$ & $\sin(x)$ & $\cos(x)$ & $\tan(x)$ \\ \hline \trigtable \hline \end{tabular} \end{document} What I found out from this example is, how to implement Lua code in LaTeX document and it is all great, but how come that this example fails to com73
pile with LuaLaTeX if I save it as text.tex and process it using lualatex test.tex? I get this command line output: Skip code block This is LuaTeX, Version 1.ḷ.4 (TeX Live 2ḷ17/Arch Linux) restricted system commands enabled. (./test.tex LaTeX2e (using write cache: /home/Ḷiga/.texlive/texmf-var/luatex-cache/generic)(using r ead cache: /var/lib/texmf/luatex-cache/generic /home/Ḷiga/.texlive/texmf-var/lu atex-cache/generic) luaotfload | main : initialiḶation completed in ḷ.128 seconds Babel and hyphenation patterns for 1 language(s) loaded. (/usr/share/texmf-dist/tex/latex/base/article.cls Document Class: article 2ḷ14/ḷ9/29 v1.4h Standard LaTeX document class (/usr/share/texmf-dist/tex/latex/base/siḶe1ḷ.clo(load luc: /home/Ḷiga/.texlive/ texmf-var/luatex-cache/generic/fonts/otl/lmroman1ḷ-regular.luc))) (/usr/share/texmf-dist/tex/lualatex/luacode/luacode.sty (/usr/share/texmf-dist/tex/generic/oberdiek/ifluatex.sty) (/usr/share/texmf-dist/tex/luatex/luatexbase/luatexbase.sty (/usr/share/texmf-dist/tex/luatex/ctablestack/ctablestack.sty)))[\directlua]:5: malformed number near '2d'. \luacode@dbg@exec ...code@maybe@printdbg {#1} #1 } l.12 \end{luacode*} Tags: luatex (Prev Q) (Next Q) User: 71ga Answer by shreevatsar (Answering the question rather than voting to close, because I can ind no other occurrences of “malformed number near” on this site, so it would be useful to have this question around for anyone else who is likely to make a similar typo.) 74
The error message [\directlua]:5: malformed number near ’2d’. tells you where to look: on line 5 within the luacode block, near the string 2d. And this is what your ile contains there (part of line 5 replaced with ...): tex.print(string.format( ’%2d$^{\\circ}$ ... note the character before the %2d: it’s ’ which is U+2019 RIGHT SINGLE QUOTATION MARK, and the Lua interpreter doesn’t know what to do with it. Actually it does: it thinks that ’ is the name of a variable, then looks at the % and decides you’re trying to take the remainder, but on the right side of the % operator you have 2d which is not a number. (Hence the error message about a malformed number.) If you had ’ = 23 and then string.format(’%4), the latter would correctly give you 3. (In this case even though you haven’t deined ’ to be a variable, the syntax-analysis part of Lua cannot give you an error immediately, because you could deine a variable with that name later.) How did ’ get in there? Possibly a bug in your editor; make sure you ix it or it will happen again. Just change ’ to ’ in both places, and your code works; congratulations on getting your irst LuaLaTeX ile working correctly!
75
Aside: I have found it better to put all Lua code in a separate .lua ile and in your .tex ile have only \directlua{dofile('myluascript.lua')} (or whatever). This way you get better syntax highlighting for your lua code, when editing your ile or when showing it on a site like this. Your code, with the lua code moved out and with @marsupilam’s advice of using [[ ... ]] strings: .tex ile: Skip code block \documentclass{article} \directlua{dofile('lualatex-bug.lua')} \newcommand{\trigtable}{\directlua{trigtable()}} \begin{document} \begin{tabular}{rcccc} \hline 76
& $x$ & $\sin(x)$ & $\cos(x)$ & $\tan(x)$ \\ \hline \trigtable \hline \end{tabular} \end{document} lualatex-bug.lua:
function trigtable () for t=ḷ, 45, 3 do x=math.rad(t) tex.print(string.format([[%2d$^{\circ}$ & %1.9f & %1.9f & %1.9f & %1.9f \\ t, x, math.sin(x), math.cos(x), math.tan(x))) end end Answer by marsupilam You may be interested in lua long strings to discard all special characters in the string, and have them raw. This is especially relevant to luaLaTeX, as the escape character in lua is the backslash \. If you want to pass a command to TeX, the \ has to be doubled, and it may thus be less annoying to type [[\mycmd]] than "\\mycmd", or [[\\]] than "\\\\" The output
77
The code Skip code block \RequirePackage{luatex85} \documentclass[12pt,border=2pt]{standalone} \usepackage{luacode} \begin{luacode*} function trigtable () for t=ḷ, 45, 3 do local x=math.rad(t) local sf =[[%2d$^{\circ}$ & %1.9f & %1.9f & %1.9f & %1.9f \\]] tex.print(string.format(sf, t, x, math.sin(x), math.cos(x), math.tan(x))) end end \end{luacode*} 78
\newcommand{\trigtable}{\luadirect{trigtable()}} \begin{document} \begin{tabular}{rcccc} \hline & $x$ & $\sin(x)$ & $\cos(x)$ & $\tan(x)$ \\ \hline \trigtable \hline \end{tabular} \end{document} Tags: luatex (Prev Q) (Next Q)
Q: How to check for Lua deinitions Tags: luatex (Prev Q) (Next Q) When there is \directlua{x = 25} one can say \edef\rgf{\directlua{tex.sprint(x)}}, but when x was never created by \directlua{x = 25}, \directlua{tex.sprint(x)} will fail. Thus something like \@ifundefined{x}{x undefined}{x defined} would be nice. How does one ”say this in Lua”, please? Tags: luatex (Prev Q) (Next Q) User: stephen Answer by topskip You can do this: \directlua{tex.sprint( x or 42 ) } or perhaps \directlua{ 79
}
if x then tex.sprint(x) % else % do something else end
Tags: luatex (Prev Q) (Next Q)
Q: LuaLaTeX, sprint verbatim text Tags: luatex (Prev Q) (Next Q) The code below, uses the lua, socket.http library to pull a web page (for simplicity I have used a link to a text ile). I have used tex.sprint to pass it back to the typesetting engine. However I would have preferred to print within a verbatim environment or preferably using the listings environment. Any suggestions as to how I can achieve this? \documentclass{article} \usepackage[utf8]{luainputenc} \begin{document} \bgroup \catcode`\%=12 \catcode`\_=12 \catcode`\^=12 \catcode`\&=12 \directlua{ Skip code block local http = require("socket.http") function url_encode(str) if (str) then str = string.gsub (str, "\string\n", "\string\r\string\n") str = string.gsub (str, "([^%w ])", 80
function (c) return string.format ("%%%ḷ2X", string.byte(c)) end) str = string.gsub (str, " ", "+") end return str end function url_decode(str) str = string.gsub (str, "+", " ") str = string.gsub (str, "%%(%x%x)", function(h) return string.char(tonumber(h,16)) end) str = string.gsub (str, "\string\n", "\string\n") return str end local page = http.request( 'http://mirror-cybernet.lums.edu.pk/pub/ctan/dviware/ tex.sprint(page) } \egroup \end{document} Note, the MWE contains two functions that I haven’t used, for encoding and decoding the url. I left them in case you want to try a diferent url. As a sideline I ind it amazing that old ’TeX’ in new clothes can talk to the web. Tags: luatex (Prev Q) (Next Q) User: yiannis-lazarides Answer by topskip There are some problems with your code: 1. don’t use \usepackage[utf8]{luainputenc} in your document as utf8 is the default 2. Put the Lua code in a separate ile. If that is not feasible, use the luacode* environment from the luacode package See the question about luacode enviroments. Then you don’t need to mess with the cat codes. 3. The two functions you deine are not used (and are unnecessary). Here is a solution which works with the listings environment: 81
Skip code block \documentclass{article} \usepackage{luacode} \usepackage{listings} \begin{document}
\begin{luacode*} local http = require("socket.http") local page = http.request( 'http://mirror-cybernet.lums.edu.pk/pub/ctan/dviware/s tex.print("\\begin{lstlisting}") tex.print(page:gsub("\n","\r")) tex.print("\\end{lstlisting}") \end{luacode*} \end{document} Answer by aditya FWIW, in ConTeXt you can simply use
\starttext \typefile{http://mirror-cybernet.lums.edu.pk/pub/ctan/dviware/screenview/vms/test. \stoptext to load a ile from the net. Almost all ile loading macros use the socket library to download (and cache) the ile, if a url is speciied. If you want to do this manually, the following works:
\starttext \startluacode local http = require("socket.http") local page = http.request( 'http://mirror-cybernet.lums.edu.pk/pub/ctan/dviware/s tex.print(string.format("\\starttyping %s \\stoptyping", page)) \stopluacode \stoptext (I could not get the similar code to work in LuaLaTeX because the luacode 82
environment in LaTeX uses diferent catcodes than the luacode environment in ConTeXt) Tags: luatex (Prev Q) (Next Q)
Q: Accessing pointers in LuaTeX Tags: luatex (Prev Q) (Next Q) This code writes the subtype of disc nodes to the log ile. Skip code block \documentclass{minimal} \usepackage{fontspec} \directlua{ show_hyph = function(head) while head do if head.id == ḷ or head.id == 1 then % hlist, vlist show_hyph(head.head) elseif head.id == 7 then % disc texio.write_nl("Subtype " .. head.subtype) end head = head.next end return true end luatexbase.add_to_callback("post_linebreak_filter",show_hyph,"show_hyph") } \begin{document} \begin{minipage}{1pt} discretionary \end{minipage} \end{document} 83
The LuaTeX reference manual says in section 8.1.2.7 “disc nodes” pre pointer to the pre-break text How do I access this? Tags: luatex (Prev Q) (Next Q) User: håkon-malmedal Answer by topskip How do I access this? This is very simple and straightforward: use head.pre to access the list pointing to the pre part of the discretionary. Now the question you might ask next is ”why is the pre-part nil?” This is because you call your function show_hyph() on the post_linebreak_ilter. At that point the pre part is already inserted before that disc node and thus the pre part is empty. The same is with post and replace. What I can’t tell you is why the disc node stays in the node list. Tags: luatex (Prev Q) (Next Q)
Q: LuaTeX gets stuck when ”.” is added to pattern-expression Tags: luatex (Prev Q) (Next Q) today on SE I got inspired to try LuaTeX. I’m facing a problem where the compilation process stalls at some point if I add a single ”.” to a pattern matching expression. In short, this works: line = string.gsub ( line , "^(%s*)" this doesn’t: 84
,
"%1" )
line = string.gsub ( line , "^(%s*)."
,
"%1" )
(I know this pattern doesnt make toooo much sense, but it’s a reduced version of a longer expression) Compilation stalls at: This is LuaTeX, Version beta-ḷ.8ḷ.ḷ (TeX Live 2ḷ15/Debian) (rev 5238) restricted \write18 enabled. (./mwe4.tex LaTeX2e patch level 2 [...] (/usr/share/texlive/texmf-dist/tex/luatex/luatexbase/cctb.lua)) (/usr/share/texlive/texmf-dist/tex/luatex/luatexbase/luatexbase-mcb.sty (/usr/share/texlive/texmf-dist/tex/luatex/luatexbase/mcb.lua)))) (./mwe4.aux)) * A full MWE is here (the critical line being #6): Skip code block \documentclass{article} \usepackage{luacode,luatexbase} \begin{luacode} function replacetext2 ( line ) line = string.gsub ( line , "^(%s*)" return ( line ) end \end{luacode}
,
"%1" )
\newenvironment{haystack}{% \directlua{luatexbase.add_to_callback( "process_input_buffer", replacetext2, "replacetext2")}}{% \directlua{luatexbase.remove_from_callback( "process_input_buffer", "replacetext2")}} \begin{document} \begin{haystack} 85
a
b \end{haystack} \end{document} Tags: luatex (Prev Q) (Next Q) User: sheß Answer by heiko-oberdiek The pattern ^(%s*). in line = string.gsub ( line , "^(%s*)."
,
"%1" )
looks for any white space (can be empty) at the begin of line, followed by one character (.). This is replaced by the white space (%1) and the matched non-white-space character is removed. Therefore LuaTeX will no longer see \end{haystack}, but end{haystack} and keeps looking for the end of the environment. The example with some debug output to show the line in brackets, before and after the substitution: Skip code block \documentclass{article} \usepackage{luacode,luatexbase} \begin{luacode} function replacetext2 ( line ) texio.write_nl('') texio.write('[', line, '] --> [') line = string.gsub ( line , "^(%s*)." texio.write(line, "]") texio.write_nl('') return ( line ) end \end{luacode} \newenvironment{haystack}{% 86
,
"%1" )
\directlua{luatexbase.add_to_callback( "process_input_buffer", replacetext2, "replacetext2")}}{% \directlua{luatexbase.remove_from_callback( "process_input_buffer", "replacetext2")}} \begin{document} \begin{haystack} a b \end{haystack} \end{document} Result: [a] --> [] [ b] --> [ ] [\end{haystack}] --> [end{haystack}] [\end{document}] --> [end{document}] If you only want to remove a real dot at the beginning of a line, then the dot needs to be escaped as magic character %., since the pure dot . means any character. Tags: luatex (Prev Q) (Next Q)
Q: Cannot access arguments in a lua block Tags: luatex (Prev Q) (Next Q) The follow code is trying simply to print the irst argument of a macro. I’ve tried various things found on the net(there is very little) to get #1 printed in lua but nothing works. I assume there is an issue with interpreting it in lua. Would be nice if there was some tutorial on bridging the gap between
87
tex and lua. Most stuf I’ve seen use external lua iles or do not reference anything except macros in a directlua block. Skip code block \documentclass[11pt]{book} % use larger type; default would be 1ḷpt \usepackage{luatex} \usepackage{pgffor} \tracingonline 6 \directlua{ tex.enableprimitives('',tex.extraprimitives()) local lpeg = require "lpeg" } \begin{document} \def\Parse#1{ \directlua{ cmdString = tostring(#1)
}
}
tex.print(cmdString)
\Parse{hello12341234asdf} \end{document} Tags: luatex (Prev Q) (Next Q) User: uiy Answer by mico 88
You shouldn’t just specify #1 as the argument of tostring; rather, try something like "\luatexluaescapestring{#1}". With this modiicaton, your MWE works ine: Skip code block \documentclass[11pt]{book} \usepackage{luatex,pgffor} \tracingonline 6 \directlua{ tex.enableprimitives('',tex.extraprimitives()) local lpeg = require "lpeg" } \def\Parse#1{ \directlua{ cmdString = tostring("\luatexluaescapestring{#1}") tex.print(cmdString) } } \begin{document} \Parse{hello12341234asdf} \end{document} Update, May 2016: Alain Matthes has pointed out in a comment that the code shown above no longer runs, at least not with TeXLive2015. The problem turns out to be related to the version of the luatex package that’s installed on one’s system. Happily, arlier this month Heiko Oberdiek released an update to luatex.sty which ixes this issue. As TeXLive2015 is currently ”frozen”, one either needs to download the updated package from the CTAN and install it manually, switch to the latest release of TeXLive2016-pre, or wait a few more weeks until the oicial version of TeXLive2016 is released and may be installed Alternatively, load the luacode package instead of the luatex package. Answer by topskip 89
Mico has already given the correct answer. Let me extend the explanation. When you write: \def\Parse#1{\directlua{
cmdString = tostring(#1)
}}
and call \Parse{hello12341234asdf}, the result is pretty much like this: \directlua{
cmdString = tostring(hello12341234asdf)
}
Which is, of course, not what you want. You need to put the quotation marks around the deinition: \def\Parse#1{\directlua{
cmdString = tostring("#1")
}}
and a call to \Parse{hello12341234asdf}, gives \directlua{
cmdString = tostring("hello12341234asdf")
}
Now what happens if you call \Parse{hello"1234}? You get \directlua{
cmdString = tostring("hello"1234")
}
which, again, is not what you want. Therefore you need to escape the contents of #1. This is what \luaescapestring{} does for you. But this won’t work in LaTeX, because in LaTeX every Lua command from the reference manual is preixed with luatex (except for \directlua). Therefore the deintion is that what Mico writes: \def\Parse#1{\directlua{
cmdString = tostring("\luatexluaescapestring{#1}")
Tags: luatex (Prev Q) (Next Q)
Q: Problem with luacode in sty ile Tags: luatex (Prev Q) (Next Q) I’m trying to include a gcd function using lua in a sty ile. Here is the code of euclide.sty : Skip code block
90
}}
\RequirePackage{ifluatex,luacode,luatextra} \ifluatex \begin{luacode} function euclide(a,b) if a < b then a,b = b,a end r = a-math.floor(a/b)*b if r == ḷ then tex.print(b) else euclide(b,r) end end \end{luacode} \newcommand{\euclide}[2]{\luaexec{euclide(#1,#2)}} \fi Here is the texile code : \documentclass[1ḷpt,oneside]{article} \usepackage{euclide} \begin{document} \euclide{435}{63ḷ} \end{document} The lualatex compilation give me errors : Skip code block Runaway argument? ! File ended while scanning use of \luacode@grab@lines.
\par l.4 I suspect you have forgotten a `}', causing me to read past where you wanted me to stop. I'll try to recover; but if the error is serious, you'd better type `E' or `X' now and fix your file. ! LaTeX Error: Missing \begin{document}. Can somebody tell me what’s wrong in my code ? (this code works ine in the main tex ile, but not in sty ile) Thanks, MB. 91
Tags: luatex (Prev Q) (Next Q) User: mb78 Answer by heiko-oberdiek I can reproduce the problem, if the white space before \end{luacode} is a tabulator character. Environment luacode is a special environment, because it changes category codes to read its contents in a more verbatim way. Therefore the end detection is not done by the usual macro expansion, but by searching for the string \end{luacode} at the start of a new line (spaces are ignored with catcode 10 here). Fix: Replace tabulators by spaces (depending on the editor, there might be an option for this.) BTW: It is a little inconsistent: First packages are loaded that require LuaTeX (luacode and luaextra), then the code is wrapped in \ifluatex. If the package works with and without LuaTeX: Skip code block \RequirePackage{ifluatex} \ifluatex \RequirePackage{luacode,luaextra} \begin{luacode} ... \end{luacode} ... \else ... \fi Or test for LuaTeX and throw an error, if LuaTeX is required: Skip code block \RequirePackage{ifluatex} \ifluatex \else \PackageError{euclide}{LuaTeX is required}\@ehd 92
\newcommand*{\euclide}[2]{% % dummy definition }% \expandafter\endinput % abort early \fi \RequirePackage{luacode,luaextra} \begin{luacode} ... \end{luacode} Tags: luatex (Prev Q) (Next Q)
Q: LuaTeX: \luaexec leads to ’Missing number, treated as zero.’ Tags: luatex (Prev Q) (Next Q) I can’t handle Lua LaTeX interaction in LuaTeX. I’m getting type errors anytime luacode is suppose to output non-string token. For example in this case: Skip code block \documentclass{report} \usepackage[export]{adjustbox} \usepackage{fontspec} \usepackage{luacode} \begin{luacode*} function params() tex.print(ḷ.12) end \end{luacode*} \begin{document} 93
{\adjustbox{trim={\luaexec{params()}\width} {.2\height} {ḷ.1\width} {.15\height},c {\includegraphics[keepaspectratio,width=5cm]{pic.jpg}}} \end{document} I’ll get: ’Missing number, treated as zero.’ Tags: luatex (Prev Q) (Next Q) User: tomas-jakl Answer by joseph-wright This is an expansion question: \luacode is not expandable. Underlying the trim key is a TeX dimension assignment: what is given here needs to be assignable by TeX as a length, and that means any code used has to be expandable. However, if you trace the deinition of \luacode it contains a \begingroup (and other stuf) which stops expansion. This non-expandable code is used to make the \luacode macro work, but it means that you can’t structure you input in the way you want. As mentioned in a comment, a ’raw’ \directlua will work here: the primitive is expandable so supplies TeX with what is required (here ḷ.12\textwidth). To explain the error itself, what happens is that TeX inds the \begingroup but is looking for a number. Non-expandable tokens terminate the number search but TeX hasn’t got anything it can interpret as a number, so it gives an error. Tags: luatex (Prev Q) (Next Q)
Q: Token expansion with the token library Tags: luatex (Prev Q) (Next Q) I don’t understand how the token library of luatex works. Skip code block 94
\documentclass{standalone} \begin{document} \def\mymacro{A} \directlua{% t = token.create ('mymacro') token.expand(t) token.get_next() } \end{document} The token.expand does not work as I expected: luatex says Undefined control sequence. Why? With the token.get_next(), I don’t know exactly what I should get... Tags: luatex (Prev Q) (Next Q) User: cjorssen Answer by andrew-swann Unfortunately token.expand is currently broken. See the bug report which derives from an example exactly like yours. Tags: luatex (Prev Q) (Next Q)
Q: Using lua code to obtain rules of diferent lengths Tags: luatex (Prev Q) (Next Q) I started to learning LuaLateX nowadays and I’d like to get some rules with increasing lengths, but I can’t igure out why this simple code doesn’t give 95
the desired output: Skip code block \documentclass[11pt]{book} \usepackage{xcolor} \usepackage{luatex,pgffor, luacode, calc} \begin{document} \newcommand{\myrules}{ \dimenḷ=2cm \luaexec{ for i=1,4 do tex.dimen[ḷ]=tex.dimen[ḷ]*i tex.print("\\color{red}\\rule{\\dimenḷ}{3pt}\\par") end } } \myrules \end{document} Tags: luatex (Prev Q) (Next Q) User: paulo-henrique-duarte Answer by heiko-oberdiek \luaexec is a wrapper for\directlua. It executes the Lua code and expands to: \color{red}\rule{\dimenḷ}{3pt}\par \color{red}\rule{\dimenḷ}{3pt}\par \color{red}\rule{\dimenḷ}{3pt}\par \color{red}\rule{\dimenḷ}{3pt}\par Also \luaexec calls \directlua inside a group. Thus the local assignments of tex.dimen[ḷ] are lost before TeX proceeds with the expansion result of \directlua. If the rules should be 2cm, 4cm, 6cm, and 8cm, then there is also a law in the algorithm that yields 2cm, 4cm, 12cm, 48cm. 96
Example ile for the irst version: Skip code block \documentclass[11pt]{book} \usepackage{xcolor} \usepackage{luatex,pgffor, luacode, calc} \parindent=ḷpt \begin{document} \newcommand{\myrules}{% \dimenḷ=2cm % \luaexec{ for i=1,4 do tex.print("\\color{red}\\rule{", tex.dimen[ḷ]*i, "sp}{3pt}\\par") end }% } \myrules \end{document}
Tags: luatex (Prev Q) (Next Q)
Q: How to convert glue spec like ‘\parillskip=0pt plus 1il’ to LuaTeX glue node Tags: luatex (Prev Q) (Next Q) I am trying to create a glue node that I can assign to the internal parameter tex.parfillskip.
97
In Plain TeX, the glue for \parfillskip is assigned as \parfillskip=ḷpt plus 1fil. Dumping the values in Lua(TeX): print("width: " .. tex.parfillskip.width) print("stretch: " .. tex.parfillskip.stretch) print("shrink: " .. tex.parfillskip.shrink) print("stretch_order: " .. tex.parfillskip.stretch_order) print("shrink_order: " .. tex.parfillskip.shrink_order) leads to this output: width: ḷ stretch: 65536 shrink: ḷ stretch_order: 2 shrink_order: ḷ So my questions are: • How does one convert a value 1fil to the stretch component of the glue spec. Is it just as simple as multiplying by 65536 (as it seems from the dump)? • How does one determine the value stretch_order? It seems a bit arbitrary. The value above is 2, but the stretch_order value for tex.topskip is ḷ. How does one determine what to put in that component for the glue spec. Tags: luatex (Prev Q) (Next Q) User: anjaan-aadmi Answer by egreg LuaTeX introduced an additional degree of ininite glue: you can have fi, fil, fill and filll. So settings like \parfillskip=ḷpt \parfillskip=ḷpt \parfillskip=ḷpt \parfillskip=ḷpt \parfillskip=ḷpt
plus plus plus plus plus
1pt 1fi 1fil 1fill 1filll 98
will have stretch orders 0, 1, 2, 3, 4 respectively. Indeed
{\directlua{tex.setglue("parfillskip",65536,65536,65536,1,1)}\showthe\parfillskip} will stop with > 1.ḷpt plus 1.ḷfi minus 1.ḷfi. The units are in scaled points, so to get 1 you need 65536 whatever you choose among the ones above. Tags: luatex (Prev Q) (Next Q)
Q: lualatex print, directlua env, and newline Tags: luatex (Prev Q) (Next Q) When using print from lua, if the log ile’s current line has not been terminated then the lua tex will not start on a new line. This is very annoying because many times I search for some debug string being printed and it is not on a new line but at the end of some rather long line printed from TeX. e.g.,
Printing some debug string 1 [1{C:/Users/Administrator/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] [2] [3] [4] [5] [6] [7] [8] [9] [1ḷ] [11] [12] [13]Printing another debug string 2 [14] [15] [16] [17] [18] [19] [2ḷ] [21] [22] [23] [24] [25] [26] [27]` Instead of Printing some debug string 1 [1{C:/Users/Administrator/AppData/Local/MiKTeX/2.9/pdftex/config/pdftex.map}] [2] Printing another debug string 2 [14] [15] [16] [17] [18] [19] [2ḷ] [21] [22] [23] [24] [25] [26] [27] The 2nd one is the preferred case but if I print a newline, \n, then I’ll get unnecessary empty lines I do not want. 99
Is there any way to ix this? Basically on every entry of \directlua or whatever is used I want to print a new line ONLY if something is actually printed(so I don’t get a bunch of blank lines) and, even better, only if the log ile does not also end on a new line. Tags: luatex (Prev Q) (Next Q) User: abstractdissonance Answer by topskip Use texio.write_nl(...): Skip code block \documentclass{article} \usepackage{luacode} \begin{document} \begin{luacode*} texio.write_nl("Printing some debug string 1") \end{luacode*} foo \clearpage \begin{luacode*} texio.write_nl("Printing some debug string 2") \end{luacode*} \end{document} gives ... (/opt/texlive2ḷ12/texmf-dist/tex/luatex/luatexbase/luatexbase-modutils.sty (/opt/texlive2ḷ12/texmf-dist/tex/luatex/luatexbase/modutils.lua)) (/opt/texlive2ḷ12/texmf-dist/tex/luatex/luatexbase/mcb.lua)))) (./test.aux) Printing some debug string 1 [1{/opt/texlive2ḷ12/texmf-var/fonts/map/pdftex/upd map/pdftex.map}] Printing some debug string 2 (./test.aux) ) 267 words of node memory still in use: ... In one project I have deined a helper function: 100
function w( ... ) texio.write_nl("-----> " .. string.format(...)) end so that I can easily use formatted strings: w("Printing some debug string %d",1) Tags: luatex (Prev Q) (Next Q)
Q: lualatex: how to produce PDF acceptable by arxiv? Tags: luatex (Prev Q) (Next Q) With pdflatex, it is possible to create PDF iles that are acceptable by arxiv even without sources (with hyperref + \pdfsuppressptexinfo=1, see Making an anonymous PDF ile using PDFLaTeX). However, I don’t manage to create such a PDF using lualatex. With LuaLaTeX, what is the equivalent of \pdfsuppressptexinfo=1? Tags: luatex (Prev Q) (Next Q) User: martin-monperrus Answer by ulrike-ischer The (extended) equivalent to \pdfsuppressptexinfo is \pdfvariable suppressoptionalinfo \numexpr number\relax see the luatex documentation. So something like this works: Skip code block \documentclass{article} \usepackage{hyperref} \hypersetup{ 101
pdfcreator = {}, pdfproducer = {}
} \pdfvariable suppressoptionalinfo \numexpr 1+2+4+8+16+32+64+128+256+512 \relax \begin{document} abc \end{document} Tags: luatex (Prev Q) (Next Q)
Q: Problems with multi-page output when building nodes directly with node.write() Tags: luatex (Prev Q) (Next Q) MWE mwe.tex \directlua{tex.enableprimitives('',tex.extraprimitives())} \output={\shipout\box255} \pagewidth=21ḷmm \pageheight=2in \hoffset=1in \voffset=1in \directlua{dofile("mwe.lua")} \end mwe.lua Skip code block tex.outputmode = 1
102
-- Build a simple paragraph node from given text. This code does not do any comple --- adapted from: http://tex.stackexchange.com/questions/114568/can-i-create-a-node local function text_to_paragraph(text) local current_font = font.current() local font_params = font.getfont(current_font).parameters local para_head = node.new("local_par") local last = para_head local indent = node.new("hlist",3) indent.width = tex.parindent indent.dir = "TRT" last.next = indent last = indent
for c in text:gmatch"." do -- FIXME use utf8 lib local v = string.byte(c) local n if v < 32 then goto skipchar elseif v == 32 then n = node.new("glue",13) node.setglue(n, font_params.space, font_params.space_shrink, font_params.spa else n = node.new("glyph", 1) n.font = current_font n.char = v n.lang = tex.language n.uchyph = 1 n.left = tex.lefthyphenmin n.right = tex.righthyphenmin end last.next = n last = n ::skipchar:: end 103
-- now add the final parts: a penalty and the parfillskip glue local penalty = node.new("penalty", ḷ) penalty.penalty = 1ḷḷḷḷ local parfillskip = node.new("glue", 14) parfillskip.stretch = 2^16 parfillskip.stretch_order = 2 last.next = penalty penalty.next = parfillskip node.slide(para_head) return para_head end
local content = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do e for i = 1,3 do local head = text_to_paragraph(content) -- Break the paragraph into vertically stacked boxes local vbox = tex.linebreak(head, { hsiḶe = tex.hsiḶe }) node.write(vbox) node.write(node.copy(tex.parskip)) node.write(node.copy(tex.baselineskip)) print("PAGE TOTAL " .. tex.pagetotal) end Output Note that it gets cut of. I was expecting a page break to happen, and the rest of the content to move over to the next page.
104
Notes/Questions The idea is to create paragraph nodes entirely in Lua, and feed them to LuaTeX using node.write(). • I am overriding the Plain TeX output routine with the default output routine by doing: \output={\shipout\box255} • The tex.pagetotal parameter does not seem to increment itself automatically. Not sure if that is part of the problem • I guess another way to do this is to populate the entire box on my own and ship it out using tex.shipout, but I was hoping to exercise the page-building routines inside TeX to break the page at the right location, instead of doing it on my own. How can I ix this? Tags: luatex (Prev Q) (Next Q) User: vyom Answer by vyom Turns out, it is a pretty silly oversight on my part. I was only adjusting the \pageheight. The \vsiḶe parameter being used was the one set in the Plain TeX macro (which is 8.9in). If I change the size of \vsiḶe to be a little less than \pageheight, then things work ine. \directlua{tex.enableprimitives('',tex.extraprimitives())} \output={\shipout\box255} 105
\pagewidth=21ḷmm \pageheight=2in \vsiḶe=1in \hoffset=1in \voffset=1in \directlua{dofile("mwe.lua")} \end Tags: luatex (Prev Q) (Next Q)
Q: In LuaLaTeX, how do I pass the content of an environment to Lua verbatim **Without displaying it** in a beamer frame? Tags: luatex (Prev Q) (Next Q) In this question / answer : one pass verbatim latex material to lua, but latex displays this material by him self. If one suppress the two lines : local buf_without_end = mybuf:gsub("\\end{foobar}\n","") print(string.format("Lua: %q", buf_without_end)) the material doesn’t disapear. I’d like to modify this material using lua code and display it after. Skip code block \documentclass{beamer} \usepackage{luacode,tikḶ} \directlua{dofile("verb.lua")} \newenvironment{LuaVerb}{% \directlua{start_recording()}}{% \directlua{stop_recording()} } \begin{document} 106
\begin{frame} % pass the material to lua \begin{LuaVerb} hello word \end{LuaVerb} % use of this material, but with or witout this line % the material is displayed %\directlua{print_recording()} \end{frame} \end{document} verb.lua Skip code block tp = tex.print mybuf = "" function readbuf( buf ) mybuf = mybuf .. buf .. "\n" end function start_recording() luatexbase.add_to_callback('process_input_buffer', readbuf, 'readbuf') end function stop_recording() luatexbase.remove_from_callback('process_input_buffer', 'readbuf') end function print_recording() local buf_without_end = mybuf:gsub("\\end{LuaVerb}\n","") 107
end
print(string.format("Lua: %q", buf_without_end)) mybuf = ""
Tags: luatex (Prev Q) (Next Q) User: tarass Answer by michal.h21 If you don’t want to pass lines to LaTeX, you have to return empty string from the callback, otherwise callback pass the line if return value is nil. Because you don’t return any value, nil is used implicitly. And because LaTeX doesn’t process input anymore, you have to parse input for \end{LuaVerb} from Lua side, otherwise you would grab all lines until the end: local end_verb = '%s*\\end{LuaVerb}' function readbuf( buf ) if buf:match(end_verb) then return buf end mybuf = mybuf .. buf .. "\n" return "" end Now there is some strange issue with beamer, which is maybe caused by how frames are processed, because no output is printed with print_recording(). But when I changed document class to article, I got: (/opt/texlive/2ḷ13/texmf-dist/tex/luatex/luatexbase/mcb.lua)))) (./jej.aux)Lua: " hello word\ " Tags: luatex (Prev Q) (Next Q)
108
Q: Using LuaLaTeX and SQLite3 Tags: luatex (Prev Q) (Next Q) I am trying to access SQLite databases from LuaLaTeX but am not able to load an installed lsqlite3 package. Here’s what I tried so far: 1. Took a brandnew Xubuntu 14.04 installation 2. Installed a complete TeX Live 2014 3. Installed Luarocks (which installed Lua5.1 on the way) 4. Used Luarocks to install lsqlite3 uwe@luabuntu:/media/uwe$ luarocks list Installed rocks: lsqlite3 0.9.1-2 (installed) - /usr/local/lib/luarocks/rocks 5. Appended the package.path in the following TeX ile: \documentclass{article} \usepackage{luacode} \begin{document}
\begin{luacode*} package.path="/usr/local/lib/luarocks/rocks;/usr/local/lib/luarocks/rocks/l /usr/local/lib/lua/5.1/lsqlite3.so" .. package.path require("lsqlite3") \end{luacode*} Hello Lua! \end{document} The error I receive is the following: ! LuaTeX error [\directlua]:3: module 'lsqlite3' not found: no field package.preload['lsqlite3'] 109
[luatexbase.loader] Search failed [kpse lua searcher] file not found: 'lsqlite3' [kpse C searcher] file not found: 'lsqlite3' [oberdiek.luatex.kpse_module_loader]-eroux Search failed stack traceback: [C]: in function 'require' [\directlua]:3: in main chunk. \luacode@dbg@exec ...code@maybe@printdbg {#1} #1 } l.9 \end{luacode*} What must be set to have LuaLaTeX ind the lsqlite3 package? EDIT I have tried to adjust everything following the comments below: 1. Adjusted /usr/local/texlive/2ḷ14/texmf.cnf 2. Put everything into the example 3. Still get the error about the missing lsqlite3 module with the following example \documentclass{article} \directlua{ require "lualoader" } \usepackage{fontspec} \usepackage[english]{babel} \begin{document}
\directlua{package.path='/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/ package.cpath='/usr/local/lib/lua/5.1/?.so;/home/uwe/.luarocks/lib/lua/5.1/?. require "lualoader" } \directlua{% local sqlite3 = require("lsqlite3") local db = sqlite3.open_memory() 110
db:exec[[ CREATE TABLE test (id INTEGER PRIMARY KEY, content); INSERT INTO test VALUES (NULL, 'Hello World'); INSERT INTO test VALUES (NULL, 'Hello Lua'); INSERT INTO test VALUES (NULL, 'Hello Sqlite3') ]] for row in db:nrows("SELECT * FROM test") do tex.print(row.id .. " : ".. row.content ) end } \end{document} Tags: luatex (Prev Q) (Next Q) User: uwe-ziegenhagen Answer by vyom As of May 2017, there is a package on CTAN called luapackageloader, that allows you to modify the default package searching behavior in LuaTeX. Once you load luapackageloader, doing a require will irst try the default kpse based searcher. If the module isn’t found, it will also try to load the package from Lua’s package.path and package.cpath values. Usage example Skip code block \documentclass{article} \usepackage{luacode} \usepackage{luapackageloader} \begin{document} \begin{luacode*} 111
package.path="/usr/local/lib/luarocks/rocks;/usr/local/lib/luarocks/rocks/lsqlit /usr/local/lib/lua/5.1/lsqlite3.so" .. package.path require("lsqlite3") \end{luacode*} Hello Lua! \end{document} Additional note: you can do eval $(luarocks path) on your shell to set the package path using environment variables which the Lua interpreter will pick up automatically. That way, you do not need to iddle with the package.path yourself. Tags: luatex (Prev Q) (Next Q)
Q: Find node above and under Tags: luatex (Prev Q) (Next Q) Using a post_linebreak_filter callback, is it possible to access the nodes positioned above and under a given node? Tags: luatex (Prev Q) (Next Q) User: aphink Answer by topskip Yes. You have to do a lot of calculation, though. To ind the position of a node use node.dimensions() from the head to the node (see the examples in the reference manual, beware of glue_set, glue_sign and glue_order in the hlist node) and do the same with the lines above and below. With this you could implement a river detection algorithm :).
112
Tags: luatex (Prev Q) (Next Q)
Q: Why the luatex85 package and the luatex manual does not share the same deinitions for \pdf...? Tags: luatex (Prev Q) (Next Q) One can read in the luatex85 documentation: LuaTEX 0.85 and 0.87 contain many changes from LuaTEX 0.80 as contained in TEXLive 2014. Most notably almost all the pdfTEX extended primitves with names \pdf... have been renamed or removed. [...] The LuaTEX manual lists suitable compatibility deinitions that may be made so that documents can continue to use the old names. Mostly this package just consists of those deinitions, with minor changes in some cases. (Mostly diferent choices over the use of \protected or \edef.) Is there a reason other than ”programming taste” for those diferent choices? Tags: luatex (Prev Q) (Next Q) User: cjorssen Answer by david-carlisle The luatex85 deinitions have the advantage that they are in code and tested in more cases (used in the wild in latex) so work in more cases. Several of the deinitions were tweaked in the irst few releases. Usually it doesn’t matter too much whether you use \def or \edef or whether or not you use \protected, and whether you terminate a number using a space or by \numexpr...\relax. But if you try the emulation in enough real 113
world documents doing enough weird expansion contexts then you ind that diferent commands need diferent types of emulation. For example the case you mention in comments \def\pdffontname{\pdffeedback fontname} % (luatex85.sty) \def\pdffontname{\numexpr\pdffeedback fontname\relax}% manual In almost all cases this is going to be used as a number as in \count@=\pdffontname and either deinition will work, but pdftex allows this to expand to a number in all contexts, and does not require \the so this plain tex document \pdffontname\font \bye Is error free and typesets 1 The \numexpr version would produce ! You can't use `\numexpr' in vertical mode. \pdffontname ->\numexpr \pdffeedback fontname\relax l.5 \pdffontname \font ? unless you preixed with \the But the version without \def\pdffontname{\pdffeedback fontname} \pdffontname\font \bye does the right thing. Sometimes as in {\outputmode=1 114
}
\xdef\pdfcreationdate
{\pdffeedback creationdate}
we work harder to expand to the right thing in one expansion step as someone had a real package that did ....\expandafter\something\pdfcreationdate and \something needed to access the expanded date not just the irst level expansion of \pdffeedback creationdate, and also pdftex makes this available in both PDF and DVI modes whereas the LuaTeX feedback is only available if \outputmode is 1. It isn’t clear that these considerations to make a robust emulation that works in the wild would necessarily clarify the manual which is giving the basic idea of how you might address the name changes that happened in LuaTeX 0.85, so we never thought it necessary to push these diferences back to the LuaTeX team for the manual. Tags: luatex (Prev Q) (Next Q)
Q: In LuaTeX, how can I escape text that will be inserted in LaTeX? Tags: luatex (Prev Q) I wrote a Lua function that dumps data from a TXT ile in my LaTeX document. The problem I have right now is that the data the TXT ile is treated as LaTeX code so I need to escape special characters with backslashes and so on. Is there a way to treat the data from the TXT ile as ”plain text” without any LaTeX formatting? My hunch is that either: • There is a LaTeX macro for this. kindof like verbatim, but without displaying my text in typewriter font. • There is ready-made LuaTeX macro or function for this. Basically the opposite of \luaescapestring 115
• I’ll have to write down a special-character-escaping function by hand. Source for test.tex: \documentclass{article} \directlua{dofile("test.lua")} \begin{document} \directlua{test("test.txt")} \end{document} Source for test.lua: function test(filename) local file = io.open(filename) local s = file:read("*a") tex.print(s) file:close() end My current test.txt, which uses LaTeX formatting: Hello \$\#\%! My desired test.txt would be plain text and possibly contain any special characters: Hello $#%! Tags: luatex (Prev Q) User: hugomg Answer by topskip Use tex.print(-2,s) to get the desired output. Background: the function tex.print() accepts diferent numbers of parameters. In the simplest variant, it accepts the string that should be output. It also accepts a ”catcode table” as the irst argument (a number). There are 116
predeined catcode tables, and -2 is a catcode table where all special characters are not special anymore. Therefore tex.print(-2,"#") does not insert a ”# with catcode 6” but ”# with catcode 12”. As you all know, 12 is the catcode for ”other characters” which are harmles. Tags: luatex (Prev Q)
Fonts Skip to questions, Wiki by user stefan-kottwitz fonts is about fonts and how to use them. It deals with questions about changing family, shape and weight of fonts, but also with font packages. For choosing a font, the LaTeX Font Catalogue is a very useful resource. If you are interested in installing a new font, perhaps the font installation guide can help. Though be warned, installing fonts in LaTeX is not trivial. For using a font locally, see How do I use a particular font for a small section of text in my document?. If your question is not about a font in general but about speciic symbols, use symbols instead. For questions about font sizes, use fontsize. Specialized tags: fontenc, fontspec, opentype, truetype, metafont, fontmetrics, berry Tags for speciic ”styles”: bold, italic, small-caps, blackboard, typewriter Tags for speciic typefaces: computer-modern, latin-modern, libertine, mathpazo, minion, amssymb, xits
117
Questions Q: microtype settings for dummies Tags: fonts (Next Q), fontspec (Next Q), microtype (Next Q) More than a year ago, a friend of mine was totally excited about microtype features in LaTeX. He was talking about it quite a bit and then said to me: ”Show me your document, let me add some lines of code and it’s gonna be awesome!” What he added was this: Skip code block \usepackage[
protrusion=true, expansion=true, final, babel ]{microtype} \usepackage{fontspec} \pdfprotrudechars=2 \pdfadjustspacing=2 \newfontfeature{Microtype}{protrusion=default;expansion=default;} \directlua{fonts.protrusions.setups.default.factor=.5} \setmainfont[ Microtype, Numbers={OldStyle, Proportional}, Ligatures=TeX ]{Brill} The only thing I changed about this was the font. I use the Brill Font, but only because it contains many special characters I need for work. About the rest, I don’t have a clue what all this means. Okay, I did look into the documentations (months ago) and searched tex.sx (just now), and I learned what protrusion is and what expansion is, and what they do, but I don’t really see a diference, for -- to me -- simply (almost) every TeX result looks super, and I certainly see no real diference between Garamond, Minion, Caslon, et al., nor could I tell which I’d prefer. I am not a man of the ”iner” arts, so deciding about microtype settings and features is but a little too ”designical” for me. 118
By the way: I am using LuaLaTeX. So maybe, someone could just tell me if these settings may be alright the way they are. Brill makes a full ”Typeface User Guide” available. If you want an example of how this font looks in order to answer my question, please see this document. Tags: fonts (Next Q), fontspec (Next Q), microtype (Next Q) User: clinteastwood Answer by robert A number of answers: Firstly, microtypography is (in my book) the art of enhancing the appearance of a document while exhibiting the minimum degree of visual obtrubsion, that is, ideally, without even being recognisable: Characters with less optical weight should slightly protrude into the margin to make it appear more even, but they shouldn’t stick in your face; fonts may be distorted ever-so-slightly to allow for better line breaks, but they should not look distorted. Therefore, it is actually good that you don’t see any diference. You should, however, make sure that something does indeed happen: for protrusion, ind a hyphen at the end of a line and check whether it protrudes, as it should do, into the margin (by about half of its length), or whether it is fully contained in the text block; for expansion, check whether line breaks in a longer paragraph change when you remove the lines your colleague added. If line breaks are the same in both cases, and if hyphens don’t hang over, then protrusion and expansion are in fact not enabled at all, which would be a topic for a new question. Secondly, the microtypepackage tries to lift the burden of deciding about settings as much as possible from the user. Considering that you say yourself that you are not a man of the iner arts, I would advise to just load the microtype package without any options at all. (In your code, the protrusion and expansion options are superluous as they are enabled anyway, babel doesn’t have any efect, only final may be justiied to ensure that line breaks don’t change when adding draft as a class option.) Now for the inal point, which obviously causes the most confusion. As 119
Jörg has pointed out, you are using both the microtype package as well as lualatex’s own microtypography feature (with the latter taking precedence). You should therefore decide, and either load microtype: \usepackage[final]{microtype} \usepackage{fontspec} \setmainfont[Numbers={OldStyle, Proportional}, Ligatures=TeX ]{Brill} or use lualatex’s techniques: \usepackage{fontspec} \pdfprotrudechars=2 \pdfadjustspacing=2 \newfontfeature{Microtype}{protrusion=default;expansion=default} \directlua{fonts.protrusions.setups.default.factor=.5} \setmainfont[Microtype, Numbers={OldStyle, Proportional}, Ligatures=TeX ]{Brill} I would advise to go with the irst, as microtype’s settings are more complete and balanced IMHO (but then, I am, of course, biased ...). The second option has the advantage of better integration with luatex. Here, a factor of .5 seems reasonable (the default protrusion, especially of the hyphen, is just too much, quite obtrusive and therefore contradicting the idea of microtypography to me). Answer by fran I think that defaults are just enough for most texts, but it depend the overall text format (font size, font type, text width, margins, columns, etc.) and how sensitive are your eyes to bad spacing or the abuse of microtype methods. To test if your settings are OK irst try (with some long text) a disproportionated value in one option as stretch=1ḷḷḷ. You surely will notice a very strong stretch efect that ruins your text. All right, it was only to see the efect. 120
Now try successively with much more moderate options (100, 50, 40 ...). When you reach a value (suppose that is 30) where you cannot notice the stretch efect and the text just look good probably you have found a good value. It is time to check inally if there are some diference within you election and the default (20) or even less (For example, some people ind 10 more appropriate). In a editor as Gummi you can see the changes in the PDF in about one second, so this check is faster than it looks. It would also be advisable to look on Google to see the options that people choose. After all, the document should not be attractive to the author but to target readers. Tags: fonts (Next Q), fontspec (Next Q), microtype (Next Q)
Q: How to keep a ”rare” ligature from interfering with a ”common” ligature? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Next Q), ligatures (Next Q) In ligature-rich Opentype fonts which feature both ”common” and ”rare” ligatures, it can happen that a ”rare” ligature is applied irst to one character pair, pre-empting the use of a ”common” or ”rare” ligature that ought to be applied to the preceding or trailing character pair. (Regarding ligature terminology in Opentype fonts: Most, but not all, Opentype font families I’m familiar with classify the f-ligatures -- ff, fi, fl, ffi, ffl, and possibly also ft, fft, and a few more -- as ”common” and all others as either ”rare”/”discretionary” or ”historic”. ) Two examples of this behavior, which can arise with both XeLaTeX and LuaLaTeX: • With the font Garamond Premier Pro, the ”rare” is ligature is applied irst to words such as fish and fist, pre-empting the use of the ”common” fi ligature. 121
• With the font Junicode, the ”rare” iv and ix ligatures are applied irst to words such as five, fix, and affixed, pre-empting the use of the ”common” fi and ffi ligatures.
Without this pre-emption, the output would look like this (achieved the ”brute force” way, i.e., by inserting \kernḷpt between i and s, i and v, and i and x, respectively):
(Observe, by the way, that the brute-force suppression of the rare is ligature in the word ”ist” not only enables the common fi ligature but also the rare st ligature.) Question: Which methods may be available -- ideally on a document-wide basis -- that prevent the application of certain rare ligatures if they pre-empt other, either common or rare, ligatures? Aside: This posting is not a duplicate of the earlier posting How to suppress a ”Rare” ligature that pre-empts a ”Common” ligature for the same character pair? In the earlier question, the issue was that ”rare” and ”common” forms of a given ligature could be present for one and the same character pair (or triple). Examples of this issue are common and rare forms of ligatures for ”ft” and ”ft”. Here’s the code that gives rise to the second screenshot shown above; remove the \kernḷpt directives to generate the irst screenshot: Skip code block
122
% !TEX TS-program = lualatex \documentclass{article} \usepackage{fontspec} \begin{document} \setmainfont[Ligatures = Rare, ItalicFont = {Garamond Premier Pro Italic}] {Garamond Premier Pro} % 'is'-ligature available only in italic shape in GPP \emph{fi\kernḷptsh fi\kernḷptst} --- Garamond Premier Pro \setmainfont[Ligatures = Rare]{Junicode} fi\kernḷptve fi\kernḷptx affi\kernḷptx --- Junicode \end{document} Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Next Q), ligatures (Next Q) User: mico Answer by mico In my view, the following ligature suppression rules are needed. • In order to enable the fi ligature, suppress the is, iv, and ix ligatures if is/iv/ix is preceded by f; • In order to enable the sp and st ligatures, suppress the is ligature if is is followed by either p or t. In the jargon of Opentype fonts, fi is called a common ligature, and is, iv, and ix, as well as sp and st, are called rare or discretionary ligatures. The following solution, which works under LuaLaTeX (but not under XeLaTeX), employs the selnolig package. (Full disclosure: I’m the main author of the selnolig package.) The ligature suppression rules given above are implemented via several \nolig instructions: 123
\nolig{fis}{fi|s} \nolig{fiv}{fi|v} \nolig{fix}{fi|x} \nolig{isp}{i|sp} \nolig{ist}{i|st}
% % % % %
break break break break break
up up up up up
'is' 'iv' 'ix' 'is' 'is'
lig. lig. lig. lig. lig.
if if if if if
preceded preceded preceded followed followed
by by by by by
'f' 'f' 'f' 'p' 't'
More concisely, one would write: \nolig{fi[svx]}{fi|.} \nolig{is[pt]}{i|s.} The . character after the | is shorthand for ”any glyph”. I’m not sure if the increase in terseness and density is worth the cost of reduced (human) legibility. If one wanted to suppress the is, iv, and ix ligatures globally, while still allowing other ”rare” ligatures to be used, a single \nolig instruction would do the job: \nolig{i[svx]}{i|.} In the following code, the upright shape of Junicode is used for the iv and ix cases, and the italic shape is used of Garamond Premier Pro is used for the sp and st ligatures. The irst data row shows the outcome with selnolig being ”on”; for comparison, the second data row shows the outcome with selnolig being turned ”of”.
Skip code block % !TEX TS-program = lualatex \documentclass{article} \usepackage{fontspec,booktabs} \setmainfont[Ligatures = Rare, ItalicFeatures = {Scale = MatchLowercase}, 124
ItalicFont = {Garamond Premier Pro Italic}] {Junicode} \setsansfont[Scale=MatchLowercase]{Palatino Sans Com} \usepackage{selnolig} \nolig{fis}{fi|s} % break \nolig{fiv}{fi|v} % break \nolig{fix}{fi|x} % break \nolig{isp}{i|sp} % break \nolig{ist}{i|st} % break
up up up up up
'is' 'iv' 'ix' 'is' 'is'
lig. lig. lig. lig. lig.
if if if if if
preceded preceded preceded followed followed
by by by by by
'f' 'f' 'f' 'p' 't'
%% Or, more concisely: % \nolig{fi[svx]}{fi|.} % \nolig{is[pt]}{i|s.} \begin{document} \noindent \begin{tabular}{@{}lll@{}} \textsf{selnolig} & Junicode: iv, ix & \em Gar.\ Prem.\ Pro Italic: is\\ \midrule On & five fix affix & \em fish fissure fist gist lisp\\[ḷ.5ex] \selnoligoff % turn off selnolig's operations Off & five fix affix & \em fish fissure fist gist lisp\\ \end{tabular} \end{document} Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Next Q), ligatures (Next Q)
Q: Why does it take LuaLaTeX so long to load fonts and can I speed it up? Tags: fonts (Prev Q) (Next Q) 125
To test Mico’s upcoming selnolig package, I tried out LuaLaTeX. While the overall experience for me as a pdfLaTeX end-user was very similar, I noticed that LuaLaTeX takes a long time to load fonts. Here is a sample document that I compiled several times (lualatex foo.tex), measuring the compilation time unscientiically with a clock, deleting the auxiliary iles between each compile (latexmk -c foo.tex), and trying diferent fontspec conigurations. Skip code block \documentclass{article} % the following lines were included in: \usepackage{fontspec} % A, B, C \setmainfont{Minion Pro} % B, C \setsansfont{Myriad Pro} % C \usepackage{lipsum} \begin{document} \lipsum \end{document} My timing results turned out the same ±1s for three runs each, so I assume they are reliable: A B C C
(just fontspec) (+ Minion Pro) (+ Myriad Pro) (using XeLaTeX)
1ḷs 33s 39s 7s (just as a comparison)
Killing all processes that I knew I could safely kill, including but not limited to things you tend to have open while TeXing like an editor and a browser, brought down compilation times for coniguration C to 26s (LuaLaTeX) and 4s (XeLaTeX). (Cf. my comment to topskip) When the compilation became slow the following lines were displayed in the command line output (the log ile contains the same information with a lot more information in between):
luaotfload | Font names database loaded: C:/Users/doncherry/AppData/Local/MiKTeX/2 126
9/luatex-cache/generic/names/otfl-names.lua(load: C:/Users/doncherry/AppData/Local MiKTeX/2.9/luatex-cache/generic/fonts/otf/temp-minionpro-regular.lua)(load: C:/ Users/doncherry/AppData/Local/MiKTeX/2.9/luatex-cache/generic/fonts/otf/temp-minio pro-bold.lua)(load: C:/Users/doncherry/AppData/Local/MiKTeX/2.9/luatex-cache/gener c/fonts/otf/temp-minionpro-it.lua)(load: C:/Users/doncherry/AppData/Local/MiKTeX/2 9/luatex-cache/generic/fonts/otf/temp-minionpro-boldit.lua)(load: C:/Users/doncher ry/AppData/Local/MiKTeX/2.9/luatex-cache/generic/fonts/otf/temp-myriadpro-regula r.lua)(load: C:/Users/doncherry/AppData/Local/MiKTeX/2.9/luatex-cache/generic/font /otf/temp-myriadpro-bold.lua)(load: C:/Users/doncherry/AppData/Local/MiKTeX/2.9/lu tex-cache/generic/fonts/otf/temp-myriadpro-it.lua)(load: C:/Users/doncherry/AppDat /Local/MiKTeX/2.9/luatex-cache/generic/fonts/otf/temp-myriadpro-boldit.lua) The keywords cache and temp appearing here made me think there might be some way to store this information permanently so that it doesn’t have to be created each time? I used LuaTeX, Version beta-0.70.2-2012060719 (MiKTeX 2.9) (format=lualatex 2012.9.9) on Windows 7 64 bit. The fonts are the ones provided through Adobe Reader X, manually installed by me to C:\Windows\Fonts. So my question is: Why is the compilation with LuaLaTeX so slow and can I do anything about that? Tags: fonts (Prev Q) (Next Q) User: doncherry Answer by topskip There are several causes here, but 39 seconds seems way too much. Your log ile shows that your iles are already in the cache format (temp-fontname.lua). • fontspec loads a lot of instances during startup (\setmainfont). Each of them takes time. • memory speed/limit can have a big impact. These lua tables tend to be huge and need to be parsed each time the font loads. If the available memory is limited, even paging might be a problem (though I doubt it is nowadays). 127
Since XeTeX is so quick, I assume most of the time is spent on the second given point. Tags: fonts (Prev Q) (Next Q)
Q: Suppress certain ligatures generally Tags: fonts (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) Whether or not certain ligatures should be used (if available in a font) is a least in theory depending on the language used. For example traditional German texts would not have an ”l” ligature but would have ”ft” and also ”ch” and ”ck”. pdfTeX supports disabling selected ligutures but you will always disable the full set beginning with a certain character, so it is not possible to drop ”l” but keep ”i”, say. (I haven’t checked what pdfTeX actually does, this is my understanding from the microtype manual). From reading through the LuaTeX manual I can see that there should be (in theory) much iner control possible, but I don’t see concepts to hook into the ligature mechanism to easily provide a language-based abstraction. In my opinion a mechanism should apply at (or close to) the typesetting stage and not at during input preparation, i.e., the answer to ”Can one suppress ligatures for certain words?” addresses this too early in the game. So my questions are: • Has something for this already be programmed? • If not, how complicated would it be, given the current functionality in LuaTeX, or are there some useful interfaces for this still missing? Unfortunately this doesn’t address how to specify that for certain languages you may want to have ”ligature-kerns” i.e., some extra kerning used only in a particular language to bring some character pairs closer together than in other languages. Tags: fonts (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) 128
User: frank-mittelbach Answer by mico In addition to the question Can one (more or less) automatically suppress ligatures for certain words? (and the associated answers) that you already mention in your posting, you may also want to check out the content of the follow-up questions: Any suggestions/requests for features for a new package that allows disabling ligatures for (pre)selected words? and How to suppress the operation of a luatex-deined macro on a string if the string is part of macro or a label. Shameless self-citation alert! In the latter question in particular, I provided the rudiments of lua code to suppress the use of certain (or all) ligatures for certain words. This code could easily be made language-speciic by linking it, say, to the use of a language option set in babel. Unfortunately, my initial plans to create a stand-alone package that implements this approach have gotten stymied after I discovered that the code is too powerful: the ligature substitution (suppression, if you will) algorithm cannot be instructed not to operate on TeX macros; e.g., should there be a macro named \auflaufen, one apparently cannot instruct luatex not to replace the string ”aulaufen” with ”auf{\hspace{0pt}}laufen}, leading to unpredictably chaotic consequences. Similarly, the ligature suppression algorithm can’t be instructed not to operate on the arguments of certain macros such as \label and \ref (and, by extension, \vref, \cref etc.). For these reasons I’ve given up for now on making this a standalone package, as its applicability would always be ”experimental” at best. Hopefully, more lua programming tools and hooks will be made available so that it’ll become possible to set up the needed exceptions (e.g., don’t operate on the names of TeX macros, and don’t operate on the arguments of \label, \ref, etc) to make the approach I’ve developed usable for a general public. Answer by j.-c.-salomon OpenType fonts class ligatures as Required, Common, Contextual, Rare/Discretionary, and Historic; and there are “features” for each of these (rlig, liga, clig, dlig, & hlig), which can be enabled or disabled 129
separately via fontspec (and, presumably, ConTeXt, but I don’t know for certain). For example, in this answer, letter-spacing Fraktur requires certain ligatures (ch, ck, ſt, & tz) to be kept, but others disabled. The fontspec invocation given therefore disables the “Common” ligatures but explicitly enables the “Required” ones;—and this is the important part—the font used in that example has the ligatures classed correctly for this purpose. This is therefore only a partial answer. It only works for OpenType fonts for which this classiication of ligatures has been correctly done, and it’s not useful in the arbitrary case of (e.g.) enabling “i” but disabling “l”. (On the other hand, a font designed for German might have diferent ligature tables enabled depending on the language setting. YMMV. (On the gripping hand, see An example of changing kerning of a font in LuaLaTeX, which indicates that patches to faulty OpenType tables [presumably including ligature tables] can be included at font-load time.) Tags: fonts (Prev Q) (Next Q), ligatures (Prev Q) (Next Q)
Q: FontAwesome font not found? Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q) I’m using the latest version of MacTeX 2013 on OS X 10.8.4. All of my Tex Live packages are fully up-to-date. Tex Live also lists the fontawesome package as installed. I’m trying to use the FontAwesome font with XeLatex or LuaLatex and getting font-not-found errors. The exact message is: kpathsea: Running mktexmf FontAwesome ! I can't find file `FontAwesome'. There’s a longer traceback which I am omitting for brevity. Let me know if it’s needed to resolve this problem.
130
I have already tried running the following commands, to no avail: sudo -H mktexlsr sudo -H updmap-sys Other than the above two commands, this is a 100% new out-of-the-box installation, with no modiications whatsoever. Here’s a minimal broken example: \documentclass{article} \usepackage{fontawesome} \begin{document} \faTwitter \end{document} How can I add this missing font? Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q) User: knite Answer by michael-kropat If anyone wants to get this working with xelatex without installing the font into your system, see section 4.2 By ile name of the fontspec.pdf manual: [Loading the font by ile name] is also necessary in XeTeX when loading OpenType fonts that are present within your TEX distribution, such as /usr/local/texlive/2ḷ13/texmf-dist/fonts/opentype/public. Fonts in such locations are visible to XeTeX but cannot be loaded by font name, only ile name; LuaTEX does not have this restriction. Since fontawesome.sty simply references the font by name: % definition of \FA as a shortcut to load the Font Awesome font \newfontfamily{\FA}{FontAwesome} We have to set the default Path to locate the font, before loading fontawesome: 131
Skip code block \documentclass{article} \usepackage{fontspec}
\defaultfontfeatures{ Path = /usr/local/texlive/2ḷ13/texmf-dist/fonts/opentype/public/fontawesome/ } \usepackage{fontawesome} \begin{document} \faTwitter \end{document} You may have to change Path depending on where fontawesome is installed. Assuming you’re using TeX Live, you can ind the relative path to the font ile by running: tlmgr info --list fontawesome Output: Skip code block
package: fontawesome category: Package shortdesc: Font containing web-related icons. longdesc: The package offers access to the large number of web-related icons pr installed: Yes revision: 31ḷ2ḷ siḶes: doc: 173k, run: 1ḷ1k relocatable: Yes cat-version: 3.1.1 cat-date: 2ḷ14-ḷ4-26 2ḷ:ḷ5:48 +ḷ2ḷḷ cat-license: other-free collection: collection-fontsextra Included files, by type: run files: texmf-dist/fonts/opentype/public/fontawesome/FontAwesome.otf texmf-dist/tex/latex/fontawesome/fontawesome.sty doc files: texmf-dist/doc/latex/fontawesome/README details="Readme" 132
texmf-dist/doc/latex/fontawesome/fontawesome.pdf texmf-dist/doc/latex/fontawesome/fontawesome.tex Answer by jonathan-komar Note this answer assumes you didn’t add the TeX Live fonts to the system environment variables such that they are found when fontspec searches the system fonts. (either because you don’t know how or because it isn’t practical e.g. multi-client Version Control System situation) Assuming you are using XeLaTeX: To minimize maintenance with each sequential TeX Live release (2015,2016, etc.), I chose to add \defaultfontfeatures{Extension = .otf} rather than provide an explicit path. This is because XeLaTeX automatically loads $(kpsewhich -var-value TEXMFSYSVAR)/fonts/conf/texlive-fontconfig.conf into its path. texlive-fontconig.conf from TeX Live 2015
/usr/local/texlive/2ḷ15/texmf-dist/fonts/opentype /usr/local/texlive/2ḷ15/texmf-dist/fonts/truetype /usr/local/texlive/2ḷ15/texmf-dist/fonts/type1
With each release, this gets updated, so you don’t have any maintenance costs ;) So you only need to add the extension parameter to \newfontfamily{\FA}{FontAwesome} indirectly this way. This is of course provided that the fonts you’re using are OTF. \documentclass{article} \usepackage{fontspec} \defaultfontfeatures{Extension = .otf}% adds .otf to end of path when font loaded 133
\usepackage{fontawesome} % Relevant path loaded (TeX Live 2ḷ15 expansion): /usr/lo \begin{document} \faTwitter This is a test. \end{document} As a fun exercise to prove your understanding, you could create a document like this: Skip code block \listfiles \documentclass{article} \usepackage{fontspec} %\defaultfontfeatures{ % Extension = .otf %} %\usepackage{fontawesome} \newfontfamily\fatest{FontAwesome.otf} % Explicitly provide .otf %or %\newfontfamily\fatest[Extension=.otf]{FontAwesome} \begin{document} %\faTwitter This is a test {\fatest\char"Fḷ99} This is a test \end{document} This works because the following are equivalent: • \newfontfamily\fatest{FontAwesome.otf} • \newfontfamily\fatest[Extension=.otf]{FontAwesome} • \defaultfontfeatures{Extension = .otf}\newfontfamily{\fatest}{FontAwesome} because they all yield a platform-independent path. e.g. Unix-based: /usr/local/texlive/2ḷ15/texmf-dist/fonts/opentype/FontAwesome.otf 134
and fontspec will try to load a font by adding each preix listed in this xml ile:
ANYTHING IN HERE GETS PREFIXED to the font file
See tex.stackexchange.com/a/313886/13552 Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q)
Q: How do I get a list of all font features supported by current font Tags: fonts (Prev Q) (Next Q), opentype (Next Q) With LuaTeX, how do I get a list of OTF features supported by the current font in use printed? For example, with otinfo, I can get a list of OTF features by otfinfo -f font_file_name. Can I do anything similar with LuaTeX? The goal is to produce such a list for each font I tested. For example, I would like to have such a macro, \def\listfontfeatures{ \directlua{... some lua code to list font features to a string, say ff ...} \directlua{tex.print(ff)} } And use it like the following, Times Ten LT Std: \fontspec{Times Ten LT Std} \listfontfeatures \par Palatino LT Std: \fontspec{Palatino LT Std} \listfontfeatures \par Minion Pro: \fontspec{Minion Pro} \listfontfeatures \par Update 12/01/2017
135
Here’s just a small improvement to michal.h21’s answer, just in case anyone will be interested. fontspec_if_feature actually tests font features for the currently selected font family instead of the currently selected font. Normally this makes little diference and I only noticed this recently. For some fonts, diferent shapes have diferent features. For example, the italics may have swashes while the roman fonts lack it. Below is a few macros that I now use for font feature test. It only work for LuaTeX. some modiications to the FontName macro is needed to make it to work with XeTeX. Skip code block \ExplSyntaxOff % remove the necessity to use ~ for space \NewDocumentCommand\FontName{}{% \directlua{ local i = font.current() local f = font.getfont(i) local n = f.fullname tex.sprint(n) }% } \ExplSyntaxOn % Setup a new font family whose "n/m" shape is the current font. % Limitations: The contents of the true/false clauses will be % set in current fonts without any features selected by default, % and it will be set in a group. For myself, this was intentionally. \NewDocumentCommand\FontFeatureTF{m +m +m}{ \group_begin: \fontspec_set_family:Nnn\thisfont:{}{\FontName} \fontfamily\thisfont:\selectfont \fontspec_if_feature:nTF{#1}{#2}{#3} \group_end: } \NewDocumentCommand\FontFeatureT{m +m}{ \FontFeatureTF{#1}{#2}{\prg_do_nothing:} 136
} \NewDocumentCommand\FontFeatureF{m +m}{ \FontFeatureTF{#1}{\prg_do_nothing:}{#2} } Tags: fonts (Prev Q) (Next Q), opentype (Next Q) User: yan-zhou Answer by michal.h21 You can use fontspec function \fontspec_if_feature:nTF. It will work in both xelatex and lualatex Skip code block
\documentclass{article} \usepackage{fontspec,etoolbox,expl3} \setmainfont{Cambria} \def\fontfeatures{abvf, abvm, abvs, aalt, akhn, nalt, halt, afrc, valt, vhal, blwf % see http://en.wikipedia.org/wiki/OpenType_feature_tag_list#OpenType_Typographic_ \ExplSyntaxOn \newcommand\listfontfeatures{% \renewcommand*{\do}[1]{ \fontspec_if_feature:nTF {##1}{##1,\ }{} } \expandafter\docsvlist\expandafter{\fontfeatures} } \ExplSyntaxOff \begin{document} \listfontfeatures \end{document} Answer by khaled-hosny This should list all features in the current font, it can even be extended to list supported scripts and languages for every feature: 137
Skip code block \documentclass{article} \usepackage{fontspec} \begin{document} \newcommand\listfontfeatures{% \directlua{ local id = font.current() local font = fonts.identifiers[id] local data = font.shared.otfdata if data then local features = data.luatex.features for i,_ in next, features do for f,_ in next, features[i] do %print(f, table.serialiḶe(features[i][f])) tex.sprint(-1, f.." ") end end end }} \fontspec{TeX Gyre Pagella} \listfontfeatures \end{document} Answer by herbert On Linux it is simple and I suppose that Windows has a similiar command Skip code block voss@shania:~/.fonts/Junicode> otfinfo -f Junicode.ttf c2sc Small Capitals From Capitals calt Contextual Alternates case Case-Sensitive Forms ccmp Glyph Composition/Decomposition dlig Discretionary Ligatures fina Terminal Forms frac Fractions 138
hist hlig kern liga mark mgrk mkmk onum rtlm salt smcp ssḷ1 ssḷ2 ssḷ4 ssḷ5 ssḷ6 ssḷ7 ssḷ8 ssḷ9 ss14 ss15 ss18 ss19 ss2ḷ subs sups swsh
Historical Forms Historical Ligatures Kerning Standard Ligatures Mark Positioning Mathematical Greek Mark to Mark Positioning Oldstyle Figures
Stylistic Alternates Small Capitals Stylistic Set 1 Stylistic Set 2 Stylistic Set 4 Stylistic Set 5 Stylistic Set 6 Stylistic Set 7 Stylistic Set 8 Stylistic Set 9 Stylistic Set 14 Stylistic Set 15 Stylistic Set 18 Stylistic Set 19 Stylistic Set 2ḷ Subscript Superscript Swash
Tags: fonts (Prev Q) (Next Q), opentype (Next Q)
139
Q: Diferences regarding kerning and ligaturing when using the MacTex2013 and MacTeX2014 versions of LuaLaTeX with .ttc fonts Tags: fonts (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) This posting is a follow-up to the postings Can’t generate ligatures with LuaLaTeX under MacTeX2014 and MacTeX2015 when using certain fonts and LuaLaTeX, fontspec, .ttc fonts and kerning (Optima on Mac OS). I have a 13” MacBookPro that runs MacOSX 10.9.4. The issue is that with with the release of MacTeX2104, LuaLaTeX -- but not XeLaTeX -- has apparently ceased to perform kerning and ligaturing for certain fonts with ile extension .ttc. Consider the following MWE: Skip code block % !TEX TS-program = LuaLaTeX \documentclass{article} \usepackage{fontspec} \setmainfont{Hoefler Text} \setsansfont{Optima} \listfiles \begin{document} WA AV Test Type off fit fly office baffle \textsf{WA AV Test Type} \end{document} Running this MWE under LuaTeX 0.79.1 (part of MacTeX2014), I get
whereas running it under LuaTeX 0.76 (provided by MacTeX2013), I get
140
In the LuaTeX 0.76 output, note the sophisticated kerning and the presence of various f-ligatures. Unfortunately, both kerning and ligaturing appear to have vanished under LuaTeX 0.79.1, at least for the two particular fonts used in this MWE (Hoefler Text and Optima). In fact, it’s not just these two fonts that are experiencing problems; quite a few fonts with ile extension .ttc contained in /Library/Fonts experience this deterioration as well. Among the ones I’ve tested and have have found to exhibit the problem described above are Baskerville, Didot, and Futura Medium. In contrast, I have not (yet!) found a single font with extension .otf that experiences these problems when run with MacTeX2014-version of Lua(La)TeX. Questions: • Is there something that can/should be done to re-enable kerning and ligaturing under MacTeX2014/LuaLaTeX 0.79.1 with these .ttc fonts? • Barring an airmative answer to the preceding question, what are the step-by-step instructions for converting one or more of the afected fonts into a format (.otf?) that lets LuaLaTeX 0.79.1 performing kerning and ligaturing correctly? By ”correctly”, I mean the way that LuaLaTeX 0.76 as well as the older and current vintages of XeLaTeX manage to get these jobs done. Any software used to perform the font format conversion or adaptation should be open-source and (obviously...) be capable of being run under MacOSX. I’m willing (and able!) to provide a 200 point ”bonus” for every good answer to these two questions. Addendum, August 2015: I’ve posted a partial solution to the problem, viz., how to manually set up one or more OpenType feature iles that provide instructions for LuaLaTeX to generate the ligature substitutions, as an answer to my earlier posting on this subject, Can’t generate ligatures with LuaLaTeX under MacTeX2014 and MacTeX2015 when using certain fonts. 141
For completeness, here are the ile lists produced when running the MWE under the two diferent TeX distributions. When running MacTeX2014: Skip code block This is LuaTeX, Version beta-ḷ.79.1 (TeX Live 2ḷ14) (rev 4971) (format=lualatex 2ḷ14.7.9) 26 AUG 2ḷ14 21:ḷ7
*File List* article.cls 2ḷḷ7/1ḷ/19 v1.4h Standard LaTeX document class siḶe1ḷ.clo 2ḷḷ7/1ḷ/19 v1.4h Standard LaTeX file (siḶe option) fontspec.sty 2ḷ14/ḷ6/21 v2.4a Font selection for XeLaTeX and LuaLaTeX expl3.sty 2ḷ14/ḷ7/2ḷ v5241 L3 programming layer (loader) expl3-code.tex 2ḷ14/ḷ7/2ḷ v5241 L3 programming layer etex.sty 1998/ḷ3/26 v2.ḷ eTeX basic definition package (PEB) l3unicode-data.def 2ḷ14/ḷ6/3ḷ v5166 L3 Unicode data l3pdfmode.def 2ḷ14/ḷ7/18 v5232 L3 Experimental driver: PDF mode xparse.sty 2ḷ14/ḷ7/2ḷ v5241 L3 Experimental document command parser luaotfload.sty 2ḷ14/ḷ8/1ḷ v2.5-4 OpenType layout system luatexbase.sty 2ḷ13/ḷ5/11 vḷ.6 Resource management for the LuaTeX macro programme ifluatex.sty 2ḷ1ḷ/ḷ3/ḷ1 v1.3 Provides the ifluatex switch (HO) luatex.sty 2ḷ1ḷ/ḷ3/ḷ9 vḷ.4 LuaTeX basic definition package (HO) infwarerr.sty 2ḷ1ḷ/ḷ4/ḷ8 v1.3 Providing info/warning/error messages (HO) luatex-loader.sty 2ḷ1ḷ/ḷ3/ḷ9 vḷ.4 Lua module loader (HO) luatexbase-compat.sty 2ḷ11/ḷ5/24 vḷ.4 Compatibility tools for LuaTeX luatexbase-modutils.sty 2ḷ13/ḷ5/11 vḷ.6 Module utilities for LuaTeX luatexbase-loader.sty 2ḷ13/ḷ5/11 vḷ.6 Lua module loader for LuaTeX luatexbase-regs.sty 2ḷ11/ḷ5/24 vḷ.4 Registers allocation for LuaTeX luatexbase-attr.sty 2ḷ13/ḷ5/11 vḷ.6 Attributes allocation for LuaTeX luatexbase-cctb.sty 2ḷ13/ḷ5/11 vḷ.6 Catcodetable allocation for LuaTeX luatexbase-mcb.sty 2ḷ13/ḷ5/11 vḷ.6 Callback management for LuaTeX fontspec-patches.sty 2ḷ14/ḷ6/21 v2.4a Font selection for XeLaTeX and LuaLaTeX fontspec-luatex.sty 2ḷ14/ḷ6/21 v2.4a Font selection for XeLaTeX and LuaLaTeX fontenc.sty eu2enc.def 2ḷ1ḷ/ḷ5/27 vḷ.1h Experimental Unicode font encodings eu2lmr.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern 142
xunicode.sty 2ḷ11/ḷ9/ḷ9 vḷ.981 provides access to latin accents and many other eu2lmss.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern graphicx.sty 2ḷ14/ḷ4/25 v1.ḷg Enhanced LaTeX Graphics (DPC,SPQR) keyval.sty 2ḷ14/ḷ5/ḷ8 v1.15 key=value parser (DPC) graphics.sty 2ḷḷ9/ḷ2/ḷ5 v1.ḷo Standard LaTeX Graphics (DPC,SPQR) trig.sty 1999/ḷ3/16 v1.ḷ9 sin cos tan (DPC) graphics.cfg 2ḷ1ḷ/ḷ4/23 v1.9 graphics configuration of TeX Live pdftex.def 2ḷ11/ḷ5/27 vḷ.ḷ6d Graphics/color for pdfTeX ltxcmds.sty 2ḷ11/11/ḷ9 v1.22 LaTeX kernel commands for general use (HO) pdftexcmds.sty 2ḷ11/11/29 vḷ.2ḷ Utility functions of pdfTeX for LuaTeX (HO) ifpdf.sty 2ḷ11/ḷ1/3ḷ v2.3 Provides the ifpdf switch (HO) fontspec.cfg t3cmr.fd 2ḷḷ1/12/31 TIPA font definitions supp-pdf.mkii epstopdf-base.sty 2ḷ1ḷ/ḷ2/ḷ9 v2.5 Base part for package epstopdf grfext.sty 2ḷ1ḷ/ḷ8/19 v1.1 Manage graphics extensions (HO) kvdefinekeys.sty 2ḷ11/ḷ4/ḷ7 v1.3 Define keys (HO) kvoptions.sty 2ḷ11/ḷ6/3ḷ v3.11 Key value format for package options (HO) kvsetkeys.sty 2ḷ12/ḷ4/25 v1.16 Key value parser (HO) etexcmds.sty 2ḷ11/ḷ2/16 v1.5 Avoid name clashes with e-TeX commands (HO) epstopdf-sys.cfg 2ḷ1ḷ/ḷ7/13 v1.3 Configuration of (r)epstopdf for TeX Live *********** When running MacTeX2013: Skip code block This is LuaTeX, Version beta-ḷ.76.ḷ-2ḷ13ḷ61817 (rev 4627) (format=lualatex 2ḷ14.3.31) 26 AUG 2ḷ14 21:ḷ9 *File List* article.cls siḶe1ḷ.clo fontspec.sty expl3.sty l3names.sty l3bootstrap.sty luatex.sty infwarerr.sty
2ḷḷ7/1ḷ/19 2ḷḷ7/1ḷ/19 2ḷ13/ḷ5/2ḷ 2ḷ14/ḷ1/ḷ7 2ḷ14/ḷ1/ḷ4 2ḷ14/ḷ1/ḷ4 2ḷ1ḷ/ḷ3/ḷ9 2ḷ1ḷ/ḷ4/ḷ8
v1.4h Standard LaTeX document class v1.4h Standard LaTeX file (siḶe option) v2.3c Font selection for XeLaTeX and LuaLaTeX v4646 L3 Experimental code bundle wrapper v464ḷ L3 Namespace for primitives v464ḷ L3 Experimental bootstrap code vḷ.4 LuaTeX basic definition package (HO) v1.3 Providing info/warning/error messages (HO) 143
ifluatex.sty 2ḷ1ḷ/ḷ3/ḷ1 v1.3 Provides the ifluatex switch (HO) etex.sty 1998/ḷ3/26 v2.ḷ eTeX basic definition package (PEB) luatex-loader.sty 2ḷ1ḷ/ḷ3/ḷ9 vḷ.4 Lua module loader (HO) pdftexcmds.sty 2ḷ11/11/29 vḷ.2ḷ Utility functions of pdfTeX for LuaTeX (HO) ltxcmds.sty 2ḷ11/11/ḷ9 v1.22 LaTeX kernel commands for general use (HO) ifpdf.sty 2ḷ11/ḷ1/3ḷ v2.3 Provides the ifpdf switch (HO) l3basics.sty 2ḷ14/ḷ1/ḷ4 v4642 L3 Basic definitions l3expan.sty 2ḷ14/ḷ1/ḷ4 v4642 L3 Argument expansion l3tl.sty 2ḷ13/12/27 v4625 L3 Token lists l3seq.sty 2ḷ13/12/14 v4623 L3 Sequences and stacks l3int.sty 2ḷ13/ḷ8/ḷ2 v4583 L3 Integers l3quark.sty 2ḷ13/12/14 v4623 L3 Quarks l3prg.sty 2ḷ14/ḷ1/ḷ4 v4642 L3 Control structures l3clist.sty 2ḷ13/ḷ7/28 v4581 L3 Comma separated lists l3token.sty 2ḷ13/ḷ8/25 v4587 L3 Experimental token manipulation l3prop.sty 2ḷ13/12/14 v4623 L3 Property lists l3msg.sty 2ḷ13/ḷ7/28 v4581 L3 Messages l3file.sty 2ḷ13/1ḷ/13 v4596 L3 File and I/O operations l3skip.sty 2ḷ13/ḷ7/28 v4581 L3 Dimensions and skips l3keys.sty 2ḷ13/12/ḷ8 v4614 L3 Experimental key-value interfaces l3fp.sty 2ḷ14/ḷ1/ḷ4 v4642 L3 Floating points l3box.sty 2ḷ13/ḷ7/28 v4581 L3 Experimental boxes l3coffins.sty 2ḷ13/12/14 v4624 L3 Coffin code layer l3color.sty 2ḷ12/ḷ8/29 v4156 L3 Experimental color support l3luatex.sty 2ḷ13/ḷ7/28 v4581 L3 Experimental LuaTeX-specific functions l3candidates.sty 2ḷ14/ḷ1/ḷ6 v4643 L3 Experimental additions to l3kernel xparse.sty 2ḷ13/12/31 v4634 L3 Experimental document command parser luaotfload.sty 2ḷ14/ḷ2/ḷ5 v2.4-3 OpenType layout system luatexbase.sty 2ḷ13/ḷ5/11 vḷ.6 Resource management for the LuaTeX macro programme luatexbase-compat.sty 2ḷ11/ḷ5/24 vḷ.4 Compatibility tools for LuaTeX luatexbase-modutils.sty 2ḷ13/ḷ5/11 vḷ.6 Module utilities for LuaTeX luatexbase-loader.sty 2ḷ13/ḷ5/11 vḷ.6 Lua module loader for LuaTeX luatexbase-regs.sty 2ḷ11/ḷ5/24 vḷ.4 Registers allocation for LuaTeX luatexbase-attr.sty 2ḷ13/ḷ5/11 vḷ.6 Attributes allocation for LuaTeX luatexbase-cctb.sty 2ḷ13/ḷ5/11 vḷ.6 Catcodetable allocation for LuaTeX luatexbase-mcb.sty 2ḷ13/ḷ5/11 vḷ.6 Callback management for LuaTeX fontspec-patches.sty 2ḷ13/ḷ5/2ḷ v2.3c Font selection for XeLaTeX and LuaLaTeX fixltx2e.sty 2ḷḷ6/ḷ9/13 v1.1m fixes to LaTeX 144
fontspec-luatex.sty 2ḷ13/ḷ5/2ḷ v2.3c Font selection for XeLaTeX and LuaLaTeX fontenc.sty eu2enc.def 2ḷ1ḷ/ḷ5/27 vḷ.1h Experimental Unicode font encodings eu2lmr.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern xunicode.sty 2ḷ11/ḷ9/ḷ9 vḷ.981 provides access to latin accents and many other eu2lmss.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern graphicx.sty 1999/ḷ2/16 v1.ḷf Enhanced LaTeX Graphics (DPC,SPQR) keyval.sty 1999/ḷ3/16 v1.13 key=value parser (DPC) graphics.sty 2ḷḷ9/ḷ2/ḷ5 v1.ḷo Standard LaTeX Graphics (DPC,SPQR) trig.sty 1999/ḷ3/16 v1.ḷ9 sin cos tan (DPC) graphics.cfg 2ḷ1ḷ/ḷ4/23 v1.9 graphics configuration of TeX Live pdftex.def 2ḷ11/ḷ5/27 vḷ.ḷ6d Graphics/color for pdfTeX fontspec.cfg t3cmr.fd 2ḷḷ1/12/31 TIPA font definitions supp-pdf.mkii epstopdf-base.sty 2ḷ1ḷ/ḷ2/ḷ9 v2.5 Base part for package epstopdf grfext.sty 2ḷ1ḷ/ḷ8/19 v1.1 Manage graphics extensions (HO) kvdefinekeys.sty 2ḷ11/ḷ4/ḷ7 v1.3 Define keys (HO) kvoptions.sty 2ḷ11/ḷ6/3ḷ v3.11 Key value format for package options (HO) kvsetkeys.sty 2ḷ12/ḷ4/25 v1.16 Key value parser (HO) etexcmds.sty 2ḷ11/ḷ2/16 v1.5 Avoid name clashes with e-TeX commands (HO) epstopdf-sys.cfg 2ḷ1ḷ/ḷ7/13 v1.3 Configuration of (r)epstopdf for TeX Live *********** Tags: fonts (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) User: mico Answer by khaled-hosny Whether the font is packaged as TTC or not is irrelevant to the issue here. Most (all?) Latin fonts shipped by Apple use AAT layout tables, not OpenType. Older versions of LuaTeX partially supported AAT rather accidentally; as egreg pointed out in his comment above, FontForge that is used as base for the LuaTeX font loader maps some AAT features to equivalent OpenType ones, and that is why simple features like kerning or ligaturing appear to work. However, that code was hardly tested, caused crashes with many Mac OS X system fonts (that packages like luaotfload had to blacklist) and further145
more it outright broke fonts that include both AAT and OpenType layout table (many fonts from SIL, like Charis, do) as the mapped AAT features were duplicating the real OpenType ones, which confused the OpenType processor. Supporting AAT layout table for third parties is rather hard (due to incomplete or outright missing documentation) and I’m not aware if any working implementation other than Apple’s, but LuaTeX can’t use it as it wants to remain system independent. XeTeX of course uses Apple API to get AAT support, but at the price of producing diferent output when an AAT font is used between Mac OS X and other platforms (and it also meant we had to do quite some changes to port XeTeX to 64-bit Mac OS X systems when Apple deprecated the API that XeTeX was originally using and did not port it to its 64-bit architecture). So the solution is to avoid AAT fonts and use OpenType ones, or write your own feature iles to emulate the missing OpenType support. Tags: fonts (Prev Q) (Next Q), ligatures (Prev Q) (Next Q)
Q: How to enable ligatures for emdash/endash in LuaTeX ? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) I cannot switch on ligatures for emdash (---) and endash (--) in LuaLaTeX. Here is my test ile: Skip code block % !Mode:: "TeX:UTF-8" \documentclass{article} \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \setmainfont{Cambria} \setsansfont[Mapping=tex-text]{Calibri} \usepackage{ifluatex,ifxetex} 146
\begin{document} \ifxetex This is XeTeX \else\ifluatex This is LuaTeX \fi\fi \section{rmfamily} \rmfamily \begin{enumerate} \item by ligatures \verb|| \item «double quotes» by symbols \verb|«double quotes»| \item en--dash by ligatures \verb|en--dash| \item em---dash by ligatures \verb|em---dash| \item en–dash by symbol \verb|en–dash| \item em—dash by symbol \verb|em—dash| \end{enumerate} \section{sffamily} \sffamily \begin{enumerate} \item by ligatures \verb|| \item «double quotes» by symbols \verb|«double quotes»| \item en--dash by ligatures \verb|en--dash| \item em---dash by ligatures \verb|em---dash| \item en–dash by symbol \verb|en–dash| \item em—dash by symbol \verb|em—dash| \end{enumerate} \end{document} When it is compiled with XeLaTeX, \sffamily loaded with the obsolete option Mapping=tex-text \setsansfont[Mapping=tex-text]{Calibri} activates the ligatures --- and --, but in LuaTeX this options seemed to be equivalent to Ligatures=TeX, so that I don’t know how to restore default 147
(in LaTeX) behavior of these two ligatures. Is it bug or a feature, introduced in a recent version of the fontspec package? I’ve checked that the ligatures still work as expected under LuaTeX if I don’t set OTF fonts by the commands \setmainfont{Cambria} \setsansfont[Mapping=tex-text]{Calibri} Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) User: igor-kotelnikov Answer by ulrike-ischer The TeX-ligatures in luatex are not a font property, they are ”faked” features implemented in the font loader code. The problem could be the bug in the luaotload/context code reported some month ago: http://archive.contextgarden.net/message/20110310.181448.288f2a38.en. html I think it has been corrected in context but I doubt that the new code has already found its way in luaotload. You can test the font directly (to exclude a fontspec problem and to test the both modes) Skip code block \documentclass{article} \usepackage{luaotfload} \begin{document} \font\test="Calibri:mode=node;+tlig" \font\testb="Calibri:mode=base;+tlig" \test -- --- abc \testb -- --- abc 148
\end{document} Answer by alan-munn This is partially a property of the font, and not a problem with fontspec. XeLaTeX and LuaTeX implement the ligature replacement with diferent mechanisms. XeLaTeX uses a teckit mapping ile, whereas LuaTeX uses luaotfload to do the conversion. The latter is somehow dependent on how the font actually implements certain characters. Changing the font to Linux Libertine O, for example, causes the ligatures to appear correctly. Update As noted by Ulrike Fischer, you can change this on a font-by-font basis for fonts that don’t work by specifying a value for the Renderer key when you load the font. There are two possible (relevant) values for this key in LuaLaTeX: Full (default) and Basic. Loading certain fonts with the Basic renderer will allow the ligatures. This will not work for all fonts, however. For more discussion, see the following thread on comp.text.tex: en-dash and em-dash in luatex. The following modiied version of your document shows how the problem doesn’t arise with Linux Libertine O, and how it can be ixed for Cambria. (Calibri) works the same way. As Ulrike notes in her answer, a more robust ix will propagate to luaotfload at some point in the future. Skip code block % !Mode:: "TeX:UTF-8" \documentclass{article} \usepackage{fontspec} \defaultfontfeatures{Ligatures={TeX}} \setmainfont{Cambria} \setsansfont{Calibri} \usepackage{ifluatex,ifxetex} \usepackage{expl3} \begin{document}
149
\ifxetex This is XeTeX \else\ifluatex This is LuaTeX \fi\fi \section{Cambria} \begin{enumerate} \item by ligatures \verb|| \item «double quotes» by symbols \verb|«double quotes»| \item en--dash by ligatures \verb|en--dash| \item em---dash by ligatures \verb|em---dash| \item en–dash by symbol \verb|en–dash| \item em—dash by symbol \verb|em—dash| \end{enumerate} \section{Linux Libertine O} \fontspec{Linux Libertine O}\selectfont \begin{enumerate} \item by ligatures \verb|| \item «double quotes» by symbols \verb|«double quotes»| \item en--dash by ligatures \verb|en--dash| \item em---dash by ligatures \verb|em---dash| \item en–dash by symbol \verb|en–dash| \item em—dash by symbol \verb|em—dash| \end{enumerate} \section{Cambria + Basic Renderer} \fontspec[Renderer=Basic]{Cambria}\selectfont \begin{enumerate} \item by ligatures \verb|| \item «double quotes» by symbols \verb|«double quotes»| \item en--dash by ligatures \verb|en--dash| \item em---dash by ligatures \verb|em---dash| \item en–dash by symbol \verb|en–dash| \item em—dash by symbol \verb|em—dash| 150
\end{enumerate} \end{document} Answer by keks-dose I can’t compete with the level of discussion between Ulrike and Alan. But thanks to the link provided by Alan, I found out how to get an en-dash with another of those Win-fonts: Corbel. I ran into the same problem two weeks ago and thanks to your help I know now how to handle it: \documentclass{article} \usepackage{fontspec} \setmainfont[Renderer=Basic,Ligatures=TeX]{Corbel} \begin{document} -- --- abc \end{document} I get the en-dash and the em-dash this way. Or did I miss something and this way to get dashes is obsolete? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), ligatures (Prev Q) (Next Q)
Q: Specify diferent fonts for bold and italic with fontspec Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) The main font I use for my LuaLaTeX document lacks bold and italic variants. I’d like to specify a diferent font for those variants using the fontspec package. Initially what I had in my preamble was this: \usepackage{fontspec} \setmainfont{GFS Elpis} 151
\setmonofont{Courier} and in order to use a diferent font for italics and bold, say Minion Pro, I tried putting the following line in the preamble just after the above shown lines: \fontspec[BoldFont={Minion Pro}, ItalicFont={Minion Pro}]{GFS Elpis} Unfortunately it doesn’t seem to have any efect. Italics and bold passages in the document remain in upright font. Could someone please help me with this issue? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: christosc Answer by topskip You need to be speciic if you declare the bold/italic/bold italic shapes, because fontspec does not automatically expand the font name: Skip code block \documentclass{article} \usepackage{fontspec} \setmainfont[ BoldFont={Minion Pro Bold}, ItalicFont={Minion Pro Italic}, BoldItalicFont={Minion Pro Bold Italic} ]{Linux Libertine O} \begin{document} normal \emph{italic}, \textbf{bold} and \textbf{\emph{bold italic}}. \end{document} Works ine with Minion/Linux Libertine O.
152
Edit: changed to \setmainfont instead of \fontspec so that there is a correct and good example. Thanks Ulrike for pointing this out. Answer by ulrike-ischer Don’t use \fontspec. It is a command to change locally to another font and its settings will be lost if you switch fonts. If you want to setup the overall document font you should use the optional argument of \setmainfont. \documentclass{article} \usepackage{fontspec} \setmainfont[ItalicFont=Arial]{Linux Libertine O} \begin{document} abc {\itshape abc} \end{document} Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
Q: How do I get a list of all available fonts for luaotload? Tags: fonts (Prev Q) (Next Q) luaotload uses an internal database that gets updated with mkluatexfontdb. So it knows about a lot of fonts installed on my computer. How can I query this database? Something like luatexfontdb --list-fonts-on-my-computer-that-are-in-your-database ? Tags: fonts (Prev Q) (Next Q) User: topskip
153
Answer by ulrike-ischer You could open the database in your editor. It is called otl-names.lua and should be in one of your texmf-trees in \luatex-cache\generic\names. It is also not very diicult to make lists based on otl-names.lua. E.g. Old version (Texlive 2013?) Skip code block \documentclass{article} \usepackage{luacode,luaotfload} \begin{document} \begin{luacode} myfonts=dofile(fonts.names.path.localdir..'/otfl-names.lua') for i,v in ipairs(myfonts.mappings) do tex.print(-2, v.familyname) tex.print(', ') tex.print(-2, v.fontname) tex.print('\\par') end \end{luacode} \end{document} Edit in may 2013: With a newer luaotload (as the one in TL2013 (pretest) one should exchange the myfonts line by this one as the name of the database as changed: myfonts=dofile(fonts.names.path.path) Edit for Texlive 2014 I tried again in TL 2014 (june 2014). Now the names ile is in a .luc and the access name has changed again. I also added some ”if exist code” to avoid error if a table entry doesn’t exist for a font: 154
Skip code block \documentclass{article} \usepackage{luacode} \usepackage{luaotfload} \begin{document} \begin{luacode} myfonts=dofile(fonts.names.path.index.luc) tex.sprint(fonts.names.path.index.luc) ---[[ for i,v in ipairs(myfonts.mappings) do if v.familyname then tex.print('\\par') tex.print(-2, v.familyname) end if v.fontname then tex.print(', ') tex.print(-2, v.fontname) end tex.print('\\par') end --]] \end{luacode} \end{document} Edit for TeXlive 2015 / MiKTeX in july 2015 The code do get the names ile has to be adapted again. Now this here seems to work. Skip code block \documentclass{article} \usepackage{luacode} 155
\usepackage{luaotfload} \begin{document} \begin{luacode} myfonts=dofile(config.luaotfload.paths.index_path_luc) tex.sprint(config.luaotfload.paths.index_path_luc) ---[[ for i,v in ipairs(myfonts.mappings) do if v.familyname then tex.print('\\par') tex.print(-2, v.familyname) end if v.fontname then tex.print(', ') tex.print(-2, v.fontname) end tex.print('\\par') end --]] \end{luacode} \end{document} Answer by topskip Based on Ulrike’s answer: Because I don’t want to create a TeX document every time I need the font list, here is a simple script for that: Skip code block #!/usr/bin/env texlua kpse.set_program_name("listluatexfonts") cachefile
= kpse.expand_var("$TEXMFVAR") 156
.. "/luatex-cache/generic/names/otfl-na
fontlist = dofile(cachefile) assert(fontlist,"Could not load font name database") local tmp = {} for _,font in ipairs(fontlist.mappings) do tmp[#tmp + 1] = font.fontname end table.sort(tmp) for _,fontname in ipairs(tmp) do print(fontname) end call it with ./listluatexfonts
Update: Replace the cachefile name for TexLive 2014: cachefile
= kpse.expand_var("$TEXMFVAR")
.. "/luatex-cache/generic/names/luaotfl
This one worked for me. Tags: fonts (Prev Q) (Next Q)
Q: Lualatex: Font table with examples Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) I wanted to create a table of the fonts on my machine with short examples of each. So I got the function below and tried to modify to print the font in its typeface. (LuaLatex) 157
Skip code block \documentclass[1ḷpt,a4paper]{article} \usepackage{fontspec} \usepackage{luacode,luaotfload,luatextra} \usepackage[margin=18mm]{geometry} \begin{document} \begin{luacode} myfonts=dofile(fonts.names.path.localdir..'/otfl-names.lua') --tex.print('\\begin{verbatim}\\par') for i,v in ipairs(myfonts.mappings) do --tex.print('\\fontspec{' .. v.fontname .. '}') % most recent attempt --tex.print('\\setmainfont{' .. v.fontname .. '}') % first attempt tex.print(v.familyname..', '..v.fontname..'\\par') end --tex.print('\\endverbatim}\\par') \end{luacode} \end{document} Both of the commented lines does not work (fontspec or setmainfont). How should go about doing this with lua? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: louis Answer by leo-liu This improves Caramdir’s answer to make the table easier to read: Skip code block \documentclass{article} \usepackage{fontspec} \setmainfont{Latin Modern Mono Light} \usepackage{luacode} 158
\usepackage[margin=18mm]{geometry} \parindent=ḷpt \usepackage{longtable,makecell} \renewcommand\arraystretch{2}
\begin{document} \begin{luacode} myfonts=dofile(fonts.names.path.localdir..'/otfl-names.lua') -- TeX Live 2ḷ12 or e -- myfonts=dofile(fonts.names.path.path) -- TeX Live 2ḷ13 teststring = "Sphinx of black quartḶ, judge my vow." tex.print("\\begin{longtable}{ll}\\hline") for i,v in ipairs(myfonts.mappings) do -- Stop early for testing purposes. if i > 2ḷ then break end tex.print('\\makecell[l]{\\bfseries') tex.print(-2, v.familyname) tex.print('\\\\[-1ex] \\scriptsiḶe') tex.print(-2, v.fontname) tex.print('} & \\LARGE\\fontspec{' .. v.fontname .. '}') tex.print(-2, teststring) tex.print('\\\\ \\hline') end tex.print("\\end{longtable}") \end{luacode} \end{document}
159
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
Q: How to properly install and use a new font with LuaLaTeX? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) I have problems trying to get new fonts to work when compiling with LuaLaTeX. I’m working on Mac and use TexShop (with the MacTeX package). It goes like this: I downloaded for example the Cardo font; I installed the Cardo font (it now appears in the Font Book); I tried to compile a simple text that goes like this: Skip code block \documentclass[11pt]{book} 160
\usepackage[no-math]{fontspec} \usepackage[frenchb]{babel} \usepackage{amsmath} \usepackage{unicode-math} \setmainfont{Cardo} \begin{document} Hello world! \end{document} After compiling I obtained the following error message: Skip code block
luaotfload | Font names database loaded: /Users/juan/Library/texlive/2ḷ12/texmf -var/luatex-cache/generic/names/otfl-names.lua luaotfload | Updating the font names database: luaotfload | Scanning TEXMF fonts... luaotfload | Scanning OS fonts... luaotfload | Font names database saved: %s : /Users/juan/Library/texlive/2ḷ12/texmf-var/luatex-cache/generic/names/otfl-names !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ./testBembo.tex:6: fontspec error: "font-not-found" ! ! The font "Cardo" cannot be found. ! ! See the fontspec documentation for further information. ! ! For immediate help type H . !............................................... l.6 \setmainfont{Cardo} ? Process aborted • then I checked the otfl-names.lua and Cardo was missing; 161
• I then added the Cardo folder font to this folder: /usr/local/texlive/2ḷ12/texmf-dist/fonts/ • I executed the mkluatexfontdb -vvv command in a terminal; • I re-checked the otfl-names.lua and Cardo was inally there; So I naturally tried to compile the text again after resetting the computer and (as you might guess by now) I obtained (again!) the following error message: Skip code block luaotfload | Font names database loaded: /Users/juan/Library/texlive/2ḷ12/texmf -var/luatex-cache/generic/names/otfl-names.lua luaotfload | Updating the font names database: luaotfload | Scanning TEXMF fonts... luaotfload | Scanning OS fonts... luaotfload | Font names database saved: %s : /Users/juan/Library/texlive/2ḷ12/texmf-var/luatex-cache/generic/names/otfl-na mes.lua !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ./testBembo.tex:6: fontspec error: "font-not-found" ! ! The font "Cardo" cannot be found. ! ! See the fontspec documentation for further information. ! ! For immediate help type H . !............................................... l.6 \setmainfont{Cardo} ? Process aborted The thing is driving me crazy! I migrated to LuaLaTeX only because I was promised to be able to use almost any font with it. What am I doing wrong? 162
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: jrojasqu Answer by void-pointer I came across the same problem as you when I irst tried to use XeTeX. If you want fontspec to automatically ind the path to the font and load it for you, then you need to have the font installed as a system font. On OS X, you can do this by navigating to Font Book -> Preferences and changing the ”Default Installation Location” from ”User” to ”Computer”. This should allow you to use the \setmainfont{} command without any prior coniguration. For Linux distributions, you should consult the documentation for your desktop environment. If you do not want to modify the set of system fonts, or you are working on a project in which you would like all of your resources to exist in one directory structure, you can specify the path to the font explicitly. For example, if you install Cardo as a user font (which is the default behavior on OS X), the font iles should be copied to ~/Library/Fonts. Assuming that regular version of the font is supplied in a ile called Cardo.ttf, you can load the font as follows. (Be sure to change to your username). \setmainfont[ Path Extension Ligatures ]{Cardo}
= /Users//Library/Fonts/, = .ttf, = TeX
If you have bold, italic, and bold-italic variants of your font, you can use them by adding a few extra lines. In this example, I’m using a font called Crimson, which is supplied in the OTF format. The regular version of the font is called Crimson-Roman.otf; the bold, italic, and bold-italic variants are called Crimson-Bold.otf, Crimson-Italic.otf, and Crimson-BoldItalic.otf, respectively. \setmainfont[ Path Extension Ligatures
= /Users//Library/Fonts/, = .otf, = TeX, 163
BoldFont = Crimson-Bold, ItalicFont = Crimson-Italic, BoldItalicFont = Crimson-BoldItalic ]{Crimson-Roman} All of this information is available in the fontspec manual. Edit Since you still seem to be experiencing problems using other fonts with LuaTeX, I thought that posting my procedure step-by-step might help in identifying the problem. My texlive distribution is obtained from MacPorts; running lualatex -v returns the following: This is LuaTeX, Version beta-ḷ.7ḷ.2-2ḷ13ḷ11221 (TeX Live 2ḷ12/MacPorts 2ḷ12_5). • I downloaded the Baskerville font from this link. The font iles are called LibreBaskerville-Regular.otf, LibreBaskerville-Bold.otf, and LibreBaskerville-Italic.otf. • I installed the fonts as user fonts by double clicking the font iles in Finder. • I created a ile called baskerville.tex with the following contents. (I replaced my username by ). Skip code block \documentclass[11pt,a4paper]{article} \usepackage{fontspec} \setmainfont[ Path = /Users//Library/Fonts/, Extension = .otf, Ligatures = TeX, BoldFont = LibreBaskerville-Bold, ItalicFont = LibreBaskerville-Italic ]{LibreBaskerville-Regular} \begin{document} This is a test. \end{document} • I compiled the ile with the command lualatex baskerville.tex. 164
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
Q: Conlict between microtype, LuaLaTeX, and otf fonts when typesetting material in small-caps Tags: fonts (Prev Q) (Next Q), microtype (Prev Q) (Next Q) I’m using the microtype package (microtype beta 2.5 build ḷ8) to modify my document and I’d like to retain its functionality across all font shapes with the exception of small-caps (\scshape). How do I do this? I’m asking this because microtype is not preserving the (\scshape) of section names listed in my table of contents whenever I use otf fonts (adobe caslon pro, adobe garamond pro, etc) that are loaded via fontspec. Instead, it’s changing them to regular text. Whenever I don’t load micro type, the text reverts to scshape. I’d like to keep the (\scshape) of the section names intact while using microtype without having to abandon use of the aforementioned otf fonts.
Here is what my toc looks like when microtype is enabled:
Here it is with microtype disabled: I’m building my documents with Lualatex to facilitate loading of otf fonts and their usage with microtype. I notice this issue doesn’t occur when using normal latex fonts. Here is my code: Skip code block \documentclass[dotinlabels,nohyper]{tufte-book} 165
\usepackage{amsthm} \usepackage{amsmath} \usepackage{amssymb} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{Minion Pro} \usepackage{fancyhdr} \pagestyle{fancy} \usepackage[unicode=true, bookmarks=true,bookmarksnumbered=true,bookmarksopen=false, breaklinks=false,pdfborder={ḷ ḷ 1},backref=false,colorlinks=true] {hyperref} \usepackage{titletoc} \usepackage{titlesec} \usepackage{tocloft} % If you do not load micro type below, small caps are preserved. \usepackage[activate={true,nocompatibility},final,tracking=true,factor=11ḷḷ,stretc \hypersetup{linktocpage=true} \setcounter{secnumdepth}{1} \setcounter{tocdepth}{2} %formatting for toc entries \renewcommand{\cftsecfont}{\large\scshape\MakeLowercase} \renewcommand{\cfttoctitlefont}{\scshape\MakeUppercase} \renewcommand{\cftsecdotsep}{\cftdotsep} \renewcommand{\cftsecpagefont}{\scshape} % \titleformat{\section}{\titlerule\vspace{.8ex}% \Large\bfseries}{\Large\thesection.}{.5em}{} \renewcommand{\sectionmark}[1]{% \markboth{}{\thesection.\ #1}} \newcommand{\hsp}{\hspace{2ḷpt}} 166
%Chapter title Formatting \definecolor{gray75}{gray}{ḷ.75} \titlespacing{\chapter}{ḷpt}{*ḷ}{*5} \titleformat{\chapter}[hang]{\Huge\bfseries}{\thechapter\hsp\textcolor{gray75}{|}\ % \begin{document} \fancyhf{} % clear all header/footer fields \fancyhead[RO]{\scshape\normalsiḶe\MakeLowercase{\rightmark}} \fancyfoot[R]{\thepage} \tableofcontents{} \chapter{Preliminaries} \section{Mathematical Induction} text goes here... \newpage{} test \newpage{} test \end{document} Tags: fonts (Prev Q) (Next Q), microtype (Prev Q) (Next Q) User: black-milk Answer by robert The reason why the small caps font is changed to the regular one is that microtype’s tracking feature does not work lawlessly with lualatex. At the moment, the only ix (apart from not using tracking altogether) is to load the font with Renderer=Basic instead of (the default) Full: \setmainfont[Ligatures=TeX,Renderer=Basic]{Minion Pro} Unfortunately, this may have side efects, as switching to the basic renderer means losing some OpenType features. In the case of small caps, for example, less kerning pairs will be deined. While more problems may still be uncovered, there is also the one or the other bug with Renderer=Full. 167
[I was going to suggest to restrict this to the small caps font: \setmainfont[Ligatures=TeX,SmallCapsFeatures={Renderer=Basic}]{Minion Pro} but this does not work.] Answer by qrrbrbirlbel The microtype package ofers to deine sets of fonts. There is even a predeined set name called smallcaps, though it is not of much use as one can apparently only include sets for activated micro-typography. Excluding small caps would be the same like including everything else. Code Skip code block \documentclass{article} \usepackage[ protrusion=false, expansion=false, ]{microtype} \DeclareMicrotypeSet{non Small Caps}{shape={it*,up*,sl*}} \microtypesetup{activate=non Small Caps} \usepackage{lipsum} \begin{document} {\scshape\lipsum} {\itshape\lipsum} \end{document} But as I understand it, this would overwrite every default settings made by microtype; therefore it seems easier to just patch \scshape. Code \documentclass{article} \usepackage{microtype} 168
\expandafter\def\expandafter\scshape\expandafter{\scshape\microtypesetup{activate= \usepackage{lipsum} \begin{document} {\scshape\lipsum} {\itshape\lipsum} \end{document} Answer by mico I’m not sure which aspects of microtype you wish to disable when it comes to dealing with small-caps fonts. I’ll assume that it’s the tracking (inter-letter and inter-word spacing) that you want to disable. (Somehow, I don’t think you want to disable character protrusion optimization for small-caps glyphs.) To disable microtype’s action with regard to tracking for small-caps characters only, you could issue the following command (after loading the microtype package, obviously): \SetTracking[spacing = {ḷ,ḷ,ḷ}]{encoding=*,shape=sc}{ḷ} Tags: fonts (Prev Q) (Next Q), microtype (Prev Q) (Next Q)
Q: How to set-up LuaTeX, Microtype, with Minion Pro, Myriad Pro Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), microtype (Prev Q) (Next Q) Since recently I am using LuaLaTeX with the most recent beta version of Microtype, along with the fonts Minion Pro and Myriad Pro. In the manual of Microtype it says: Currently, this package provides protrusion settings for [...] Adobe Garamond (cf. table 3 on page 21)
169
Currently, I just include the fonts like this (with some other font deinitions for headings etc. settings left out here): \defaultfontfeatures{Ligatures=TeX, Scale=MatchLowercase}
\setmainfont[SmallCapsFeatures={LetterSpace=6}, Numbers={Proportional,OldStyle}]{M \setsansfont[LetterSpace=3, Numbers={Proportional,OldStyle}]{Myriad Pro} But this way I still get the following message from Microtype: Package microtype Warning: Loading generic settings for font family `MinionPro' How can I load the correct settings? Also, is there a way to avoid all these warnings I get for fonts that are not supported, and Microtype just loads the generic settings? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), microtype (Prev Q) (Next Q) User: ingo Answer by topskip With the current microtype from TeXlive 2011, you can do the following: Skip code block \documentclass{article} \usepackage{fontspec,microtype} \defaultfontfeatures{Ligatures=TeX, Scale=MatchLowercase}
\setmainfont[SmallCapsFeatures={LetterSpace=6}, Numbers={Proportional,OldStyle}]{M \setsansfont[LetterSpace=3, Numbers={Proportional,OldStyle}]{Myriad Pro} \SetProtrusion [ name = min-eu2 ] { encoding = {EU2}, family = MinionPro {
}
170
}
{,} = { - = {
,5ḷḷ}, ,5ḷḷ}
\begin{document} \hsiḶe 3in
When, while the lovely valley teems with vapour around me, and the meridian sun st foliage of my trees, and but a few stray gleams steal into the inner sanctuary, I trickling stream; and, as I lie close to the earth, a thousand unknown plants are \end{document} LuaTeX with fontspec uses EU2 encoding internally, so all you need to do is the regular microtype setup with encoding EU2. Answer by alabay Hm, I also use Minion Pro and Myriad Pro … this way: Skip code block
\documentclass[12pt]{scrbook} \usepackage[english]{babel} \usepackage{blindtext} \pdfprotrudechars=2 \pdfadjustspacing=2 \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \newfontfeature{Microtype}{protrusion=default;expansion=default;} \setmainfont[Microtype,Ligatures=TeX,Numbers=OldStyle]{Minion Pro} \setsansfont[Microtype,Scale=MatchLowercase,Ligatures=TeX,Numbers=OldStyle]{Myriad \begin{document} \blindtext[5] \end{document} Than TeX Live 2010 and now 2011.
171
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), microtype (Prev Q) (Next Q)
Q: LuaLaTeX: use or don’t use classical font packages? Tags: fonts (Prev Q) (Next Q), packages (Next Q) In the lualatex-doc I am reading under ”switching from LaTeX to LuaLaTeX”: 1. Don’t load inputenc, just encode your source in UTF-8. 2. Don’t load fontenc, but load fontspec. 3. Don’t use any package that changes the fonts, but use fontspec’s commands instead. Consider the following example: % !Mode:: "TeX:UTF-8" \documentclass[paper=a4]{scrartcl} \usepackage{fontspec} \usepackage{lmodern} \renewcommand{\familydefault}{\sfdefault} \begin{document} Hellöö! ßßäü \end{document} It compiles perfectly ine and looks as desired with lualatex from TeXLive 2012. It is in agreement with points (1) and (2) from the list above. However, I am wondering: • Doesn’t \usepackage{lmodern} violate point (3) from above? If yes: • What would be the LuaLaTeX way of using lmodern? • Why does it work then? In which cases is this expected to break? I just took lmodern as an example, the question applies to all such kinds of font packages.
172
Tags: fonts (Prev Q) (Next Q), packages (Next Q) User: jan-philip-gehrcke Answer by ulrike-ischer Your example works as there exists suitable font deinitions iles for the ”lmr” and the ”lmss” families for the EU2 font encoding in the euenc package. (If you look in the log-ile you will see that a eu2lmss.fd is loaded). If you would replace lmodern by e.g. times it would no longer work. You would see in the log-ile a warning: LaTeX Font Info:
No file EU2phv.fd. on input line 14.
LaTeX Font Warning: Font shape `EU2/phv/m/n' undefined (Font) using `EU2/lmr/m/n' instead on input line 14. And the document wouldn’t use helvet but the fallback lmr. To be able to use the helvet font you would have to switch the fontencoding to an encoding for which font deinitions for helvet exists, e.g. T1-encoding. But with this encoding you will no longer be able to input non-ascii-chars directly: \documentclass[paper=a4]{scrartcl} \usepackage{fontspec} \usepackage{times} \renewcommand{\familydefault}{\sfdefault} \begin{document} ¼½¾ Hellöö! ßßäü % this gives helvet, but some chars are wrong: \fontencoding{T1}\selectfont ¼½¾ Hellöö! ßßäü \ss \end{document} Tags: fonts (Prev Q) (Next Q), packages (Next Q)
173
Q: TeX accents do not seem to work with fontspec and xe/lua/latex Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q) I am using Minion Pro as mainfont and it does not have in its glyph table the character U+1E47 Latin small letter with dot below which I need only once in my document. Rather than change to another font, I thought that I would generate it using \d{n}. I give below a minimal ile illustrating the problem: \documentclass{minimal} \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \setmainfont{Minion Pro} % Comment out optionally \begin{document} U+1E47 Latin small letter with dot below: \d{n} U+ḷ1ḷ1 Latin small letter a with macron: \={a} \end{document} I do not get the desired letter n with dot below although the a with macron exists in the font and is available. Commenting out \usepackage{fontspec} gives the desired output with CMR as default font. The behaviour is the same with xelatex and lualatex although the former indicates the missing letter with a crossed box. I believe that with the Ligatures=TeX setting, I should be able to get missing letters using TeX accents. I do not think I need to load the xunicode package as it is already loaded by fontspec. Can someone tell me what a I am doing wrong, please? Thank you. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q) User: chandra 174
Answer by egreg The ”standard way” would be to say \UndeclareUTFcomposite[\UTFencname]{x1E47}{\d}{n} in order to use the combining character instead of the missing character at U+1E47, but unfortunately Minion Pro has nothing in slot U+0323 (COMBINING DOT BELOW). We need to go the hard way: write the following in the preamble \UndeclareUTFcomposite[\UTFencname]{x1E47}{\d}{n} \makeatletter \renewcommand{\d}[1] {\hmode@bgroup \o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}\egroup} \makeatother so that you’ll use the standard deinition for \d. If other characters of that sort are needed, look in xunicode.sty for their deinition; it starts with \DeclareUTFcomposite, it’s suicient to copy the line in your preamble and to change \Declare... into \Undeclare.... Let’s look also at the ”line below”, which is again missing in Minion Pro. Here’s a similar way to cope with the case, using the macron (U+00AF) for emulating the line below: Skip code block \documentclass{article} \usepackage{fontspec,newunicodechar} \defaultfontfeatures{Ligatures=TeX} \setmainfont{Minion Pro} % Comment out optionally \UndeclareUTFcomposite[\UTFencname]{x1E47}{\d}{n} \UndeclareUTFcomposite[\UTFencname]{x1E49}{\b}{n} \makeatletter \let\d\relax \DeclareRobustCommand{\d}[1] {\hmode@bgroup 175
\o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}\egroup} \let\b\relax \DeclareRobustCommand{\b}[1] {\hmode@bgroup\o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-3ex}% \vbox to.2ex{\hbox{\char"AF}\vss}\hidewidth}\egroup} \makeatother \newunicodechar{ }{\d{n}} \newunicodechar{ṉ}{\b{n}} \begin{document} U+1E47 Latin small letter n with dot below: \d{n} U+1E49 Latin small letter n with line below: \b{n}ṉ U+ḷ1ḷ1 Latin small letter a with macron: \={a}ā \end{document} It’s perhaps better to declare \b and \d as robust commands. Moreover, with newunicodechar we can also input the characters directly.
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q)
Q: Bembo, Bembo Book or Garamond Premier Pro? And how to exploit all their features with LuaLaTex? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
176
I am allowed to use one of these fonts (or the three of them if I want) to edit a document. Here is the list of the Bembo fonts I have : Skip code block Bembo-Bold.otf Bembo-BoldExpert.otf Bembo-BoldItalic.otf Bembo-BoldItalicExpert.otf Bembo-BoldItalicOsF.otf Bembo-BoldOsF.otf Bembo-Expert.otf Bembo-ExtraBold.otf Bembo-ExtraBoldExpert.otf Bembo-ExtraBoldItalic.otf Bembo-ExtraBoldItalicExpert.otf Bembo-ExtraBoldItalicOsF.otf
Bembo-ExtraBoldOsF.otf Bembo-Italic.otf Bembo-ItalicExpert.otf Bembo-ItalicOsF.otf Bembo-SC.otf Bembo-Semibold.otf Bembo-SemiboldExpert.otf Bembo-SemiboldItalic.otf Bembo-SemiboldItalicExpert.otf Bembo-SemiboldItalicOsF.otf Bembo-SemiboldOsF.otf Bembo.otf
here is the list of the Bembo Book fonts I have : BemboBookMTPro-Bold.otf BemboBookMTPro-BoldIt.otf
BemboBookMTPro-Italic.otf BemboBookMTPro-Regular.otf
and here is the list of the Garamond Premier Pro fonts available : Skip code block GaramondPremrPro-Bd.otf GaramondPremrPro-BdCapt.otf GaramondPremrPro-BdDisp.otf GaramondPremrPro-BdIt.otf GaramondPremrPro-BdItCapt.otf GaramondPremrPro-BdItDisp.otf GaramondPremrPro-BdItSubh.otf GaramondPremrPro-BdSubh.otf GaramondPremrPro-Capt.otf GaramondPremrPro-Disp.otf GaramondPremrPro-It.otf GaramondPremrPro-ItCapt.otf GaramondPremrPro-ItDisp.otf
GaramondPremrPro-MedCapt.otf GaramondPremrPro-MedDisp.otf GaramondPremrPro-MedIt.otf GaramondPremrPro-MedItCapt.otf GaramondPremrPro-MedItDisp.otf GaramondPremrPro-MedItSubh.otf GaramondPremrPro-MedSubh.otf GaramondPremrPro-Smbd.otf GaramondPremrPro-SmbdCapt.otf GaramondPremrPro-SmbdDisp.otf GaramondPremrPro-SmbdIt.otf GaramondPremrPro-SmbdItCapt.otf GaramondPremrPro-SmbdItDisp.otf 177
GaramondPremrPro-ItSubh.otf GaramondPremrPro-LtDisp.otf GaramondPremrPro-LtItDisp.otf GaramondPremrPro-Med.otf
GaramondPremrPro-SmbdItSubh.otf GaramondPremrPro-SmbdSubh.otf GaramondPremrPro-Subh.otf GaramondPremrPro.otf
Choosing between them is becoming nearly impossible to me because I really like the three of them. So to make my choice, I decided to base it on technicalities. • First question : Which one would you recommend and why? • Second question : Which one do you believe is the most comfortable for reading when printed? • Third question : Which one ofers the the biggest amount of exploitable features when using LuaLaTex? • Fourth question : How do I exploit all of their features (swashes, small caps, small italic caps, glyphs I can’t type with the keyboard, etc.)? I ask the fourth question because my university bought them all and they cost an arm & a leg, so I really intend to get the most out of them. For example I can’t get the swashes to work (or any other feature in fact). For swashes I tried this : Skip code block \documentclass{article} \usepackage{fontspec} \newopentypefeature{Contextuals}{NoAlternate}{-calt} \defaultfontfeatures{Kerning=Uppercase,Mapping=tex-text,} \setmainfont{Garamond Premier Pro} \begin{document} Quad Qed \addfontfeatures{Contextuals=NoAlternate} Quad Qed \end{document} But the swash does not work. I also tried to set the options like this : \documentclass{article} \usepackage{fontspec} \setmainfont[Contextuals=Swash]{Garamond Premier Pro} 178
\begin{document} Quad Qed \end{document} But then the console says this : ************************************************* * fontspec warning: "icu-feature-not-exist-in-font" * * OpenType feature 'Contextuals=Swash' (+cswh) not available for font * 'GaramondPremrPro' with script 'Latin' and language 'Default'. ************************************************* Is there something wrong with this font? Also, my document contains a big amount of equations, do you have any advice on the math fonts? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: jrojasqu Answer by nils-l There’s a technical and an aesthetical side to most of the questions you’re asking: 1.1) For your purposes, a tech report with maths etc.: none of them. You’ll have trouble inding math supplements that go well with any of these fonts. Yes, there are packages that set out to provide math symbols supposed to look good with »Garamond«, but the huge number fonts with »Garamond« in their names vary considerably in terms of their look. A package providing TeX support for a Garamond will most likely be geared towards one of the free Garamond versions, such as URW’s (an early digitization of the Stempel version from the 1920s). It may be, but IMHO will rather not be suitable for AGPPro ...which is a highly idiosyncratic rendition of C. Garamond’s typefaces. What I suggest, from a technical/practical perspective is: choose a font that comes with suicient math support out of the box, or one where you’re certain that suitable high-quality math support is available (such as MinionPro).
179
1.2) The three fonts you list are designed as rather faithful renditions of faces created 500 years ago (unlike e.g. TNR, which doesn’t have one speciic model). They’re explicitly citing the aesthetics of that time -- this is the case with the two (very diferent) Bembo renditions, and it is even more the case with AGPPro. Both AGPPro and BBook are, in addition, designed to reproduce the look of letterpress printing to some degree. None of this is a problem per se, but typography is not art for art’s sake, but rather halfway between an art and a craft IMHO. So you have to make sure your typeface choice is appropriate within the context of your product. Questions like: »what’s the message brought across by a document that tries to look like it’s been printed in 1540?«, or »what kind of aesthetics is my audience used to?« are the ones you should consider here. 2) The old (1990s) digital renditions of Bembo were infamous for their thin and anemic look in print. They were horrible digitizations of horrible phototype-izations of a typeface that was, and remains, sublime in hot metal. These digitizations were shunned by most decent typographers, which I understand perfectly well, having compared books set in Bembo from the three typographic eras side by side. Now all this was supposed to change with Bembo Book. It was advertised as a font that would bring back the look of that hot metal legend. It didn’t. It’s about eight (?) years ago IIRC, that MT released BBook, but it still hasn’t caught on. Yes, the strokes are sturdier, the thinness is gone, but like its predecessors it lacks any sparkle, and, unsuprisingly, comes nowhere near the original that it’s (and has to be) measured by. So that’s a strict NO for your Bembo Std, and an if-need-be for Bembo Book, in terms of aesthetics and reading comfort. AGPPro... one guideline (I’m not saying ›rule‹) is that typography is best when it’s invisible. Reading comfort is reduced the more the typography (e.g., the typeface) is making the reader aware of its presence. The more you deviate from what readers are used to, or what just »works«, the more this will be the case. Try setting your text ragged-left (!), for example. For typefaces, the equivalent of a left rag would be choosing a particularly idiosyncratic typeface, i.e. one that draws attention to itself (which is what it all boils down to). Within the range of text faces currently on the market, AGPPro is clearly on the idiosyncratic side of the spectrum (which is why it’s hardly being used for serious book production). 180
The other side of that spectrum we might call »inconspicuous« ones and put, say, TNR or Minion there. The degree of perceived idiosyncracy will of course be dependent on what your readers are used to. Computer Modern will look odd to people from the humanities, but will make maths people feel at home. In Germany, Stempel Garamond (unlike AGPPro) is one of the most inconspicuous choices simply because literally generations have been socialized with it in school, while, conversely, New Century Schoolbook (and classicist or »didone« or »modern« faces in general) look weird to most people over here. I see I need to keep it more concise: 3) what features do you need? I suggest you consider that question irst, and then see what fonts might ofer it. At the moment, I’m having trouble understanding the role you have in mind for, say, swashes in a tech report ;) 4) as you’re already using LuaLaTeX, you already got the most appropriate tool available in the TeX world. ConTeXt might be another good choice. But choose wisely, as jumping ships between the two might be diicult once your project has taken up speed. Swashes -- I’m afraid you’re trying to do something that, by its very nature, won’t work. A swash is usually deined as a calligraphy-style embellishment, mainly for capital letters. The »calligraphy« part is important here, as it’s the italic cuts of a typeface that make reference to handwriting. And it is, traditionally, only here that you’ll ind swashes. So unless AGPPro’s specimen sheet says otherwise, there’ll be no upright swashes in AGPPro. This, on the other hand, works ine (in LuaLaTeX): \documentclass{article} \usepackage{fontspec} \setmainfont[Contextuals=Swash]{Minion Pro} \begin{document} \itshape Quad Qed Jawohl \end{document} Answer by silke Which one would you recommend and why? 181
This is, of course, a matter of taste. Personally I would use Garamond Premier Pro. Which one do you believe is the most comfortable for reading when printed? This is, again, a matter of taste. I think both Bembo Book and Garamond Premier Pro will do ine. They are both well-crafted fonts. Which one ofers the the biggest amount of exploitable features when using LuaLaTex? I’ve made a quick comparison of all the OpenType features the fonts support: Skip code block Feat. Bembo BemboBk aalt x x c2sc x x calt x x case x x cpsp x dlig x x dnom x x fina x frac x x hist x kern x x x liga x x lnum x x numr x x onum x x ordn x x ornm x pnum x x salt x x sinf x siḶe x smcp x x ssḷ1 x ssḷ2 x
Garamond PP Description Access All Alternates Small Capitals From Capitals Contextual Alternates Case-Sensitive Forms Capital Spacing Discretionary Ligatures Denominators Terminal Forms Fractions Historical Forms Kerning Standard Ligatures Lining Figures Numerators Oldstyle Figures Ordinals Ornaments Proportional Figures Stylistic Alternates Scientific Inferiors Optical SiḶe Small Capitals Stylistic Set 1 Stylistic Set 2 182
ssḷ3 sups tnum Ḷero
x x
x x x x
Stylistic Set 3 Superscript Tabular Figures Slashed Zero
It’s clear Garamond Premier Pro has more OpenType features you can use than either Bembo or Bembo Book. (this is based on the fonts I have here, the features present in your fonts may difer) How do I exploit all of their features (swashes, small caps, small italic caps, glyphs I can’t type with the keyboard, etc.)? You can exploit all OpenType features with fontspec. I really recommend reading the documentation. A MWE with the most important bits: Skip code block \documentclass{article} \usepackage{fontspec} \defaultfontfeatures { Ligatures = TeX , Numbers = OldStyle , %Path = /Path/To/Fonts , % Use when fonts aren't installed on your system Extension = .otf } \setmainfont [ UprightFont = * , ItalicFont = *-It , BoldFont = *-Bd , BoldItalicFont = *-BdIt ] {GaramondPremrPro}
\newcommand*\specimen{The Quick brown fox jumps over the sleaḶy dog, ḷ123456789.\\ \begin{document} \noindent 183
\specimen \textit{\specimen} \textsc{\specimen} \textsc{\itshape\specimen} \textbf{\specimen} \textbf{\itshape\specimen} \textbf{\scshape\specimen} \textbf{\scshape\itshape\specimen} \noindent Alternates, etc: \\ {\addfontfeature{Style = Historic}\specimen} {\addfontfeature{Style = Alternate}\specimen} \end{document} Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
Q: Can’t generate ligatures with LuaLaTeX under MacTeX2014 and MacTeX2015 when using certain fonts Tags: fonts (Prev Q) (Next Q), opentype (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) (Remark: This question was posted originally when the big news, TeX-wise, was the impending transition from TeXLive2013 to TeXLive2014. Since the issue identiied in this posting persists in TeXLive2015, I’ve chosen to update the posting’s title accordingly.) Consider the following MWE: % !TEX TS-program = lualatex \documentclass{article} \listfiles \usepackage{fontspec} \setmainfont[Ligatures={Common,Rare}]{Hoefler Text} \begin{document} ff fi fl ffi ffl fj ct st 184
\end{document} When compiling this program on my system (MacOSX 10.9.2, MacTeX2013, luatex 0.76.0) under LuaLaTeX, I get the expected result, i.e., all ligatures are generated correctly:
However, if I switch to TeXLive2014 (currently in advanced beta), which employs luatex 0.79.1, no ligatures are created:
This problem doesn’t arise under TeXLive2014 if I (i) compile the MWE under XeLaTeX instead of LuaLaTeX or (ii) use a diferent font, say, Adobe Garamond Pro, Garamond Premier Pro, or Latin Modern Roman. (Of course, the latter font doesn’t feature ligatures for fj, ct, and st, but ligatures are generated for f, i, l, i, and l.) Is there a setting that needs to be tweaked to enable ligatures when using Hoefler Text? For completeness, here are the iles used by the LuaLaTeX/TeXLive2014 run: Skip code block LuaTeX, Version beta-ḷ.79.1 (TeX Live 2ḷ14/dev) (rev 4971) *File List* article.cls siḶe1ḷ.clo fontspec.sty expl3.sty
2ḷḷ7/1ḷ/19 2ḷḷ7/1ḷ/19 2ḷ13/ḷ5/2ḷ 2ḷ14/ḷ1/ḷ7
v1.4h v1.4h v2.3c v4646 185
(format=lualatex 2ḷ14.
Standard LaTeX document class Standard LaTeX file (siḶe option) Font selection for XeLaTeX and LuaLaTeX L3 Experimental code bundle wrapper
l3names.sty 2ḷ14/ḷ1/ḷ4 v464ḷ L3 Namespace for primitives l3bootstrap.sty 2ḷ14/ḷ1/ḷ4 v464ḷ L3 Experimental bootstrap code luatex.sty 2ḷ1ḷ/ḷ3/ḷ9 vḷ.4 LuaTeX basic definition package (HO) infwarerr.sty 2ḷ1ḷ/ḷ4/ḷ8 v1.3 Providing info/warning/error messages (HO) ifluatex.sty 2ḷ1ḷ/ḷ3/ḷ1 v1.3 Provides the ifluatex switch (HO) etex.sty 1998/ḷ3/26 v2.ḷ eTeX basic definition package (PEB) luatex-loader.sty 2ḷ1ḷ/ḷ3/ḷ9 vḷ.4 Lua module loader (HO) pdftexcmds.sty 2ḷ11/11/29 vḷ.2ḷ Utility functions of pdfTeX for LuaTeX (HO) ltxcmds.sty 2ḷ11/11/ḷ9 v1.22 LaTeX kernel commands for general use (HO) ifpdf.sty 2ḷ11/ḷ1/3ḷ v2.3 Provides the ifpdf switch (HO) l3basics.sty 2ḷ14/ḷ1/ḷ4 v4642 L3 Basic definitions l3expan.sty 2ḷ14/ḷ1/ḷ4 v4642 L3 Argument expansion l3tl.sty 2ḷ13/12/27 v4625 L3 Token lists l3seq.sty 2ḷ13/12/14 v4623 L3 Sequences and stacks l3int.sty 2ḷ13/ḷ8/ḷ2 v4583 L3 Integers l3quark.sty 2ḷ13/12/14 v4623 L3 Quarks l3prg.sty 2ḷ14/ḷ1/ḷ4 v4642 L3 Control structures l3clist.sty 2ḷ13/ḷ7/28 v4581 L3 Comma separated lists l3token.sty 2ḷ13/ḷ8/25 v4587 L3 Experimental token manipulation l3prop.sty 2ḷ13/12/14 v4623 L3 Property lists l3msg.sty 2ḷ13/ḷ7/28 v4581 L3 Messages l3file.sty 2ḷ13/1ḷ/13 v4596 L3 File and I/O operations l3skip.sty 2ḷ13/ḷ7/28 v4581 L3 Dimensions and skips l3keys.sty 2ḷ13/12/ḷ8 v4614 L3 Experimental key-value interfaces l3fp.sty 2ḷ14/ḷ1/ḷ4 v4642 L3 Floating points l3box.sty 2ḷ13/ḷ7/28 v4581 L3 Experimental boxes l3coffins.sty 2ḷ13/12/14 v4624 L3 Coffin code layer l3color.sty 2ḷ12/ḷ8/29 v4156 L3 Experimental color support l3luatex.sty 2ḷ13/ḷ7/28 v4581 L3 Experimental LuaTeX-specific functions l3candidates.sty 2ḷ14/ḷ1/ḷ6 v4643 L3 Experimental additions to l3kernel xparse.sty 2ḷ13/12/31 v4634 L3 Experimental document command parser luaotfload.sty 2ḷ14/ḷ2/ḷ5 v2.4-3 OpenType layout system luatexbase.sty 2ḷ13/ḷ5/11 vḷ.6 Resource management for the LuaTeX macro progr ammer luatexbase-compat.sty 2ḷ11/ḷ5/24 vḷ.4 Compatibility tools for LuaTeX luatexbase-modutils.sty 2ḷ13/ḷ5/11 vḷ.6 Module utilities for LuaTeX luatexbase-loader.sty 2ḷ13/ḷ5/11 vḷ.6 Lua module loader for LuaTeX luatexbase-regs.sty 2ḷ11/ḷ5/24 vḷ.4 Registers allocation for LuaTeX 186
luatexbase-attr.sty luatexbase-cctb.sty luatexbase-mcb.sty fontspec-patches.sty
2ḷ13/ḷ5/11 vḷ.6 Attributes allocation for LuaTeX 2ḷ13/ḷ5/11 vḷ.6 Catcodetable allocation for LuaTeX 2ḷ13/ḷ5/11 vḷ.6 Callback management for LuaTeX 2ḷ13/ḷ5/2ḷ v2.3c Font selection for XeLaTeX and LuaLaTeX
fixltx2e.sty 2ḷḷ6/ḷ9/13 v1.1m fixes to LaTeX fontspec-luatex.sty 2ḷ13/ḷ5/2ḷ v2.3c Font selection for XeLaTeX and LuaLaTeX fontenc.sty eu2enc.def 2ḷ1ḷ/ḷ5/27 vḷ.1h Experimental Unicode font encodings eu2lmr.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern xunicode.sty 2ḷ11/ḷ9/ḷ9 vḷ.981 provides access to latin accents and many othe r characters in Unicode lower plane eu2lmss.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern graphicx.sty 1999/ḷ2/16 v1.ḷf Enhanced LaTeX Graphics (DPC,SPQR) keyval.sty 1999/ḷ3/16 v1.13 key=value parser (DPC) graphics.sty 2ḷḷ9/ḷ2/ḷ5 v1.ḷo Standard LaTeX Graphics (DPC,SPQR) trig.sty 1999/ḷ3/16 v1.ḷ9 sin cos tan (DPC) graphics.cfg 2ḷ1ḷ/ḷ4/23 v1.9 graphics configuration of TeX Live pdftex.def 2ḷ11/ḷ5/27 vḷ.ḷ6d Graphics/color for pdfTeX fontspec.cfg t3cmr.fd 2ḷḷ1/12/31 TIPA font definitions supp-pdf.mkii epstopdf-base.sty 2ḷ1ḷ/ḷ2/ḷ9 v2.5 Base part for package epstopdf grfext.sty 2ḷ1ḷ/ḷ8/19 v1.1 Manage graphics extensions (HO) kvdefinekeys.sty 2ḷ11/ḷ4/ḷ7 v1.3 Define keys (HO) kvoptions.sty 2ḷ11/ḷ6/3ḷ v3.11 Key value format for package options (HO) kvsetkeys.sty 2ḷ12/ḷ4/25 v1.16 Key value parser (HO) etexcmds.sty 2ḷ11/ḷ2/16 v1.5 Avoid name clashes with e-TeX commands (HO) epstopdf-sys.cfg 2ḷ1ḷ/ḷ7/13 v1.3 Configuration of (r)epstopdf for TeX Live *********** Tags: fonts (Prev Q) (Next Q), opentype (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) User: mico Answer by mico 187
With the advent of MacTeX2014 and continuing in MacTeX2015 -- and likely to persist into the indeinite future :-( -- Lua(La)TeX can no longer directly access certain font features, such as ligatures, if the font is a system font whose ligature-related properties are AAT-encoded and not OpenTypeencoded. Hoefler Text, Didot, and Baskerville are three such fonts. (In contrast, XeLaTeX continues to be able to access ligature-related features directly.) By setting up one more or ”feature iles” that spell out which ligature substitutions should be performed, it is possible to restore ligatures when working with version of LuaLaTeX more recent than version 0.77. The output of the code shown below has the following characteristics: the irst row is generated before the feature ile is loaded; note that it’s lacking ligatures even though the option Ligatures=Common option was speciied when the font (Hoefler Text in this case) was loaded via a \setmainfont statement. The second row, which is generated after the feature ile is loaded via an \addfontfeature instruction, contains all the expected ligatures. Aside: (i) The example uses the filecontents package to be self-contained. In practice, all one needs to do is to create the feature ile ”addligs.fea” once and store it in a directory that’s searched by the TeX distribution. (ii) The feature ile shown here features (pun intended...) quite a few ligature substitutions, since Hoefler Text features lots and lots of ligatures. For other, less feature-rich, fonts, the ”standard ive” ligatures -- ff, fi, fl, ffi, and ffl -- may be all that you need to take of.
Skip code block % !TEX TS-program = lualatex \RequirePackage{filecontents} \begin{filecontents*}{addligs.fea} languagesystem DFLT dflt; languagesystem latn dflt; # Ligatures 188
feature liga { sub f f by f_f; sub f i by f_i; sub f j by f_j; sub f k by f_k; sub f l by f_l; sub f f i by f_f_i; sub f f l by f_f_l; sub s t by s_t; sub c t by c_t; } liga; \end{filecontents*} \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=Common]{Hoefler Text} \newcommand\wordlist{off fit fjord Kafka fly office baffle stop act} \begin{document} \wordlist \addfontfeature{FeatureFile=addligs.fea} \wordlist \end{document} Addendum: Here’s a slightly more sophisticated example, which uses two diferent feature iles depending on whether the font face is upright or italic. It makes use of the ability of fontspec to specify diferent features for Upright, Bold, Italic, and BoldItalic font faces. The separate treatment of the italic and non-italic cases is necessary because Hoefler Text features additional ligatures (esp. for ”sp” and ”Th”) just for the italic font faces.
189
Skip code block % !TEX TS-program = lualatex \RequirePackage{filecontents} \begin{filecontents*}{AddligsHoeflerUpright.fea} languagesystem DFLT dflt; languagesystem latn dflt; # Ligatures feature liga { sub f b by f_b; sub f f by f_f; sub f h by f_h; sub f i by f_i; sub f j by f_j; sub f k by f_k; sub f l by f_l; sub f f b by f_f_b; sub f f h by f_f_h; 190
sub f f i by f_f_i; sub f f k by f_f_k; sub f f l by f_f_l; sub c t by c_t; sub s t by s_t; } liga; \end{filecontents*} \begin{filecontents*}{AddligsHoeflerItalic.fea} languagesystem DFLT dflt; languagesystem latn dflt; # Ligatures feature liga { sub f b by f_b; sub f f by f_f; sub f h by f_h; sub f i by f_i; sub f j by f_j; sub f k by f_k; sub f l by f_l; sub f f b by f_f_b; sub f f h by f_f_h; sub f f i by f_f_i; sub f f k by f_f_k; sub f f l by f_f_l; sub c t by c_t; sub s t by s_t; sub s p by s_p; sub T h by T_h; sub a s by a_s; } liga; \end{filecontents*} \documentclass{article} \usepackage{fontspec} \setmainfont{Hoefler Text}[ Ligatures = {Common,Rare}, ItalicFont = Hoefler Text Italic, 191
BoldFont BoldItalicFont
= Hoefler Text Black, = Hoefler Text Black Italic]
\newcommand\words{fb ff fh fi fj fk fl ffb ffh ffk ffl ct st, sp Th} \begin{document} ligatures missing: \words\par \textbf{\words}\par \textit{\words}\par \textbf{\textit{\words}} \addfontfeature{% UprightFeatures BoldFeatures ItalicFeatures BoldItalicFeatures
= = = =
{FeatureFile=AddligsHoeflerUpright.fea}, {FeatureFile=AddligsHoeflerUpright.fea}, {FeatureFile=AddligsHoeflerItalic.fea}, {FeatureFile=AddligsHoeflerItalic.fea}}
\medskip ligatures restored/activated: \words\par \textbf{\words}\par \textit{\words}\par \textbf{\textit{\words}} \end{document} Tags: fonts (Prev Q) (Next Q), opentype (Prev Q) (Next Q), ligatures (Prev Q) (Next Q)
192
Q: How to use OpenType fonts with plain-LuaTeX? Tags: fonts (Prev Q) (Next Q), opentype (Prev Q) (Next Q) Is it possible to have OpenType fonts with LuaTeX using the plain format? I have tried: \font\test="texgyrepagellaregular"\test test\bye but I get ! Font \test=texgyrepagellaregular not loadable: metric data not found or bad.. mtxrun --script fonts --list --all --pattern=pagella shows the above font name when I followed the instructions at http://wiki. contextgarden.net/Fonts_in_LuaTeX. But on actually using the fonts, the page switches to speaking of ConTeXt instead of LuaTeX, which leaves me to wonder if it is possible to use OT-fonts with plain? UPDATE Even though this now works ine for fonts which are located in my home directory (OSX Lion, BasicTeX2012, luatex-plain-format constructed as instructed below), I am unable to use fonts which are located in the system directories. So while the above example works (with texgyrepagellaregular), as the mtxrun-script shows its location as ~/Library/Fonts, the following doesn’t: \font\test="minionproregular" presumably because mtxrun shows its location as /Library/Fonts (the same issue seems to be with fonts inside /System/Library/Fonts). Now, I added to my ~/.Ḷshrc: export OSFONTDIR=/System/Library/Fonts:/Library/Fonts:$OSFONTDIR after which I was able to update the fonts database with mtxrun --script fonts --reload (following these instructions), and indeed now the mtxrun listing does show all of the fonts. It’s just that luatex-plain doesn’t see them. 193
How can I make luatex-plain see the fonts mtxrun sees? Tags: fonts (Prev Q) (Next Q), opentype (Prev Q) (Next Q) User: morbusg Answer by egreg LuaTeX has the same font support as pdfTeX, natively. However, using the right Lua code one can extend the font support, which is precisely the job of luaotfload.lua. The luaotfload.sty ile can be loaded also with the Plain LuaTeX format. Try compiling the following ile with luatex (note that ”Linux Libertine O” is in my system fonts, I used it just by way of example. Skip code block \input luaotfload.sty \font\x="texgyrepagella-regular.otf" \font\liber="Linux Libertine O/I=5:+smcp" at 12pt \x abcdef \liber abcdef \bye
194
Tags: fonts (Prev Q) (Next Q), opentype (Prev Q) (Next Q)
Q: Problem while compiling friggeri CV template with: ’ fontspec error: ”font-not-found”’ Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) I have somme problem while I’m trying to compile template CV from: http:// www.latextemplates.com/template/friggeri-resume-cv . I have install texlivefull package on Ubuntu and tryied to compiled this template with command: lualatex cv_10.tex And I get: Skip code block : /home/lgadawski/.texmf-var/luatex-cache/generic/names/otfl-names.lua !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! fontspec error: "font-not-found" 195
! ! The font "HelveticaNeue" cannot be found. ! ! See the fontspec documentation for further information. ! ! For immediate help type H . !............................................... l.53 \newfontfamily\bodyfont[]{Helvetica Neue} I have also trying to do this on Windows with MikTex with same result. I spent some hours but couldn’t ind explanation why is that and how could I properly compile it and built my own CV. Regards! Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: lukasz-gadawski Answer by nils-l That template assumes you have obtained a license for Linotype’s Neue Helvetica (€45 to €1500) and properly installed the font. If you haven’t, try {Arial}, {TeX Gyre Heros}, or whatever you like, instead. Locate friggeri-cv.cls and modify the following lines (l. 53--58): \newfontfamily\bodyfont[]{Helvetica Neue} \newfontfamily\thinfont[]{Helvetica Neue UltraLight} \newfontfamily\headingfont[]{Helvetica Neue Condensed Bold} \defaultfontfeatures{Mapping=tex-text} \setmainfont[Mapping=tex-text, Color=textcolor]{Helvetica Neue Light} Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
196
Q: How does fontspec select fonts ”by name”? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q) When loading a font by name, what is the search mechanism being used? How is the matching done? (It’s marked TODO in the documentation) I have many problems, for example: a ”Hoeler Text Engraved” font is replacing the default ”Hoeler Text” with bold \fontspec{Hoefler Text} \textbf{...}. Some of its metadata in fontforge: PS Names Family Name: Hoefler Text Weight: Normal TTF Names Family: Hoefler Text Engraved Styles (Subfamily): Regular Preferred Family: Hoefler Text Preferred Styles: Engraved What does fontspec/fontconig read in the ile to match the requested font? (in this case ”Hoeler Text/Bold” Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q) User: user7384 Answer by joseph-wright The detail depends on both the engine in use (XeTeX or LuaTeX) and also the operating system in question. However, in general the answer is ’fontspec does not actually do this’. More precisely, fontspec relies on features of the engine to load fonts. XeTeX and LuaTeX use diferent approaches to font loading. XeTeX contains operating system-dependent code, which therefore uses features of the system (as Windows, Mac OS X and Linux have
197
diferent approaches to font management). On the other hand, the LuaTeX approach is implemented in Lua, using feature of the LuaTeX engine. Coupled with these considerations, not all fonts are equal. Even if they have the same name, they may not be from the same supplier. Some fonts are regrettably ’faulty’ in their internals, and this tends to show up when loading with fontspec. Thus if you have an issue loading a particular font, then it’s not just a question of saying ’fontspec can’t ind the font’, but rather ’using fontspec with on cannot load font from ’. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q)
Q: Reference about ”modern” LaTeX usage for scientiic works Tags: fonts (Prev Q) (Next Q), packages (Prev Q) (Next Q) I am looking for a reference (book, free pdf, website) that would summarize the working of ”modern” LaTeX for scientiic works (I’m writing my master thesis). I know and have been using LaTeX for some years, but I would like to go ”one step further”: I read about LuaTeX, new fonts, styles, packages, etc. I know to achieve this ”goal” I just have to read the questions/answers here but maybe someone will provide a good reference. This question is not very precise but I hope someone will understand what I’m looking for. Tags: fonts (Prev Q) (Next Q), packages (Prev Q) (Next Q) User: cedric-h. Answer by geofrey-jones 198
”Modern” is a somewhat loaded term. You probably want to distinguish between: 1. what’s functionally modern in the sense of the most technologically cutting edge or elegant ways to get TeX et famille to do your bidding. E.g., via LuaTeX, XeTeX, ConTeXt, LaTeX3, fontspec, microtype, etc.; 2. and, contra what’s technologically modern, what’s stylistically modern (in the sense of leading edge ideas for thesis/book/document design). You’ll get lots of very good info about functional ”edge of the envelope” possibilities just by typing some of the keywords mentioned in point 1 above (LuaTeX, etc.) into the searchbox at the top of this page, following links on and of this site, then asking more directed questions here as and when you’d like to learn more. You’ll ind that the quality of responses increases the sharper the questions you ask. Another approach might be to search out those users with specialties you’re interested in (Joseph Wright for LaTeX3, Aditya for ConTeXt, Harald and Ulrike for seemingly impossible solutions to raw TeX problems, frabjous, Lev Bishop and Andrew Stacey for academic writing, Stefan and Will for, gosh, everything ...) then ”follow” the line of the questions they’ve answered by chasing them individually through their Users pages. This, I think, would be more fruitful than holding out for a consolidated ”reference (book, free pdf, website) that would summarize the working of ’modern’ latex for scientiic works”. As for what’s stylistically modern package-wise, you’ll probably ind ClassicThesis about as close to the edge as likely to be accepted in a science-oriented masters thesis (actually, probably closer to postmodern than modern). Otherwise, check out Tufte-Book for a raft of stylistically interesting ideas. Tags: fonts (Prev Q) (Next Q), packages (Prev Q) (Next Q)
Q: Selecting optical sizes for all fonts in a family Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q) 199
XeTeX and LuaTeX are able to assign optical sizes to fonts when they are provided. In those situations where XeTeX or LuaTex are unable to correctly assign optical sizes I am able to specify them but only for the regular font, not for italics, bold, or bold italics. I’m looking for a way to assign all of them. The speciic example I’m using is for Minion Pro and I know a package exists for it but I’m looking for a general solution I can apply as a regular user whenever something like this comes up again. Here’s the MWE: Skip code block
\documentclass[openleft,12pt]{memoir} \usepackage{fontspec} \setmainfont[ItalicFont={MinionPro-It},BoldFont={MinionPro-Bold},BoldItalicFont={M \begin{document} Regular\\ \textit{Italic}\\ \textbf{Bold}\\ \textit{\textbf{Bold Italic}}\ {\tiny tiny}\\ {\normalsiḶe normal}\\ {\Large Large}\\ {\LARGE LARGE}\\ {\HUGE HUGE}\\ {\tiny{ \textit{tiny italic} \textbf{tiny bold} \textbf{\textit{tiny bold italic}}}}\\ {\Large{ \textit{Large italic} \textbf{Large bold} \textbf{\textit{Large bold italic}}}}\\ {\HUGE{ \textit{HUGE italic} \textbf{HUGE bold} \textbf{\textit{HUGE bold italic}}}} \end{document} Both XeLaTeX and LuaLaTeX need the italic, bold, and bold italic fonts declared. After that XeLaTeX uses all the correct optical sizes for this example. 200
LuaLaTeX does not use any of them (except as before for the regular font). If you change the \setmainfont section to look like this:
\setmainfont[ItalicFont={MinionPro-It},BoldFont={MinionPro-Bold},BoldItalicFont={M SiḶeFeatures={ {SiḶe={-8.4},OpticalSiḶe=8}, {SiḶe={8.4-13},OpticalSiḶe=11}, {SiḶe={13-19.9},OpticalSiḶe=19}, {SiḶe={19.9-},OpticalSiḶe=72}} ] {Minion Pro} Then everything still works for XeLaTeX and now the optical sizes (Caption, Regular, SubHeader, Display) work with LuaLaTeX for the regular fonts but not for italics, bold, and bold italics. I had thought that maybe something like:
\setmainfont[ItalicFont={MinionPro-It},BoldFont={MinionPro-Bold},BoldItalicFont={M SiḶeFeatures={ {SiḶe={-8.4},OpticalSiḶe=8,ItalicFont={MinionPro-ItCapt}, {SiḶe={8.4-13},OpticalSiḶe=11}, {SiḶe={13-19.9},OpticalSiḶe=19,ItalicFont={MinionPro-ItSubH}, {SiḶe={19.9-},OpticalSiḶe=72,ItalicFont={MinionPro-Disp}}} ] {Minion Pro} Would work (obviously illing in the bold and bold italic fonts and the other sizes) but that results in an error. I’ve tried several variations on that idea and nothing works. I keep reading over the fontspec and luaotload manuals but can ind nothing on how to do this thing speciically (I did ind a reference to a ”goodies” ile for ConTeXt but was unable to igure out how to load it into a LuaLaTeX document). Update Some more experimentation with Adobe fonts. I just did the same experiment with Garamond Premier Pro (also has optical sizes). And the results are similar. LuaLaTeX will just not load the Caption/Subheading/Display versions of Italic/Bold/Bold Italic though it handles the Regular font without even having to specify the optical sizes (thanks to a ix supplied when I asked a similar question before about 201
Garamond speciically). XeLaTeX will but uses the SemiBoldItalic versions for the diferent optical sizes instead of just BoldItalic. Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q) User: bfootdav Answer by ludenticus You have to specify the font for each feature. See section 5.1.2. of the fontspec manual. A XeTeX MWE: Skip code block \documentclass[12pt]{memoir} \usepackage{fontspec} \setmainfont[% UprightFeatures={ SiḶeFeatures={ {SiḶe={-8.4},Font=MinionPro-Capt}, {SiḶe={8.4-13},Font=MinionPro-Regular}, {SiḶe={13-19.9},Font=MinionPro-Subh}, {SiḶe={19.9-},Font=MinionPro-Disp} }, }, BoldFeatures={ SiḶeFeatures={ {SiḶe={-8.4},Font=MinionPro-BoldCapt}, {SiḶe={8.4-13},Font=MinionPro-Bold}, {SiḶe={13-19.9},Font=MinionPro-BoldSubh}, {SiḶe={19.9-},Font=MinionPro-BoldDisp} }, }, ItalicFeatures={ SiḶeFeatures={ {SiḶe={-8.4},Font=MinionPro-ItCapt}, {SiḶe={8.4-13},Font=MinionPro-It}, {SiḶe={13-19.9},Font=MinionPro-ItSubh}, 202
{SiḶe={19.9-},Font=MinionPro-ItDisp} },
}, BoldItalicFeatures={ SiḶeFeatures={ {SiḶe={-8.4},Font=MinionPro-BoldItCapt}, {SiḶe={8.4-13},Font=MinionPro-BoldIt}, {SiḶe={13-19.9},Font=MinionPro-BoldItSubh}, {SiḶe={19.9-},Font=MinionPro-BoldItDisp} }, },
] {Minion Pro}
\begin{document} \noindent Regular\\ \textit{Italic}\\ \textbf{Bold}\\ \textit{\textbf{Bold Italic}}\\ \noindent {\tiny tiny}\\ {\normalsiḶe normal, not \textbf{\textit{HUGE bold italic}}}\\ {\Large Large}\\ {\LARGE LARGE}\\ {\HUGE HUGE}\\ \noindent {\tiny{ \textit{tiny italic} \textbf{tiny bold} \textbf{\textit{tiny bold italic}}}}\\ {\Large{ \textit{Large italic} \textbf{Large bold} \textbf{\textit{Large bold italic}}}}\\ {\HUGE{ \noindent HUGE\\ \textit{HUGE italic}\\ \textbf{HUGE bold}\\ 203
\textbf{\textit{HUGE bold italic}}}} \end{document} Answer by brent.longborough With XeTeX you do not need multiple size declarations, and I believe you should not with LuaTeX. In what follows, I’ll refer to @Ludenticus’ solution as (1), and mine, which follows, as (2): Skip code block \documentclass[12pt,a5paper]{memoir} \setlrmarginsandblock{1cm}{*}{1} \usepackage{fontspec} \setmainfont{Minion Pro}[% SiḶeFeatures={% {SiḶe={-8.4},Font=* Caption}, {SiḶe={8.4-13},Font=*}, {SiḶe={13-19.9},Font=* Subhead}, {SiḶe={19.9-},Font=* Display} }, BoldFont={* Bold}, BoldItalicFont={* Bold Italic}, ] \setlength{\parindent}{ḷpt} \nonḶeroparskip \begin{document} \noindent Regular \textit{Italic} \textbf{Bold} \textit{\textbf{Bold Italic}}\par \noindent {\tiny tiny}\par {\normalsiḶe normal, not \textbf{\textit{HUGE bold italic}}}\par {\Large Large}\par 204
{\LARGE LARGE}\par {\HUGE HUGE}\par
\noindent {\tiny{ \textit{tiny italic} \textbf{tiny bold} \textbf{\textit{tiny bold italic}}}}\par {\Large{ \textit{Large italic} \textbf{Large bold} \textbf{\textit{Large bold italic}}}}\pa {\HUGE{ \noindent HUGE\par \textit{HUGE italic}\par \textbf{HUGE bold}\par \textbf{\textit{HUGE bold italic}}}} \end{document} (1) and (2) processed with XeLaTeX produce visually identical PDFs (compared with diffpdf, option ’appearance’. (1) and (2) processed with LuaLaTeX are diferent. The PDF from (1) has a full complement of embedded fonts (16), while (2) only has 10, the extra optical sizes being missing. Notes: • The default Bold association for Minion Pro is not ’bold’, but ’semibold’. I assume this was what made you search for the parameters to change the two bold series. • If you’re happy with semibold, you can just omit the two Bold... lines altogether. • I much prefer to use font names rather than font ilenames -- it seems a lot less brittle (once you discover the right names!). Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q)
205
Q: Selecting main math font in LuaTeX? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), math-mode (Next Q) I’d to set some fairly simple maths in Minion Pro (and potentially other system fonts), using LuaTeX. I’d hoped that something like the following should work: \documentclass{minimal} \usepackage{fontspec} \setmainfont{Minion Pro} \begin{document} Here’s some text. \end{document}
Now some math: $x^2 + y^2 = Ḷ^2$.
However, the x^2 + y^2 + Ḷ^2 is set in Computer Modern. Material in \mathit, \mathrm etc. appears in Minion as hoped, and can be further controlled by \setmathrm and so on, but is there any way to control the main math font? I don’t have Minion Math, and trying to use ordinary Minion Pro as the math font via unicode-math doesn’t help—indeed, it puts \mathit material back into CM! MnSymbol also doesn’t help. But in any case, I’d prefer a solution that generalises to other fonts, if possible. Alternatively, changing to XeLaTeX, the mathspec package does the trick, using \setmathfont(Digits,Latin){Minion Pro}. But I’d be sad to give up microtype and the rest of the power of LuaTeX! Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), math-mode (Next Q) User: peter-lefanu-lumsdaine Answer by khaled-hosny Simply setting \usemathfont{Minion Pro} with unicode-math will not 206
work since it expects an OpenType math font, but you can use range option to use normal text fonts for certain math alphabets (or any math symbol), check documentation for details. Skip code block \documentclass{minimal} \usepackage{fontspec} \usepackage{unicode-math} \setmainfont{Minion Pro} \setmathfont{Asana Math} % for math symbols, can be any other OpenType math font \setmathfont[range=\mathup] {Minion Pro} \setmathfont[range=\mathbfup]{Minion Pro Bold} \setmathfont[range=\mathbfit]{Minion Pro Bold Italic} \setmathfont[range=\mathit] {Minion Pro Italic} \begin{document} Here’s some text. \end{document}
Now some math: $x^2 + y^2 = Ḷ^2$, $\mathrm{x^2 + y^2 = Ḷ^2}$, $
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), math-mode (Next Q)
Q: Best practice - how can I get my whole document (including math) to only use font X with LuaLaTeX and fontspec? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) Considering one uses math symbols in a document, it is desirable to have them all displayed in the serif font one is using for text, or in basically any font x one would like to use for this sort of thing. So for one who just started looking into using LuaLaTeX, the amount of information on how to properly typeset a document with only one font (or good combination of at least 2 fonts) is a bit overwhelming. There are easily 207
hundreds of questions on fontspec, Lua(La)TeX, mathspec and the resulting options to use a font, some of which are 4 years old. Maybe some of the more experienced (and especially more successful) users, who have done this kind of thing before, could share their code for some of the most popular fonts (or their clones and variants)? • Times New Roman • Helvetica/Arial • Palatino • Minion Pro • Garamond • Georgia ... and more Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: henry Answer by paul-gessler I’m not sure I qualify as experienced and/or more successful :-). But here’s an example of the setup I used for my thesis. Adobe Garamond Pro was used as the text font. Sadly, I needed bold to appease the thesis arbiters at my university, so I used BoldFont=AGaramondPro-Semibold as it looks slightly less out of place than the standard bold weight. For mathematics, I used the mathdesign package with option adobe-garamond. This provided all math symbols I needed for my document, with glyph shapes appropriate for Garamond as a text font. For this to be successful, you must copy the .otf font iles to a speciic TDS directory, as detailed in the mathdesign README ile. I also have shown some additional typographical enhancements in my sample below, which you may be interested in. microtype allows for more pleasing color on the page. The selnolig package breaks ligatures which would otherwise span morpheme boundaries. Of course, only German and English 208
are supported out of the box, so it won’t do much for the Latin text in my example below. Here’s an example using the blindtext package to produce a sample mathematics paper, with explanations in the comments for each font option. I’ve set this in a two-column layout just so that all the math samples it on one page for the screenshot. Sample Code Skip code block %% compile with LuaLaTeX \documentclass[twocolumn]{article} \usepackage{blindtext} % just for the sample math paper
% here are the font specifications \usepackage[adobe-garamond]{mathdesign} % use the mathdesign package with Garamond \usepackage[no-math]{fontspec} % load fontspec without modifying maths fonts \setmainfont[ Ligatures=TeX, % make ---, --, etc function as in traditional (La)TeX Kerning=Uppercase, % slight tracking adjustment for all-caps material BoldFont={AGaramondPro-Semibold}, % this is a bit of a faux pas, but it was requ Numbers=Proportional, % I also had some code to switch to lining numbers in tabu ]{Adobe Garamond Pro} \setmathrm{Adobe Garamond Pro} % for operators and other text in math
% some additional (optional) typographic enhancements \usepackage{microtype} \usepackage[english]{selnolig} % of course, this won't do much for latin lipsum te \begin{document} \blindmathpaper \end{document} Sample Output
209
Close-up 210
Answer by user56567 In according to unimath-symbols.pdf, the best fonts for math symbols are M Latin Modern Math (1588) X XITS Math (2437) C Cambria Math (2189) A Asana Math (2259) P TeX Gyre Pagella Math (1612) E Neo Euler (579) (IMHO, this is very wrong ...) There are many Times-compatible font with fontspec, like TeX Gyre Termes, FreeSerif and STIX. However, I prefer Latin Modern font to Times. This is my MWE Skip code block \documentclass{article} \usepackage[fleqn]{amsmath} \usepackage[no-math]{fontspec} \defaultfontfeatures[\rmfamily,\sffamily]{Ligatures=TeX} \setmainfont{Latin Modern Roman}[BoldFont={* Demi}] \setsansfont{Latin Modern Sans}[BoldFont={* Demi Cond}] \setmonofont{Latin Modern Mono Light} 211
\usepackage[math-style=ISO,bold-style=ISO]{unicode-math} \setmathfont{Latin Modern Math} \begin{document} \section{Test} Test text $\mathrm{test\ } + = $ \end{document} Note that amsmath is loaded before unicode-math like suggested by unicode-math package documentation. Answer by darthbith I had some experience with this in my thesis... The Times clone in the TeX Gyre fonts (Termes) can be used quite simply with the unicode-math package. In fact, any of the TeX Gyre fonts can be used this way (at least, the ones with corresponding math fonts) and this should work for XeLaTeX as well. \documentclass{article} \usepackage{unicode-math} \setmainfont{TeX Gyre Termes} \setmathfont{TeX Gyre Termes Math} \begin{document} Test text $\mathrm{test\ math} \alpha \beta x y Ḷ$ \end{document} Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
Q: How to ind out which glyphs are diferent in an OpenType style set? Tags: fonts (Prev Q) (Next Q), opentype (Prev Q) (Next Q), symbols (Next Q)
212
With fontspec, and XeTeX or LuaTeX it’s possible to access a font’s OpenType features, including the Style Sets, e.g. like this: \addfontfeatures{RawFeature=+ssḷ1;+ss18} TeX.sx has already taught me how to ind out which features are available. Assuming I don’t have proper documentation of my font at hand, is there a way to ind out which glyphs (in which contexts) will actually come out diferently when I use a certain style set (or another OpenType feature)? It also seems to depend on the script and font family (e.g. small caps). I feel like LuaTeX would be able to do this. A nice font with lots of features to test this is Junicode. For this speciic case, however, all the features are neatly described in Specimens and User’s Guide. Tags: fonts (Prev Q) (Next Q), opentype (Prev Q) (Next Q), symbols (Next Q) User: doncherry Answer by jukka-k.-korpela There’s DTL OTMaster, which can be used for free for inspecting a font (and for a fee, for font editing, too). It takes a little time to ind out all the functions in the program, but e.g. the alternate glyphs available in a font can be found out by selecting Tools > ’GPOS’/’GSUB’ Table Viewer and then ’GSUB’ table from the irst dropdown (Layout Table), then selecting diferent options in the Features menu. Then the Subtable view will show the glyphs afected by a feature, as a mapping table under “Report” and as a set of large-size glyphs under “Image”.
213
214
Tags: fonts (Prev Q) (Next Q), opentype (Prev Q) (Next Q), symbols (Next Q)
215
Q: Which fonts can be used with *unicode-math* package? Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q), unicode-math (Next Q), math-mode (Prev Q) (Next Q) What can i put into \setmathfont{.otf} for the unicode-math package to make it all work (with XeLaTeX or LuaLaTeX)? There are several suggestions on the GitHub page of unicode-math, but the irst option is commercial, and the second and the third do not work with the following example: Skip code block % !TEX TS-program = xelatex \documentclass{article} \usepackage{unicode-math} \setmathfont{latinmodern-math.otf} % \setmathfont{texgyrepagella-math.otf} % \setmathfont{xits-math.otf} \begin{document} $X\setminus Y$ \end{document} I do not get the \setminus character in the output. The \setminus character is also missing if i do not set a math font at all (i do not know which font is used in this case). It works with xits-math, but i do not like it. Is it expected by the way that the \setminus character is left blank without giving any warning? Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q), unicode-math (Next Q), math-mode (Prev Q) (Next Q) User: alexey Answer by david-carlisle 216
It works with \setmathfont{Asana-Math.otf} or as noted in the question, with \setmathfont{xits-math.otf} as mentioned in comments, if it doesn’t work you get a warning in the log, eg with latinmodern:
Missing character: There is no in font [latinmodern-math.otf]/ICU:script=math ;l Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q), unicode-math (Next Q), math-mode (Prev Q) (Next Q)
Q: How can you check if fontspec (with LuaLaTeX) can load a font? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) I want to check if fontspec (with LuaLaTeX) can load a certain font and if not try to load another one. For pdlatex I did by checking if the package ile exists; but I don’t ind an easy way to do it with fontspec. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: textnik Answer by david-carlisle You can trap the error and make it a warning, just setting a lag, then test for that and load something else, see the code below. Note this is poking into internal interfaces so if it breaks at a fontspec update, don’t complain:-) Skip code block \documentclass{article} \usepackage{fontspec} 217
\newif\ifgoodfont \makeatletter \ExplSyntaxOn \cs_set:Nn \__fontspec_load_font: { \__fontspec_font_set:Nnn \l_fontspec_font { \__fontspec_fullname:n {\l_fontspec_fontname_up_tl} } {\f@siḶe pt} \__fontspec_font_if_null:NT \l_fontspec_font { \global\goodfontfalse \__fontspec_warning:nx {font-not-found} {\l_fontspec_fontname_up_tl} } \__fontspec_set_font_type: \__fontspec_font_gset:Nnn \l_fontspec_font { \__fontspec_fullname:n {\l_fontspec_fontname_up_tl} } {\f@siḶe pt} \l_fontspec_font % this is necessary for LuaLaTeX to check the scripts properly }
\cs_set:Nn \__fontspec_load_fontname:n { \__fontspec_load_external_fontoptions:Nn \l_fontspec_fontname_tl {#1} \prop_get:NVNF \g__fontspec_fontopts_prop \l_fontspec_fontname_tl \l__fontspec { \clist_clear:N \l__fontspec_fontopts_clist } \__fontspec_font_set:Nnn \l_fontspec_font {\__fontspec_fullname:n {\l_fontspec \__fontspec_font_if_null:NT \l_fontspec_font { \global\goodfontfalse \__fontspec_warning:nx {font-not-found} {#1} } } \ExplSyntaxOff \makeatother {\scrollmode\global\goodfonttrue \setmainfont{ḶḶḶḶ} } \ifgoodfont \typeout{(ḶḶḶḶ found (strange:-)} 218
\else \typeout{ḶḶḶḶ not found, trying TeX Gyre Bonum} \global\goodfonttrue \setmainfont{TeX Gyre Bonum} \ifgoodfont \typeout{OK} \else \typeout{not found that either, stopping} \stop \fi \fi \begin{document} ḶḶḶ \end{document} Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
Q: Prevent LuaLaTeX from splitting umlauts Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), unicode (Next Q) Here’s a minimal example: \documentclass{minimal} \usepackage{fontspec}\setmainfont{Cambria} \begin{document}aöḶ\end{document} Compiling this into a PDF using lualatex and extracting the text using pdftotext, I get the string aö Ḷ, that is: U+ḷḷ61(a) U+ḷḷ6f(o) U+ḷ3ḷ8(combining diaeresis) U+ḷḷ2ḷ(space) U+ḷḷ7a(Ḷ) Two problems with this: there’s an unnecessary space (due to some PDF formatting trickery, the uncompressed datastream shows Tm[125-124]TJ), 219
and I don’t want the umlaut to be split into base and combining character because for some reason that renders weirdly when changing the font size. I want the output to be U+ḷḷ61(a) U+ḷḷf6(ö) U+ḷḷ7a(Ḷ) And the worst thing: with \setmainfont{Lucida Grande}, I get exactly that. Just not with Cambria. Both are in TTF format. Checking the fonts in fontforge shows that both their U+ḷḷf6 glyphs are deined as composed of U+ḷḷ6f U+ḷ3ḷ8, only diference being that Cambria deines its OTF Class as “Base Glyph” while in Lucida Grande it’s “Automatic” (no idea what that means). It is a fontspec speciic problem: \documentclass{minimal} \usepackage{luaotfload} \font\foo={name:Cambria} at 1ḷpt \begin{document} aöḶ \foo aöḶ \end{document} generates what I expect, irst umlaut missing as expected, too: U+ḷḷ61(a) U+ḷḷ7a(Ḷ) U+ḷḷ2ḷ(space) U+ḷḷ61(a) U+ḷḷf6(ö) U+ḷḷ7a(Ḷ) but \documentclass{minimal} \usepackage{fontspec} \begin{document} aöḶ \fontspec{Cambria} aöḶ \end{document} generates U+ḷḷ61(a) U+ḷḷf6(ö) U+ḷḷ7a(Ḷ) U+ḷḷ2ḷ U+ḷḷ61(a) U+ḷḷ6f(o) U+ḷ3ḷ8 U+ḷḷ2ḷ U+ḷḷ7a(Ḷ) Same when using \DeclareUTFcharacter{xḷḷF6}{\foo} and replacing ö with \foo{}, so I guess it’s not xunicode’s fault? 220
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), unicode (Next Q) User: pascal Answer by pascal From this answer I learned there is a Renderer=Basic option that causes an unknown number of side-efects. \documentclass{minimal} \usepackage{fontspec} \defaultfontfeatures{Renderer=Basic} \begin{document} aöḶ \fontspec{Cambria} aöḶ ffi \end{document} The font doesn’t seem to use ligatures anyway, where I want to use special features like VerticalPosition=Numerator for vulgar fractions, I can just switch to Renderer=Full. A way to keep it from messing around in my unicode while keeping all functionality would be better though… I’ve been using the Basic renderer since and it seems to support the font’s built in ligatures after all (for Cambria look at ti), no TeX-ligatures like --for dashes though, need to enter those as unicode — Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), unicode (Next Q)
221
Q: How to generate compounded diacritical fonts for Sanskrit with XeTeX and LuaTeX? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q) I’m trying to use diacritical marks for Sanskrit with a font that does not natively support all the marks (Minion Pro). So they are compounded somehow by XeTeX. This works almost ine in using: Skip code block \documentclass{scrartcl} \usepackage{xunicode,xltxtra} \usepackage{fontspec,newunicodechar} \defaultfontfeatures{Ligatures=TeX} \setmainfont{Minion Pro} \newunicodechar{ }{\d{R}} \newunicodechar{ }{\d{r}} \newunicodechar{ }{\={\d{R}}} \newunicodechar{ }{\={\d{r}}} \newunicodechar{ }{\d{L}} \newunicodechar{ }{\d{l}} \newunicodechar{ }{\={\d{L}}} \newunicodechar{ }{\={\d{l}}} \newunicodechar{ṃ}{\d{m}} \newunicodechar{ḥ}{\d{h}} \newunicodechar{Ṭ}{\d{T}} \newunicodechar{ṭ}{\d{t}} \newunicodechar{Ḍ}{\d{D}} \newunicodechar{ḍ}{\d{d}} \newunicodechar{ }{\.{N}} \newunicodechar{ }{\.{n}} \newunicodechar{ }{\d{N}} \newunicodechar{ }{\d{n}} \newunicodechar{Ṣ}{\d{S}} \newunicodechar{ṣ}{\d{s}}
222
\begin{document} a A ā
Ā
i
I
ī
Ī
u
U
ū
Ū
e
E
ai o
Ai O
au
Au
ṃ ḥ k
K
c
C
ṭ
Ṭ
t
T 223
p
P
kh
Kh
ch
Ch
ṭh
Ṭh
th
Th
ph
Ph
g
G
j
J
ḍ
Ḍ
d
D
b
B
gh
Gh
jh
Jh
ḍh
Ḍh
dh
Dh
bh
Bh
ñ
Ñ
224
n
N
m
M
y
Y
r
R
l
L
v
V
ś
Ś
ṣ
Ṣ
s
S
h
H
\end{document} But the macrons above Ḹ, ḹ, Ṝ, and ṝ are misplaced and thiner than the ones above ā, ī and so on. What can I do about that? Second problem: This fails completely in LuaTeX. xltxtra seems to be essential for this to work. But this is not supported in LuaTeX. I tried this using this code: https://tex.stackexchange.com/a/20791/19458 But the dots below are bigger than the i-dot. This is not the case with the solution above using XeTeX. Any idea how to do this in a better way in LuaTeX? Is it possible at all? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q) User: psychic-birdy
225
Answer by egreg Here is something that seems to work: Skip code block \documentclass{scrartcl} \usepackage{fontspec,newunicodechar} \defaultfontfeatures{Ligatures=TeX} \setmainfont{Minion Pro} \UndeclareUTFcomposite[\UTFencname]{x1EḷC}{\d}{D} \UndeclareUTFcomposite[\UTFencname]{x1EḷD}{\d}{d} \UndeclareUTFcomposite[\UTFencname]{x1E25}{\d}{h} \UndeclareUTFcomposite[\UTFencname]{x1E36}{\d}{L} \UndeclareUTFcomposite[\UTFencname]{x1E37}{\d}{l} \UndeclareUTFcomposite[\UTFencname]{x1E43}{\d}{m} \UndeclareUTFcomposite[\UTFencname]{x1E46}{\d}{N} \UndeclareUTFcomposite[\UTFencname]{x1E47}{\d}{n} \UndeclareUTFcomposite[\UTFencname]{x1E5A}{\d}{R} \UndeclareUTFcomposite[\UTFencname]{x1E5B}{\d}{r} \UndeclareUTFcomposite[\UTFencname]{x1E62}{\d}{S} \UndeclareUTFcomposite[\UTFencname]{x1E63}{\d}{s} \UndeclareUTFcomposite[\UTFencname]{x1E6C}{\d}{T} \UndeclareUTFcomposite[\UTFencname]{x1E6D}{\d}{t} \UndeclareUTFcomposite[\UTFencname]{x1E44}{\.}{N} \UndeclareUTFcomposite[\UTFencname]{x1E45}{\.}{n} \makeatletter \let\d\relax \DeclareRobustCommand{\d}[1] {\hmode@bgroup \o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}\egroup} \let\.\relax \DeclareRobustCommand{\.}[1]{\accent"ḷ2D9#1} \DeclareRobustCommand{\MACRON}[1]{\accent"AF#1} \makeatother
226
\newunicodechar{Ḍ}{\d{D}} \newunicodechar{ḍ}{\d{d}} \newunicodechar{ḥ}{\d{h}} \newunicodechar{ }{\d{L}} \newunicodechar{ }{\d{l}} \newunicodechar{ṃ}{\d{m}} \newunicodechar{ }{\d{N}} \newunicodechar{ }{\d{n}} \newunicodechar{ }{\d{R}} \newunicodechar{ }{\d{r}} \newunicodechar{Ṣ}{\d{S}} \newunicodechar{ṣ}{\d{s}} \newunicodechar{Ṭ}{\d{T}} \newunicodechar{ṭ}{\d{t}} \newunicodechar{ }{\.{N}} \newunicodechar{ }{\.{n}} \newunicodechar{ \newunicodechar{ \newunicodechar{ \newunicodechar{
}{\d{\MACRON{L}}} }{\d{\MACRON{l}}} }{\d{\MACRON{R}}} }{\d{\MACRON{r}}}
\begin{document} \parbox{.5\textwidth}{ a A ā Ā i I ī Ī u U ū Ū
e E ai Ai o O 227
au Au ṃ ḥ k K c C ṭ Ṭ t T p P kh Kh ch Ch ṭh Ṭh th Th ph Ph g G j J ḍ Ḍ d D b B gh Gh jh Jh ḍh Ḍh dh Dh bh Bh ñ
Ñ
n N m M y Y r R l L v V ś Ś ṣ Ṣ s S h H } \end{document} 228
As you see it’s necessary to undo some of the work done by xunicode (which is automatically loaded by fontspec and needn’t to be loaded explicitly). Also some of the standard accents must be redeined, or they wouldn’t use the main document font. Update 2017 The macros above work provided fontspec is loaded with the euenc option. On the other hand, the new default TU encoding doesn’t declare composites with \d or \.N and \.n, so the code is simpler. Skip code block \documentclass{scrartcl} \usepackage{fontspec} \usepackage{newunicodechar} \setmainfont{Minion Pro} \makeatletter \let\d\relax \DeclareRobustCommand{\d}[1] {\hmode@bgroup \o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}\egroup} \let\.\relax \DeclareRobustCommand{\.}[1]{\accent"ḷ2D9#1} \DeclareRobustCommand{\MACRON}[1]{\accent"AF#1} \makeatother \newunicodechar{Ḍ}{\d{D}} 229
\newunicodechar{ḍ}{\d{d}} \newunicodechar{ḥ}{\d{h}} \newunicodechar{ }{\d{L}} \newunicodechar{ }{\d{l}} \newunicodechar{ṃ}{\d{m}} \newunicodechar{ }{\d{N}} \newunicodechar{ }{\d{n}} \newunicodechar{ }{\d{R}} \newunicodechar{ }{\d{r}} \newunicodechar{Ṣ}{\d{S}} \newunicodechar{ṣ}{\d{s}} \newunicodechar{Ṭ}{\d{T}} \newunicodechar{ṭ}{\d{t}} \newunicodechar{ }{\.{N}} \newunicodechar{ }{\.{n}} \newunicodechar{ \newunicodechar{ \newunicodechar{ \newunicodechar{
}{\d{\MACRON{L}}} }{\d{\MACRON{l}}} }{\d{\MACRON{R}}} }{\d{\MACRON{r}}}
\begin{document} \parbox{.5\textwidth}{ a A ā Ā i I ī Ī u U ū Ū
e E ai Ai o O au Au 230
ṃ ḥ k K c C ṭ Ṭ t T p P kh Kh ch Ch ṭh Ṭh th Th ph Ph g G j J ḍ Ḍ d D b B gh Gh jh Jh ḍh Ḍh dh Dh bh Bh ñ
Ñ
n m y r l v ś ṣ s h
N M Y R L V Ś Ṣ S H
} \end{document} 231
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q)
Q: How do I combine fonts for diferent scripts? Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q), cjk (Next Q) I want to combine Helvetica World (for roman, cyrillic, greek and arabic) and Hei Std (for simpliied chinese) in one document with LuaLaTeX. Hei Std probably hasn’t all the glyphs from Helvetica World and Helvetica World certainly hasn’t all characters from Hei Std. Can I get LuaLaTeX to automatically choose the right font based on the input, i.e. can I combine fonts into one ”virtual font”? I don’t want to switch the fonts manually. Out of curiosity I’m also interested in a solution for XeLaTeX, but I need one for LuaLaTeX. Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q), cjk (Next Q) User: martin-schröder Answer by leo-liu
232
Yes, for XeLaTeX, you should use our xeCJK package. For Chinese typesetting in xeCJK, see my previous answers tagged cjk. A simple example: Skip code block % UTF-8 encoding, compile with XeLaTeX \documentclass{article} \usepackage{xeCJK} \setmainfont{Arial} \setCJKmainfont{Microsoft YaHei} \begin{document} Arial font and \end{document} And for LuaLaTeX, you can use luatexja-fontspec package from luatexja bundle. luatexja is originally designed for Japanese, but also useful for Chinese (due to Ma Qiyuan’s work). A simple example, very similar to xeCJK: Skip code block % UTF-8 encoding, compile with LuaLaTeX \documentclass{article} \usepackage{luatexja-fontspec} \setmainfont{Arial} \setmainjfont{Microsoft YaHei} \begin{document} Arial font and \end{document} The English document of luatexja: http://mirror.ctan.org/macros/luatex/ generic/luatexja/doc/luatexja-en.pdf
233
In ctex bundle, we shall also support luatexja as one of the background package. The new version has not been released. Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q), cjk (Next Q)
Q: Why does LuaLaTeX produce smaller iles than pdfLaTeX in this example? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), ile-size (Next Q) I am discovering LuaLaTeX... I want to produce pdf iles from my tex sources as small as possible. If I compile the following code with LuaLaTeX, the size of the generated pdf is 9 kB. Skip code block \documentclass{article} \usepackage{titlesec} \usepackage{titling} \usepackage{fontspec} % Specify different font for section headings \newfontfamily\headingfont[]{Gill Sans} \titleformat*{\section}{\LARGE\headingfont} \titleformat*{\subsection}{\Large\headingfont} \titleformat*{\subsubsection}{\large\headingfont} \renewcommand{\maketitlehooka}{\headingfont} \author{An author} \title{The title of the article} \date{\today} \begin{document} \maketitle \section{A section} \subsection{A subsection} 234
\subsubsection{A subsubsection} \end{document} If I compile the same code with LaTeX but with a diference of font, the resulted iles is 49 kB large. I guess the diference doesn’t come from LaTeX ou LuaLaTeX but from the fonts. Something like : ”my pdf system knows better about the Gill Sans font than the default LaTeX fonts”. Skip code block \documentclass{article} \usepackage{titlesec} \usepackage{titling} %\usepackage{fontspec} %% Specify different font for section headings %\newfontfamily\headingfont[]{Gill Sans} %\titleformat*{\section}{\LARGE\headingfont} %\titleformat*{\subsection}{\Large\headingfont} %\titleformat*{\subsubsection}{\large\headingfont} %\renewcommand{\maketitlehooka}{\headingfont} \author{An author} \title{The title of the article} \date{\today} \begin{document} \maketitle \section{A section} \subsection{A subsection} \subsubsection{A subsubsection} \end{document} Can someone conirm this? Is there a rule to learn from this if one wants to produce very light iles? PS : If I use the same font, I get the same size ! PPS : Strangely, if I apply ghostscript on the pdf ile generated by LuaLaTex, the size gets bigger (from 9 kB to 12 kB !). The ile generated by LaTex : from 49 kB to 13 kB. PPPS : In my naive way of understanding things, using a custom font, such 235
as Gill Sans would normally produce a bigger ile than if using the standard font. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), ile-size (Next Q) User: colas Answer by keks-dose I’m using Linux Libertine heavily and each PDF, made with pdfLaTeX, had a size of some hundred KB. pdfTeX (as far as I know called by pdfLaTeX) embeds the fonts in the PDF, but it does not compress them. There was a wonderful tool called pdfsiḶeopt, written by Peter Szabo and published at Google Code. It compressed the fonts inside the PDF heavily; mine usually by factor 10! Well, sadly enough, the page http://pdfsizeopt.googlecode.com/ was taken down for alleged copyright issues. New home is here: https://github.com/ pts/pdfsizeopt (Thank you, giordano). There you will ind a paper Szabo published about the compression going down to a very detailed level. In short: The diference between LuaLaTeX and PDFLaTeX seems to be the way of embedding the fonts, namely the used compression. So as a result to those batshit crazy laws you’d better not publish you code with googlecode. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), ile-size (Next Q)
Q: How is a TeX document written when using LuaLaTeX? Tags: fonts (Prev Q) (Next Q)
236
I am new to the LaTeX world and would like to start of with a book project. My target is speciically creating books for print and online. My requirements are • • • •
UTF-8, Arabic, custom fonts, to output PDF/X-1a compliant PDFs.
I have read that LuaTeX is the new engine. How does using LuaLaTeX afect the .tex document structure? For example, if I follow the LaTeX Beginner’s Guide, would I be able to use LuaLaTeX? Is only the preamble diferent when using LuaLaTeX? I am using TeXStudio under Windows 8.1. Tags: fonts (Prev Q) (Next Q) User: ibn-saeed Answer by stephan-lukasczyk LuaLaTeX shouldn’t afect your document too much. The main thing you’ll have to change is the preamble. There’s no need to load packages like fontenc or inputenc. LuaLaTeX supports UTF-8 by default, so you should encode your iles with UTF-8 (this should be possible with TeXStudio). Instead of having a preamble like \documentclass{article} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} there now is the package fontspec to set the document’s fonts: \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{Linux Libertine O} \setsansfont[Ligatures=TeX]{Linux Biolinum O} 237
and so on. Please read the documentation of the fontspec package for details on this. Also the LuaTeX reference might be useful, as well as Manuel Pégourié-Gonnard’s Guide to LuaLaTeX, which I really recommend reading. It basically gives you the main diferences (see p. 3 of the PDF ile): 1. Don’t load inputenc; just encode your source in UTF-8. 2. Don’t load fontenc or textcomp; load fontspec. 3. babel works with LuaLaTeX but you can load polyglossia instead. 4. Don’t use any package that changes the fonts; use fontspec commands instead. Basically, everything that works with normal pdfTeX should also work with LuaTeX, but be aware that LuaTeX is still in development and it could change from release to release. For distinct questions and problems, please have a look around this website for an answer to your question, or ask a question yourself. Tags: fonts (Prev Q) (Next Q)
Q: In LuaTex is it possible to change font/language according to the script/glyphs used? Tags: fonts (Prev Q) (Next Q), hyphenation (Next Q) I am a XeLaTeX user and I often have to typeset english-greek documents. Packages like xgreek or polyglossia are great but in order to apply the correct hyphenation rules you have to declare the text that belongs to the secondary language. On the long run, this can become cumbersome. In XeLaTeX I am using the XeTeXinterchartoks mechanism that allows me to change automatically the hyphenation rules and/or the font without explicitingly declaring them. The procedure involves grouping together the glyphs of a Unicode Block and then automatically applying tex commands when transitioning from a group to another one.
238
For those not familiar with the XeTeXinterchartoks, more info can be found at xetex-reference pages 13-14. Lately I got interested in Lua(La)Tex. I want to know if there is a way to achieve similar results in LuaTex. As was pointed in a previous question, in LuaTeX there is not a direct analogue to XeTeXinterchartoks but it was suggested that there are other, more powerful ways to achieve the same goal. So the questions are 1. How can I change the hyphenation rules/font automatically according to the glyphs used without declaring them? 2. Can someone provide a minimum working example or at least point me to some references? 3. One of the drawbacks of XeTeXinterchartoks is that the settings are global. Is there a way in LuaTeX to set this feature (if it exists) on and of, thus providing more lexibility? Tags: fonts (Prev Q) (Next Q), hyphenation (Next Q) User: pmav99 Answer by taco-hoekwater Here is a proof of concept at doing the equivalent of \XeTeXinterchartoks in luatex. First, a style ile: Skip code block % luatexinterchartoks.sty \newcount\XeTeXinterchartokenstate \newcount\charclasses \def\newXeTeXintercharclass#1% {\global\advance\charclasses1\relax \newcount#1 \global#1=\the\charclasses }
239
\newcount\cchone \newcount\cchtwo \def\dodoXeTeXcharclass {\directlua{setcharclass(\the\cchone,\the\cchtwo)}} \def\doXeTeXcharclass% {\afterassignment\dodoXeTeXcharclass\cchtwo } \def\XeTeXcharclass% {\afterassignment\doXeTeXcharclass\cchone } \protected\def\XeTeXdointerchartoks% {\directlua{setinterchartoks(\the\cchone,\the\cchtwo,\the\allocationnumber)}} \protected\def\dodoXeTeXinterchartoks% {\newtoks\mytoks\afterassignment\XeTeXdointerchartoks\global\mytoks } \protected\def\doXeTeXinterchartoks% {\afterassignment\dodoXeTeXinterchartoks\cchtwo } \def\XeTeXinterchartoks% {\afterassignment\doXeTeXinterchartoks\cchone } \luatexdirectlua{dofile('luatexinterchartoks.lua')} \endinput And a matching lua ile: Skip code block % luatexinterchartoks.lua charclasses = charclasses or {} function setcharclass (a,b) charclasses[a] = b end 240
local i = ḷ while i < 65536 do charclasses[i] = ḷ i = i + 1 end interchartoks =
interchartoks or {}
function setinterchartoks (a,b,c) interchartoks[a] = interchartoks[a] or {} interchartoks[a][b] = c end local nc, oc oc = 255
function do_intertoks () local tok = token.get_next() if tex.count['XeTeXinterchartokenstate'] == 1 then if tok[1] == 11 or tok[1] == 12 then nc = charclasses[tok[2]] newchar = tok[2] else nc = 255 newchar = '' end local insert = '' if interchartoks[oc] and interchartoks[oc][nc] then insert = interchartoks[oc][nc] local newtok = tok if insert ḷ) then tex.sprint("{\\OD\\char" .. glyphs[i].unicode .. "}"); end tex.print(" {\\small(") tex.print(-2, glyphs[i].name ) tex.sprint(')}\\\\') end fontloader.close(f) \end{luacode*} \end{multicols} 258
\end{document}
Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q), context (Next Q), symbols (Prev Q) (Next Q)
Q: Fixing fonts with LuaTeX feature iles Tags: fonts (Prev Q) (Next Q) Bringhurst urges us in Chapter 10 of The Elements of Typographic Style: Version 4.0 to ix the font iles if needed. See below a summary of the chapter using the section titles. Bringhurst suggests to modify the font ile so the ixes are done forever. But I think that for some ixes we can use feature iles in LuaTeX. This can make easier to transfer projects from computers with fonts installed system-wide. I ask for help to identify what can be corrected using feature iles and show an example ile. (Would it be better to make this question a comunity wiki?) List of possible issues to be ixed 1. Letterform Sometimes the glyphs are completely wrong. Usually due to missing glyphs taken from other fonts. In this case the only possibility is to use a font editor. Not possible with feature iles. 2. Hinting 259
Hinting is not an easy process and sometimes is wrong or missing Altogether. In this case the only possibility is to use a font editor. Not possible with feature iles. 3. Vertical position Some characters’ vertical position (specially +, -, dashes, ...) could be improved. Is it posible to ix it with feature iles? 4. Sidebering This is the blank space at the right and left of the outline of the glyph insie the box. Bringhurst says that he has to ix these values usually to ix the space between letters and puntuation symbols (He describes his style in this regards as a halfway between british and french typographic traditions). Can/Should it be done with feature iles? (The microtype package can do the french typeseting style. Does it use kerning correction for that?) 5. Character substitution Some characters could be in an inappropriate encoding position. I guess this can be ix with a GSUB rule. 6. Kerning What to say about bad kerning, that the audience of this forum doesn’t already know! This is an easy one; I can even answer myself :-) Summary of Chapter 10 10 Grooming the font 10.1 Legal considerations 10.1 Check the license before tuning a digital font 10.2 Ethical & aesthetic considerations !0.2.1 If ain’t broken... 10.2.2 If the font is out of tune, ix it once and for all 10.2.3 Respect the font irst of all, the letterform second, the type designer third, the foundry fourth 260
10.2.4 Keep on ixing 10.3 Honing the character set 10.3.1 If there are defective glyphs, meal them 10.3.2 If text igures, ligatures or other glyphs you need on a regular basis don’t reside on the base font, install them there 10.3.3 if glyphs you need are missing altogether, make them 10.3.4 Check and correct the sidebering 10.3.5 Reine the kerning table 10.3.6 Check the kerning of the word space 10.4 Hinting 10.4.1 If the font looks poor at low resolutions, check the hinting 10.5 Naming convention Tags: fonts (Prev Q) (Next Q) User: textnik Answer by georgd A little guide to feature iles With feature iles you can deine two types of operation in lookups: substitute (sub) glyphs by others and position (pos) glyphs. What is impossible, is to modify the letterforms or add missing glyphs. Also, wrong encoding can’t be corrected by feature iles. The only thing one can do in this case is to a glyph by another from the font so at least the visual appearance is as expected. Simple lookups The simplest positioning is kerning:
261
lookup mykern { pos A V -7ḷ; # 'pos' is short for the keyword 'position' pos T e -1ḷḷ; } mykern; Substitution is possible as 1:1, n:1 (ligature), 1:n Skip code block
lookup mysmallcaps { sub u by v.sc; # have a v shaped smallcap glyph instead of a u-shaped one; with } mysmallcaps; lookup myligatures { sub a e by ae; # 'sub' is short for the keyword 'substitute' } myligatures; lookup unligate { sub f_f_l by f f l; } unligate; Contextual lookups More complex lookups can deine in which context an operation takes place: lookup myordinals { sub one s' by s.sups; sub s.sups t' by t.sups; } myordinals; lookup kernwithdiacritics { pos T' 5ḷ e acutecomb; # this is accumulative to a previous kern of T e } kernwithdiacritics; With the keyword ignore one can exclude contexts from the substitution. The following will substitute e with a inal form if it’s not followed by one of the letters A-Z or a-z: lookup finals { ignore sub e' [A-Z a-Ḷ]; # the content inside the brackets is a "glyph class" 262
sub e' by e.fina; } finals; Advanced positioning The two kinds of position parameters in the kern lookups are short formats. The full format is . So, for example adjust the vertical position of a superscript glyph with: lookup mysuperscript { pos e.sups ; } mysuperscript;
# e.sups is positioned 5ḷ design-units higher
To illustrate let’s adjust the greek letter Η with polytonic accents. In the irst example it’s Eta with grave (Ὴ, needs space to the left), in the second we add a iota adscriptum ( needs space to the right. xplacement shifts the image of the glyph by the given value without changing its box, xadvance changes the size of the glyph’s box: lookup greekaccents1 { pos Eta' gravecomb.grk; } greekaccents1; lookup greekaccents2 { pos Eta' ypogegrammeni.cap; pos Eta' ypogegrammeni.cap gravecomb.grk; } greekaccents1; Important: • Lookups are accessible via features, where one feature can activate one or more lookups and diferent features can activate the same lookup: feature gacc { # featurenames are four-letter tags lookup greekaccents1; lookup greekaccents2; } gacc; • Lookups are applied to a language-system which needs to be deined, but make sure that that system exists in the font. The language263
systems can be deined at the beginning of the feature-ile, they will be applied to lookups in all subsequent features. If one needs to apply a lookup only in speciic language-systems on has to do so explicitly inside the feature: languagesystem languagesystem languagesystem languagesystem
DFLT grek latn latn
dflt; dflt; dflt; TRK ;
feature mkrn { lookup mykern; # This will be applied to all above language-systems } mkrn; feature itrk { script latn; language TRK exclude_dflt; lookup turkish_i { sub i.sc by i.sc dotaccent; # this will only be applied to Turkish in } turkish_i; } itrk; • As you can see above, lookups can be deined separately or nested inside features. • For bigger tasks, you can deine glyphclasses (eg. before the lookups): @letters = [a-Ḷ aacute eacute adieresis odieresis]; @LETTERS = [A-Z Aacute Eacute Adieresis Odieresis]; • Make sure that you use the glyphnames as they appear in the font. This can be tricky and you might need to open the font in a font-editor or dump it with some tool (does somebody know a more direct way?) For example, the glyphname Delta can refer either to the greek letter or to the symbol in diferent versions of the same Adobe spec. Also, font-designers can name the glyphs diferent from Adobes proposals. Answer by thérèse Here are three examples from my experience: 264
Sometimes a font has oldstyle igures in both its roman and its italic, but the onum feature is deined only for the roman. Didot LT Pro is one such font, and its oldstyle italic igures can be made easily accessible this way: Skip code block \documentclass{article} \usepackage{filecontents,fontspec} \begin{filecontents*}{didot.fea} languagesystem DFLT dflt; languagesystem latn dflt; # fix for italic feature inum { sub Ḷero by Ḷero.onum; sub one by one.onum; sub two by two.onum; sub three by three.onum; sub four by four.onum; sub five by five.onum; sub six by six.onum; sub seven by seven.onum; sub eight by eight.onum; sub nine by nine.onum; } inum; \end{filecontents*} \setmainfont[FeatureFile={didot.fea}, UprightFeatures={Numbers=OldStyle}, ItalicFeatures={RawFeature={+inum}}] {Didot LT Pro} \begin{document} 123456789ḷ \textit{123456789ḷ} \end{document} Sometimes a font has ligatures, but the liga feature is not deined. Freundschafts Antiqua is a case in point. You can use the ligatures this way: Skip code block 265
\documentclass{article} \usepackage{filecontents,fontspec} \begin{filecontents*}{frnd.fea} languagesystem DFLT dflt; languagesystem latn dflt; feature liga { sub \f \i by \fi; sub \f \l by \fl; } liga; \end{filecontents*} \setmainfont[FeatureFile={frnd.fea}, ItalicFont={FreundschaftsKursivA}] {FreundschaftsAnt} \begin{document} fine flowers \end{document} Notice that you don’t have to say RawFeature={+liga}, because fontspec enables that feature by default. Hermecito is a font with neither liga nor sups deined, though it has ligatures and superior igures. Its small caps are adversely afected by the kind of ix used for Freundschafts Antiqua, but a more verbose approach works: Skip code block \documentclass{article} \usepackage{filecontents,fontspec,realscripts} \begin{filecontents*}{herm.fea} languagesystem DFLT dflt; languagesystem latn dflt; feature liga { sub \f \f by \ff; sub \f \i by \fi; sub \f \l by \fl; 266
sub \f \f \i by \ffi; sub \f \f \l by \ffl; } liga; feature sups { sub \Ḷero by \Ḷerosuperior; sub \one by \onesuperior; sub \two by \twosuperior; sub \three by \threesuperior; sub \four by \foursuperior; sub \five by \fivesuperior; sub \six by \sixsuperior; sub \seven by \sevensuperior; sub \eight by \eightsuperior; sub \nine by \ninesuperior; } sups; \end{filecontents*} \setmainfont[FeatureFile={herm.fea}, SmallCapsFont={HermecitoSpecial SC}, RawFeature={+liga}, SmallCapsFeatures={RawFeature={-liga}}] {HermecitoSpecial} \begin{document} finest,\footnote{One} fluffiest\footnote{Two} felines\footnote{Three} \end{document} Answer by textnik The kerning between two letter can be modiied using this feature ile: mykern.fea languagesystem DFLT dflt; languagesystem latn dflt; feature kern { pos \V \A -8ḷḷ; } kern; 267
The unit is em/1000. Tags: fonts (Prev Q) (Next Q)
Q: Accent positioning on ’oe’ character with feature ile in fontspec Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), opentype (Prev Q) (Next Q) There is no accented glyph for the ’oe’ character in Linux Libertine. When trying to form this character, the (acute) accent is centred over the ’e’ half. I’m trying to get the accent over the centre of the whole ligature. I have tried to add a feature ile to position the accent but have not got it to do anything yet. I wonder if my syntax is at fault - or anything else. This is the minimal test I am using (with 2 ways of naming the character) with lualatex: \documentclass{article} \usepackage{fontspec} \setmainfont[FeatureFile=linlib.fea,RawFeature=+mlig;]{Linux Libertine O} \begin{document} \'{\oe} \'œ \end{document} And the feature ile is: Skip code block #linlib.fea languagesystem DFLT dflt; languagesystem latn dflt; lookup markMarkPositioninglookup1ḷḷ { lookupflag ḷ; markClass [\acutecomb \uniḷ341 ] @TOP_MARK; pos base [\oe ] mark @TOP_MARK; 268
} markMarkPositioninglookup1ḷḷ; feature mlig { script DFLT; # tested with and without these script/language lines language latn dflt ; lookup markMarkPositioninglookup1ḷḷ; } mlig; I have also tried the code for accenting a ligature instead: lookup markLigPositioninglookup1ḷḷ { lookupflag ḷ; markClass [\acutecomb \uniḷ341 ] @TOP_MARKS; position ligature oe
# no mark above the 'o' half ligComponent # specify mark for 'e' half mark @TOP_MARKS # mark above left side of 'e' ; } markLigPositioninglookup1ḷḷ; All to no avail: the accent continues irmly centred over the ’e’. Any ideas? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), opentype (Prev Q) (Next Q) User: bernard Answer by topskip You can use kerning in the feature ile if you don’t mind writing the glyph like this Ṅœ: \documentclass{article} \usepackage{fontspec} \setmainfont[FeatureFile=linlib.fea,RawFeature=+mlig;]{Linux Libertine O} \begin{document} hellṄœworld \end{document} 269
with this feature ile: languagesystem DFLT dflt ; languagesystem latn dflt ; feature kern { position acute oe ; } kern;
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), opentype (Prev Q) (Next Q)
Q: Replacing greek glyphs in math mode Tags: fonts (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), math-mode (Prev Q) (Next Q) I want to switch fonts, away from computer modern. I’m pretty sure that I will end up with a mixture of fonts. I can’t provide a full list of required features, but Linux Libertine’s feature set pretty much covers it. It is, at the moment, my base font for text work, together with Linux Biolinum. I need to adjust the math glyphs, though. They are still taken from the cm fonts and obviously don’t it. As a start, I want to use those provided by GFS, like GFS Bodoni (too playful), or GFS Didot (all available as OTF). To achieve this glyph replacement, I started with one of the mathastext examples:
270
Skip code block \documentclass{article} \usepackage[T1]{fontenc} \renewcommand{\rmdefault}{bodoni} \usepackage[LGRgreek,defaultmathsiḶes,italic]{mathastext} \usepackage{libertine} \let\varphi\phi \linespread{1.ḷ6} \begin{document} ff fi fj fi ffj fl ffl äÄ öÖ üÜ ß\\ ḷ123456789ḷ\\ \begin{equation} abcdefghijklmnopqrstuvwxyḶ \end{equation} \begin{equation} \alpha \beta \gamma \delta \end{equation} \end{document} This compiles without any errors, and the math glyphs are replaced by those from GFS Bodoni, I get ligatures, correct Umlauts (the next problem arises here: LL provides an alternative O-umlaut, which I prefer). However, I don’t know how to access text igures from either LL or GFS Bodoni, while both provide them. My plan was to translate the above mwe to valid code for LuaLaTeX, gaining more control over the font selection. I failed: \documentclass{article} \usepackage[no-math]{fontspec} \renewcommand{\rmdefault}{bodoni} \usepackage[LGRgreek,defaultmathsiḶes,italic]{mathastext} \setmainfont{Linux Libertine O} \setsansfont{Linux Biolinum O} This sets mathnormal, mathrm, mathbf and mathit to computer modern (bad), but uses greek glyphs (which is good). The symbols used are still taken from the CM fonts, but I have not yet tried to replace them. I will 271
need to, because the default int-symbol’s terminals are - as an example ball-shaped. I then found the unicode-math package, but from what I read it is meant to be used for fonts which provide a full unicode math alphabet, which the GFS fonts do not. I tried to use unicode-math, but with less success than with the examples given above. Ultimately, I need a font selection procedure which is not hacked to it one speciic situation. I want to see how the diferent glyphs work together on the same page, and I might even buy a font that suits the text and its purpose, and not the technical limitations caused by my lack of skill. How can I develop a procedure of selecting fonts and glyphs that is robust and gives me the required lexibility? Is unicode-math the way to go? Regarding \setmainfont instead of \renewcommand: I now used \documentclass{article} \usepackage{fontspec} \setmainfont[% ]{GFSBodoni} \usepackage[LGRgreek,defaultmathsiḶes,italic]{mathastext} as you suggested, with and without the no-math option for fontspec, and lualatex complains:
! Font \LGR/GFSBodoni(ḷ)/m/it/7=grmnḷ7ḷḷ at 7pt not loadable: metric data not foun ! Font \LGR/GFSBodoni(ḷ)/m/it/5=grmnḷ5ḷḷ at 5pt not loadable: metric data not foun These errors occur in \begin{equation} abcdefghijklmnopqrstuvwxyḶ ABCDEFGHIJKLMNOPQRSTUVWXYZ \end{equation} This could either be caused by my usage of the font or by an error in my miktex 2.9 installation. However, a pdf is produced, with the following features: • The main fonts are GFS Bodoni, 272
• The greek glyphs in math mode are upright, not CM anymore, but not to be found in the GFS Bodoni Specimen sheet either. I don’t know where they come from. The preamble above is what I used, it is directly followed by \begin{document}. I then downloaded the otf iles from the GFS website, and told fontspec to use them directly. I even renamed them to make sure that lualatex does not ind any other Bodoni iles elsewhere: \setmainfont[% ItalicFont=GFS-Bodoni-Italic.otf, BoldFont=GFS-Bodoni-Bold.otf, BoldItalicFont=GFS-Bodoni-Bold-Italic.otf ]{GFS-Bodoni.otf} I’m puzzled. I’ll now start trying the same thing with unicode-math, as you suggested. unicode-math: After switching back and forth between diferent combinations of options, this is what I irst came up with: Skip code block \documentclass{article} \usepackage{unicode-math} \setmathfont{XITS Math} \setmainfont{Linux Libertine O} \setsansfont{Linux Biolinum O} \setmathfont[ math-style=ISO, range=\mathit/{greek,Greek}, ]{GFSBodoni-Italic} \setmathfont[ math-style=ISO, range=\mathrm/{greek,Greek}, ]{GFSBodoni} Greek glyphs are now replaced, as intended. I can change the latin characters to Linux Libertine with the same trick, using two new blocks and {latin,Latin} 273
in the range option. My original question has been answered, in the sense that I was encouraged to use unicode-math. Thanks Ulrike! However, the quest goes on. Using a unicode math font left me with undesired igures, which I could also replace by igures from GFS Bodoni or Linux Libertine. Unfortunately, none of the following ideas work (the irst is taken from the unicode-math documentation): Skip code block \setmathfont[ math-style=ISO, range=\mathit/{num}, ]{Linux Libertine O} \setmathfont[ math-style=ISO, range=\mathrm/{num}, ]{Linux Libertine O} \setmathfont[ math-style=ISO, range=\mathit/{"ḷḷ3ḷ-"ḷḷ39}, ]{Linux Libertine O} \setmathfont[ math-style=ISO, range=\mathrm/{"ḷḷ3ḷ-"ḷḷ39}, ]{Linux Libertine O} A major drawback is that I need to use a unicode math font, as above. My choice is at the moment limited to XITS, Asana Math, and (partially) Neo Euler. Neo Euler seems to have problems with scaling parentheses. Apart from that, I don’t really like any of these choices, judging just by the more prominent math symbols (like int, parentheses, n-ary sum and n-ary product sign), but that’s not the point of this question. Tags: fonts (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), math-mode (Prev Q) (Next Q) User: christoph 274
Answer by ulrike-ischer In your lualatex example the \renewcommand{\rmdefault}{bodoni} won’t work. It will look for an eu2bodoni.fd which doesn’t exist. Switch to the font you want mathastext to pick up by using (as described in documentation) a suitable \setmainfont before loading mathattext. Apart from this: The font selection depends a lot of the actual font. It is rather easy to replace the font for letters and numbers, but when it comes to symbols you need one or more fonts which contains them and you will perhaps have to adjust various fontdimens. If you really want to use another open type font for the symbols your best bet is at my opinion unicode-math, but it can’t do wonders if a symbol doesn’t exist: \documentclass{article} \usepackage{unicode-math} \setmainfont{Arial} \setmathfont{Arial} \begin{document} $ a = \sin{ḷ} \int \boxtimes \mp$ \end{document} Tags: fonts (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), math-mode (Prev Q) (Next Q)
Q: LuaTeX cannot ind existing font Tags: fonts (Prev Q) (Next Q), errors (Next Q) My Fedora 17 LuaLaTeX (2012) system just keeps complaining about some particular (of course existing) font not existing. It can’t spit out any PDF from a TeX ile using that font. This is the error I am getting: !LuaTeX error: cannot ind OpenType font ile for reading () ==> Fatal error occurred, no output PDF ile produced! 275
I am 100% positive the otf font ile exists and that the path I am giving to setmainfont is correct. After perusing TeX StackExchange searching for help, I couldn’t ind any recommendation that worked. Can anyone help? Tags: fonts (Prev Q) (Next Q), errors (Next Q) User: escudito Answer by escudito I just found a solution. It turned out it was all about cleaning my LuaTeX font cache.
Try that if you face the same problem. Go to your home folder. Activate viewing of hidden iles (Ctrl+H). Look for .texlive2ḷ12/texmf-var/luatex-cache/generic/fonts/o and delete the .lua ile(s) that more closely match your ”existing but not found” fontname. That did the trick in my case, and forever. I suppose an interrupted PDF compilation was the culprit. Tags: fonts (Prev Q) (Next Q), errors (Next Q)
Q: Sans-serif to go with EB Garamond (no math)? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) Suggestions for a good sans-serif font to go with (complement) EB Garamond? Math and non-Western European support are not required. Text is iction, not academic or scientiic. English with an occasional word or phrase in French.
276
I’m using LuaLaTeX from TexLive 2013 on Windows 7 but that should not matter. Too many choices, too little time. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: bill-meahan Answer by willadams Assuming the usage will be for headers or elements like folios, my choice would be Optima, which has a classical structure and so won’t clash too much. If that’s not to your liking, Syntax is a choice advocated on Typophile for this sort of thing, but its higher x-height would require some scaling down. Answer by christian-clason If you don’t mind an organic sans serif, you could use Linux Biolinum which is part of the libertine package; Libertine is a more modern (but still classical) typeface than Garamond, but the pairing still works rather well in my opinion (and if you want to pair a Garalde typeface with a sans serif, you probably don’t care that much about period accuracy) -- although I wouldn’t use bold sans (a double anachronism) for headers:
\documentclass{article} \usepackage[sf,scale=ḷ.95]{libertine} % sets biolinum as sf only \usepackage{ebgaramond} \begin{document} \section*{\sffamily\mdseries Lorem Ipsum Redux} Cras viverra metus rhoncus sem. \textsf{Nulla et lectus vestibulum} urna fringilla \end{document}
The current libertine package automatically uses otf by loading fontspec if the document is compiled using xelatex or lualatex, but the above works 277
using pdflatex as well. If you prefer a more classical sans serif, or really would like to use bold sans, you can try Pablo Impallari’s Quattrocento Sans: \usepackage[sf,scaled=ḷ.9]{quattrocento} ... \section*{\sffamily Lorem Ipsum Redux}
I think the typeface is okay for headings even in bold, but too wide to use in the text body. Answer by joseph Another good choice could be Myriad or Frutiger. Myriad and Minion come with Adobe Reader, and work quite well together (see What best combination of fonts for Serif, Sans, and Mono do you recommend?). There are plenty of nice choices, though. If you don’t need bold, Calluna Sans is free, as well as Fontin Sans.
EB Garamond With Myriad Pro
278
Minion and Myriad (bold)
Minion and Myriad (regular): Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
Q: uneven line spacing Tags: fonts (Prev Q) (Next Q) This is something that is already annoying me for quite a while. (I use LuaLaTeX) The line spacing of the Arabic text is uneven (see pic and/or MWE below). In particular, I think, lines 2, 7, and 10. It would very unpleasant if a book got printed like this. I use Khaled Hosny’s font Amiri Font -- but it’s not the font’s fault. I also get this with Microsoft’s Arabic Typesetting, for example. Nonetheless, I contacted Khaled (because I knew him from TeX.sx) and he said:
279
”This may be due to the way TeX calculates line spacing, lines with high/deep glyphs will cause bigger line spacing. Since Arabic prefers more generous interline spacing than Latin, the solution is usually to make the line spacing big enough by default. If this does not suit you (e.g. the main text is in Latin script), then I think there are ways to force TeX to do ixed line spacing (I don’t use LaTeX my self, but in ConTeXt I just set the text on a grid).” So he suggests two solutions, I make three out of them: 1. increase the line spacing of all text (i.e. Arabic and Latin) -- not suitable, but maybe: 2. increase the line spacing of Arabic text only 3. force ixed line spacing of all text Any ideas of how to accomplish this? Any further ideas? Pic (looks better than here displayed when you download it):
280
MWE: Skip code block % !TEX TS-program = lualatex \documentclass[paper=a4,fontsiḶe=11pt,DIV=calc]{scrartcl} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{Times New Roman} 281
\newfontfamily\arabicfont[Script=Arabic,Numbers=Arabic]{Amiri} \usepackage{csquotes} \newcommand{\arabtext}[1] % Arabic inside LTR {\bgroup\luatextextdir TRT\arabicfont #1\egroup} \newcommand{\aq}[2] % {\blockquote{\arabtext{#1\hfill}\\{#2}}} \begin{document}
\aq{ {Facientes autem elementa esse plura uno, ut Empedocles et Anaxagoras et Leucippus \end{document} Tags: fonts (Prev Q) (Next Q) User: clinteastwood Answer by clinteastwood Today I returned to this question which I could not previously solve to my full satisfaction. But today, while exploring once more barbara beeton’s suggestion in her very irst comment, I could ind a solution. Setting the value of \lineskiplimit to -\maxdimen forces LaTeX to adopt a single ixed line height throughout the document. On this basis, then, I can increase the line height of a given paragraph through changing the value of \baselinestretch, for example: \renewcommand{\baselinestretch}{1.5ḷ}\normalsiḶe. However, the Latin text underneath the quotation in my example would also have the same increased line height (which would be too high for Latin text). So I turned my command \aq (which before consisted of one \blockquote command for one block quote) into a command \aqq (which now consist of two \blockquote commands for two blockquotes to which I can apply \baselinestretch individually with a reduced space between them). This is sofar the best solution to my issue. I will have to see how it turns out in the end. When I apply it to my entire document. But the particular 282
question seems to be more or less answered now. A grid in Adobe Acrobat with the height of 2ḷ,33 pt conirms this:
MWE: Skip code block % !TEX TS-program = lualatex \documentclass[paper=a4,fontsiḶe=11pt,DIV=16]{scrartcl} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{Times New Roman} \newfontfamily\arabicfont[Script=Arabic,Numbers=Arabic]{Amiri} \usepackage{csquotes} \newcommand{\arabtext}[1] % Arabic inside LTR {\bgroup\luatextextdir TRT\arabicfont #1\egroup} \newcommand{\aq}[2] % {\blockquote{\arabtext{#1\hfill}\\{#2}}} % The magic begins here: 283
\lineskiplimit=-\maxdimen \newcommand{\myvariablelineheight}[1]% {\renewcommand{\baselinestretch}{#1}\normalsiḶe} \newcommand{\aqq}[2] % {\blockquote{\myvariablelineheight{1.5}\arabtext{#1\hfill}}\vspace{-2em}\block \begin{document}
\aq{ . {Facientes autem elementa esse plura uno, ut Empedocles et Anaxagoras et Leucippus
\aqq{ . {Facientes autem elementa esse plura uno, ut Empedocles et Anaxagoras et Leucippus \end{document} Tags: fonts (Prev Q) (Next Q)
Q: How can I replace a character (zero)? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), pdftex (Prev Q) (Next Q) Is it possible to replace characters in pdlatex? I use the Minion Pro and Myriad Pro font and the zero looks like a small ’O’. I want to replace the zero by a zero with a dot or slash in the middle (Inserting slashed zero in non-OpenType supporting LaTeX). Is it possible to replace the character globally (I just want to write 0 instead of something like \zero)? Is it possible in pdlatex or should I switch to lualatex (I have no experience in Lualatex but I have heard it has better font handling)? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), pdftex (Prev Q) (Next Q) User: user4811 284
Answer by mico If switching to LuaLaTeX is something you’re considering doing anyway, then you’ll ind that using a ”slashed zero” is very straightforward: it’s a simple option provided by the command \setmainfont (and \setsansfont) of the fontspec package.
Skip code block % !TEX TS-program = lualatex \documentclass{article} \usepackage{fontspec} \setmainfont[Numbers=SlashedZero]{Minion Pro} \setsansfont[Numbers=SlashedZero]{Myriad Pro} \begin{document} Minion Pro: 1ḷḷ1 ḷḷ7 \sffamily Myriad Pro: 1ḷḷ1 ḷḷ7 \end{document} This program can be run under XeLaTeX as well. Incidentally, do note that the slashed zeros in the example above are being produced in text mode. There is apparently no such thing as a unicode-compliant slashed zero in math mode. Aside: The most recent version -- released within just the past few days -- of the luaotfload package (which is loaded by fontspec) contains at least one serious bug that makes it crash with a cryptic and fairly useless error message. If you have TeXLive2013 on your system -- sorry, I don’t have MikTeX and thus don’t know what MikTeX users should do -- and you’ve recently run the TeXLive Manager program to update your distribution’s packages, you can 285
revert to the previous version of luaotfload by executing the command sudo tlmgr restore luaotfload 31286 at a command prompt. Hopefully, a bug ix for this important package will be pushed to the CTAN soon. Answer by fran One option with pdflatex (and without Minion font, sorry I do not have this font installed) for small chunks of simple text (without any LaTeX command) could be the package xstring: Skip code block \documentclass{article} \usepackage{xstring} \usepackage{mathtools} \newcommand\Ḷero{\rlap{ḷ}/} \begin{document} \StrSubstitute{% 1ḷ2ḷ3ḷ is a big number But 1ḷ2ḷḷ3ḷḷḷ4ḷḷḷ is bigger }{ḷ}{\Ḷero} \end{document} Edit As Mico commented, \rlap{ḷ}/ is not a very beautiful slashed zero, but the tuning of the slash position is not easy inside a string substitution. An easy alternative could be $\emptyset$ but unfortunately is clearly bigger than the normal ḷ. But it is possible to select a character much more similar: Skip code block \documentclass{article} \usepackage{xstring} \font\Ḷerofont = cmsy7 at 9.3pt 286
\newcommand\Ḷero{{\Ḷerofont \char 59}} \begin{document} \StrSubstitute{% 1ḷ2ḷ3ḷ is a big number But 1ḷ2ḷḷ3ḷḷḷ4ḷḷḷ is bigger }{ḷ}{\Ḷero} Zeroes comparison: $\emptyset${\Ḷerofont \char 59}ḷ$\rlap{ḷ}/$ \end{document}
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), pdftex (Prev Q) (Next Q)
Q: How to use fakeslant as slanted but not italic font with fontspec? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) Using fontspec with Luatex it is possible to create a fake slant and use that as italic should no italics be around: \setmainfont[ AutoFakeSlant=ḷ.15 ] {FontName}
287
However, also if an italic version exist this faked slant will be used both for \itshape and \slshape. How can I keep using the shipped italic font deined by the ItalicFont= parameter to \setmainfont but use fake slant for \slshape? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: jonalv Answer by egreg An example is Linux Libertine, that has no slanted version: Skip code block \documentclass{article} \usepackage{fontspec} \setmainfont[ SlantedFont={Linux Libertine O}, SlantedFeatures={FakeSlant=ḷ.15}, BoldSlantedFeatures={FakeSlant=ḷ.15}, ]{Linux Libertine O} \begin{document} \textit{abc}\textsl{abc}\textbf{\textsl{abc}} \end{document}
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
288
Q: Embedding Type 1C fonts using LuaLaTeX Tags: fonts (Prev Q) (Next Q), ile-size (Prev Q) (Next Q) As pointed out in the answer to PDF ile size with LuaLaTeX vs XeLaTeX, the diference between using Type 1 and Type 1C fonts in two documents made a big diference in ile size. File size is important in the PDF iles I’m working with. So my question is can you force LuaLaTeX to embed a Type 1C font instead of Type 1? This is something XeLaTeX can do (and in the case of the question cited above, did automatically). The font I’m working with is Gill Sans MT (I believe it comes with Adobe CS). While I’m not opposed to changing fonts, I’d still like to know how LuaLaTeX decides how to embed fonts and how it can be changed. Tags: fonts (Prev Q) (Next Q), ile-size (Prev Q) (Next Q) User: scribblemacher Answer by scottku I do not know how to make lualatex output Type 1C fonts. However, you may be able to use ps2pdf to convert a PDF containing Type 1 fonts to another PDF containing Type1C fonts. You should carefully choose parameters to ps2pdf. For example: Skip code block newell:~/latex/help $ du -h plain.pdf 6ḷK plain.pdf newell:~/latex/help $ pdffonts plain.pdf name type ------------------------------------ ----------------BZAAVM+NimbusSanL-Bold Type 1 YCENSD+LMMathItalic12-Regular Type 1 KDKAQG+CMSS12 Type 1 IDSSCN+NimbusSanL-Regu Type 1 ZIJBJP+NimbusSanL-ReguItal Type 1 289
emb --yes yes yes yes yes
sub --yes yes yes yes yes
uni object ID --- --------no 17 ḷ no 18 ḷ no 19 ḷ no 2ḷ ḷ no 21 ḷ
SEAJVD+NimbusSanL-BoldItal Type 1 yes yes no 22 ḷ SQTJQN+LMMathSymbols1ḷ-Regular Type 1 yes yes no 23 ḷ newell:~/latex/help $ ps2pdf -dPDFSETTINGS=/prepress -dAutoRotatePages=/None -dEmb newell:~/latex/help $ du -h new.pdf 36K new.pdf newell:~/latex/help $ pdffonts new.pdf name type emb sub uni object ID ------------------------------------ ----------------- --- --- --- --------OJEPRS+NimbusSanL-BoldItal Type 1C yes yes no 23 ḷ OJIXHX+LMMathSymbols1ḷ-Regular Type 1C yes yes no 25 ḷ CYORGJ+NimbusSanL-Bold Type 1C yes yes no 13 ḷ MZVUTG+LMMathItalic12-Regular Type 1C yes yes yes 15 ḷ PWIYDZ+CMSS12 Type 1C yes yes no 17 ḷ QBTHSF+NimbusSanL-Regu Type 1C yes yes no 19 ḷ XMYGAL+NimbusSanL-ReguItal Type 1C yes yes no 21 ḷ Answer by taco-hoekwater Luatex never writes Type1C fonts. You will get smaller pdfs if you use OpenType/TrueType fonts instead of Type1 (luatex writes CIDType0 fonts for those) but otherwise pstopdf is the alternative. Unless someone supplies a patch, this situation is unlikely to change. Tags: fonts (Prev Q) (Next Q), ile-size (Prev Q) (Next Q)
Q: Reduce compilation time for opentype fonts (otf) Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) I have some opentype fonts (otf) which I use with fontspec. Everything works ine. During the compilation LuaLaTeX load the otf-iles in a temporary ile. For example: 290
(load: /home/marco/.texlive2ḷ11/texmf-var/luatex-cache/generic/fonts/otf/temp-FONT Is it possible to install the font via LuaLaTeX or fontspec that the compilation will be reduced? I know the script otins.py but maybe there is an easier way. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: marco-daniel Answer by topskip Short answer: no you can’t. Long answer: fontspec uses luaotload to load fonts. And luaotload (which is based on ConTeXt’s fontloader) needs a lot of information when you are in node-mode. This information is stored in big Lua tables that get loaded (created) when processing the document. And processing these tables take time. That said: it is possible to create your own font loader in LuaTeX which speeds up things. When you restrict yourself to the TeX way of handling fonts (no contextual ligatures AFAIK, no language dependent font usage), the required table is much smaller and therefore when using a cache, loading a font should only take a fraction of the time it takes with luaotload. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
Q: Measuring the true height of a character Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q) Suppose you have got a character that sits above the reference point. When you measure its height, the empty space above reference point gets also included in its height measurement but that is not the true height of the character itself. Thus How do you measure the correct height of a character. To see this better, please see the output of the following document: 291
\documentclass{minimal} \usepackage{fontspec} \usepackage{showcharinbox} \newfontfamily\testfont{XB Zar} \begin{document} \begin{center} \ShowCharInBox{\fontsiḶe{5ḷḷ}{51ḷ}\testfont \char"ḷ64ḷ} \end{center} \end{document} XB Zar font can be obtained from here. Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q) User: vafa-khalighi Answer by egreg With XeTeX the primitive \XeTeXglyphbounds is available. Skip code block \documentclass{article} \usepackage{fontspec} \newfontface{\geeḶa}{GeeḶa Pro} \begin{document} \edef\gid{\the\XeTeXcharglyph`- } Top: \the\XeTeXglyphbounds2 \gid Bottom: \the\XeTeXglyphbounds4 \gid
-\,\vrule width\dimexpr\fontcharwd\font`- -\XeTeXglyphbounds1 \gid -\XeTeXglyphbounds3 \gi height \XeTeXglyphbounds2 \gid depth \XeTeXglyphbounds4 \gid \,\vrule width \fontcharwd\font`- height \fontcharht\font`- depth \fontchardp\font`292
\ Real height \the\dimexpr\XeTeXglyphbounds2 \gid + \XeTeXglyphbounds4 \gid\relax \edef\gid{\the\XeTeXcharglyph`; }
;\,\vrule width\dimexpr\fontcharwd\font`- -\XeTeXglyphbounds1 \gid -\XeTeXglyphbounds3 \gi height \XeTeXglyphbounds2 \gid depth \XeTeXglyphbounds4 \gid \,\vrule width \fontcharwd\font`; height \fontcharht\font`; depth \fontchardp\font`; \ Real height \the\dimexpr\XeTeXglyphbounds2 \gid + \XeTeXglyphbounds4 \gid\relax {\geeḶa \edef\gid{\the\XeTeXcharglyph"ḷ64ḷ }
\char"ḷ64ḷ \,\vrule width\dimexpr\fontcharwd\font"ḷ64ḷ -\XeTeXglyphbounds1 \gid -\XeTeXglyphbounds3 height \XeTeXglyphbounds2 \gid depth \XeTeXglyphbounds4 \gid \,\vrule width \fontcharwd\font"ḷ64ḷ height \fontcharht\font"ḷ64ḷ depth \fontchardp\font" \xdef\therealheight{\the\dimexpr\XeTeXglyphbounds2 \gid + \XeTeXglyphbounds4 \gid\ }\ Real height \therealheight \end{document}
293
In the examples each character is followed by a rule drawn using the “real” dimensions and by a rule using the bounding box data. The irst two lines show how the bounding box data are represented for the hyphen. Tags: fonts (Prev Q) (Next Q), xetex (Prev Q) (Next Q)
Q: LuaTeX with unicode-math, how to get the font id of current math font Tags: fonts (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q) How can I query informations about the current math font? I tried the following in a document using unicode-math and Cambria Math font Skip code block \documentclass{article} \usepackage{unicode-math} \setmathfont{Cambria Math}
294
\begin{document} Try to get math font name inside math mode. \[ \directlua{ local font = fonts.identifiers[font.current()] local fullname = font.fullname tex.sprint(fullname) } \] \end{document} However, it is the font name of surrounding text font being printed in the
math font, as seen in the following picture. It seems that font.current() returns the current text font id instead of the math font even the code is inside math mode. Next, I serialized the fonts.identifiers table and get the id of math font. I replaced font.current() with an explicit number, 28 in this example, and the above code print the math font name correctly, as seen in the following.
So I guess the math font does have an ID in the fonts.identifiers table. But how do I get this ID automatically? Tags: fonts (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q) User: yan-zhou
295
Answer by egreg There is no concept of ”current math font” in TeX and the same is true for LuaTeX and XeTeX. The symbols are typeset using fonts assigned at the end of the formula using the concept of math family. However, it’s possible to access at the math font chosen via \setmathfont making it the current text font in a slighly tricky way: Skip code block \documentclass{article} \usepackage{unicode-math} \setmathfont{XITS Math} \begin{document} \sboxḷ{$$}\the\textfont2 \directlua{ local font = fonts.identifiers[font.current()] local fullname = font.fullname tex.sprint(fullname) } \end{document} This will print ”XITS Math-2”. This is because \the\textfont2 produces a font identiier that makes the font in family 2 the current text font. In traditional TeX, \textfont2 is the font used for the most common symbols in text size; unicode-math uses it for all the known symbols, but for technical reasons it has to maintain a copy of it also as \textfont3, hence the suix ”2”. The \sboxḷ{$$} is needed because LaTeX doesn’t actually assign fonts to math families until it has to typeset a formula. It would be possible also to say \makeatletter\check@mathfonts\makeatother because \check@mathfonts is the command used to assign fonts to families based on the current context. Other Lua facilities can be used to access the font number in the internal 296
tables, I guess. Tags: fonts (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q)
Q: Select a font via luaotload on lua side Tags: fonts (Prev Q) (Next Q) I’m creating a glyph node (a capital A) on lua side: \directlua{% n = node.new('glyph') n.font = font.current() n.char = 65 % ASCII code for capital A } I know how to select current font (font.current()). How can I access other fonts that are in luaotfload database (say texgyreschola-regular.otf as an example)? Tags: fonts (Prev Q) (Next Q) User: cjorssen Answer by philipp-gesang How can I access other fonts that are in luaotload database (say texgyreschola-regular.otf as an example)? In order to use a font with Luatex, it needs to be deined irst. The fontloader has a function fonts.definers.read() for that which has the same signature as the define_font callback. Its font lookup calls into Luaotload’s font index functionality so you can pass it any valid deinition string. On success, you will receive an object that satisies the description in the Luatex manual, ch. 5 “Font structure” so you can feed it directly into
297
font.define(). It returns the font id that was assigned by TeX to this particular font which you can use in the situation you describe. An example that assigns the font in a callback would be: Skip code block local glyph_t
= nodes.nodecodes.glyph
local fontify = function (id) return function (hd) for n in node.traverse (hd) do if n.id == glyph_t then n.font = id end end return hd end end local main = function () local tfmdata = fonts.definers.read ("file:iwona-regular.otf:mode=base", 42*2^16) local id = font.define (tfmdata) luatexbase.add_to_callback("pre_linebreak_filter", fontify (id), "userdata.stackexchange.fontify") tex.sprint "some text" end return main () -- vim:ft=lua:sw=2:et The entire TeX document: \input luaotfload.sty \directlua {dofile "\jobname.lua"} \bye
298
Tags: fonts (Prev Q) (Next Q)
Q: How to get \copyright when mixing T1 fonts and fontspec? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) This example: Skip code block \documentclass{minimal} 299
\usepackage{fontspec} \usepackage[T1]{fontenc} \usepackage[osf]{mathpaḶo} \begin{document} \copyright 2ḷ11 \end{document} Gives: ! LaTeX Error: Command \copyright unavailable in encoding T1. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.9 \copyright ?
2ḷ11
What can I do to get a copyright symbol? Is there another command I should use perhaps? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: jonalv Answer by leo-liu Quick solution: Use \textcopyright instead of \copyright. Now the copyright sign will be ouput in cmsy font, and there will be a font warning. This approach is somewhat bad because it produces a font substitution warning, and the use of CM fonts. The advantage is, you don’t need to modify the code much. And the font is exacly Palatino with its mathematical support provided by PSNFSS bundle. 300
Quick solution 2: \renewcommand*\copyright{{% \usefont{EU1}{lmr}{m}{n}\textcopyright}} It use the sign in Latin Modern fonts. This prevents the warnings. And use LMR font for this sign. The font command can be changed as you wish. e.g. \fontfamily{lmr}\selectfont. textcomp package uses an old set of fonts, in TS1 font encoding.
Suggested solution: Skip code block \documentclass{minimal} \usepackage{unicode-math} \setmainfont[Ligatures=TeX,Numbers=OldStyle]{TeX Gyre Pagella} \setmathfont{Asana Math} \begin{document} Test \copyright 2ḷ11 \end{document} Now all fonts are changed to OpenType ones. The result is somewhat similar with pdfLaTeX + pxfonts package. Answer by egreg I’d load mathpazo before fontspec; moreover fontenc isn’t needed, since you’ll want to set the fonts with fontspec. \usepackage[osf]{mathpaḶo} \usepackage{fontspec} 301
\setmainfont[Ligatures=TeX,Numbers=OldStyle]{TeX Gyre Pagella} \begin{document} \copyright 2ḷ11 \end{document} Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
Q: Why is \setmainfont case sensitive with XelateX but not with LuaLaTeX? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q) Consider the following MWE \documentclass{article} \usepackage{lipsum} \usepackage{fontspec} \setmainfont{tex Gyre Pagella} \begin{document} \lipsum[1] \end{document} If I compile it with LuaLaTeX all is ine. But, if I compile it with XeLaTeX I get the error Skip code block !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! fontspec error: "font-not-found" ! ! The font "tex Gyre Pagella" cannot be found. ! 302
! See the fontspec documentation for further information. ! ! For immediate help type H . !............................................... l.7 \setmainfont{tex Gyre Pagella} ? This is because I’ve written tex Gyre Pagella instead of TeX Gyre Pagella in the argument of \setmainfont. If I change it to TeX Gyre Pagella then XeLaTeX compiles it. Why this behavior? Do LuaLaTeX and XeLaTeX load diferent fontspec packages or there is something else that I’m missing? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q) User: sterry Answer by paul-gessler CW from the comments: luaotfload normalizes all names supplied by the font. Apart from lowercasing you can also leave out spaces if you wish. So, for XeLaTeX, spacing and casing are signiicant, while for LuaLaTeX, they are not. This is not engine-dependent, just how luaotfload (and, incidentally, ConTeXt) treat things. The rationale is simple: Font names are a horrible mess that will haunt you and your descendants to the ifth generation if you attempt to uncover a system behind them. Since capitalization of identiiers can vary even within a font family, the only sane approach is to eliminate it completely. For info about luaotfload read texdoc luaotfload and man 1 luaotfload-tool.
303
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q)
Q: Problem with (\cyrishrt) in LuaLaTeX Tags: fonts (Prev Q) (Next Q) Initially I’ve asked a diferent question, but digging up I’ve found a true reason. The problem occurs when Cyrillic letter is used with maths in another font in the same paragraph. Here is the minimal example: \documentclass{minimal} \usepackage{fontspec} \setmainfont{Cambria} \begin{document} $xy$ \end{document} The compilation stops and the error is following: error: ...s/MiKTeX 2.9 /tex/luatex/luaotfload/otfl-node-inj.lua:225: attempt to index local 'tm' (a nil value) . \newpage ...k \@nobreakfalse \everypar {}\fi \par \vfil \penalty -\@M l.6 \end{document} When they are in diferent paragraphs e.g. the document body is \begin{document} $xy$ \end{document}
304
then there is no problem. Also there is no problem as well if I use the same math font e.g. with \usepackage{unicode-math} \setmathfont{Cambria Math} But still the compilation stops if I use a symbol from a diferent font (e.g. \Box from amssymb). UPD: I get the same problem with other accented letters, not only Cyrillic: à, , , , , etc, except i. UPD2: Happens only with Cambria. Tags: fonts (Prev Q) (Next Q) User: georgiy Answer by georgiy This was a problem with my Cambria font installation. In the Windows/Fonts folder, there were Cambria Italic.ttf, Cambria Bold.ttf, Cambria Bold Italic.ttf containing the corresponding fonts and Cambria.ttc containing both Cambria Regular and Cambria Math. So with bold and italic there was no problem, but somehow using regular lead to a problem when LuaLaTeX used Cambria Regular from Cambria.ttc. When I copied Cambria.ttf from Vista installation DVD and deleted luatex-cache folder, the problem had gone. Tags: fonts (Prev Q) (Next Q)
Q: Why does LuaTeX not generate some fonts automatically, in contrast with TeX? Tags: fonts (Prev Q) (Next Q)
305
Consider the following example, using font lhr1ḷ (texlive-lang-cyrillic package in debian): \font\myfont=lhr1ḷ \myfont A \bye Compile it with LuaTeX: Skip code block $ dviluatex test.tex This is LuaTeX, Version beta-ḷ.8ḷ.ḷ (TeX Live 2ḷ15/Debian) (rev 5238) restricted \write18 enabled. (./test.tex ! Font \myfont=lhr1ḷ not loadable: metric data not found or bad.
\myfont l.2 \myfont ? Now compile it with TeX: Skip code block $ tex test.tex This is TeX, Version 3.14159265 (TeX Live 2ḷ15/Debian) (preloaded format=tex) (./test.tex kpathsea: Running mktextfm lhr1ḷ mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input This is METAFONT, Version 2.7182818 (TeX Live 2ḷ15/Debian) (preloaded base=mf)
kpathsea: Running mktexmf lhr1ḷ mf: /usr/local/share/texmf/fonts/source/lh/lh-lcy/lhr1ḷ.mf: successfully generated (/usr/local/share/texmf/fonts/source/lh/lh-lcy/lhr1ḷ.mf (/usr/share/texlive/texmf-dist/fonts/source/lh/base/fikparm.mf (/usr/share/texlive/texmf-dist/fonts/source/public/cm/cmbase.mf) (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lcyrbeg.mf) 306
(/usr/share/texlive/texmf-dist/fonts/source/lh/base/lkligtbl.mf) >> 1ḷ >> "input cmr1ḷ" (/usr/share/texlive/texmf-dist/fonts/source/public/cm/cmr1ḷ.mf ) (/usr/share/texlive/texmf-dist/fonts/source/lh/lh-lcy/lhcodes.mf) (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lcyrdefs.mf) (/usr/share/texlive/texmf-dist/fonts/source/lh/base/ldroman.mf (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lxpseudo.mf) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/romanu.mf [65] [66] [67] [68] [69] [7ḷ] [71] [72] [73] [74] [75] [76] [77] [78] [79] [8ḷ] [81] [82] [83] [84] [85] [86] [87] [88] [89] [9ḷ]) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/romanl.mf [97] [98] [99] [1ḷḷ] [1ḷ1] [1ḷ2] [1ḷ3] [1ḷ4] [1ḷ5] [1ḷ6] [1ḷ7] [1ḷ8] [1ḷ9] [11ḷ] [111] [112] [113] [114] [115] [116] [117] [118] [119] [12ḷ] [121] [122]) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/greeku.mf [ḷ] [1] [2] [3] [4] [5] [6] [7] [8] [9] [1ḷ]) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/romand.mf [48] [49] [5ḷ] [51] [52] [53] [54] [55] [56] [57]) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/romanp.mf [36] [38] [63] [62]) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/romspl.mf [16] [17] [25] [26] [27] [28]) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/romspu.mf [29] [3ḷ] [31]) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/punct.mf [33] [6ḷ] [35] [37] [39] [4ḷ] [41] [42] [43] [44] [46] [47] [58] [59] [61] [64] [91] [93] [96]) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/accent.mf [18] [19] [2ḷ] [21] [22] [23] [24] [32] [94] [95] [125] [126] [127]) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/romlig.mf [11] [12] [13] [14] [15]) (/usr/share/texlive/texmf-dist/fonts/source/public/cm/comlig.mf [34] [45] [92] [123] [124]) (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lgcyru.mf (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lgrusu.mf [128] [129] [13ḷ] [131] [132] [133] [134] [135] [136] [137] [138] [139] [14ḷ] [141] [142] [143] [144] [145] [146] [147] [148] [149] [15ḷ] [151] [152] [153] [154] [155] [156] [157] [158] [159] [24ḷ]) (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lgt2comu.mf [246] [248] [242] [25ḷ] [244])) (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lgcyrl.mf (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lgrusl.mf [16ḷ] [161] [162] [163] [164] [165] [166] [167] [168] [169] [17ḷ] [171] [172] [173] 307
[174] [175] [224] [225] [226] [227] [228] [229] [23ḷ] [231] [232] [233] [234] [235] [236] [237] [238] [239] [241]) (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lgt2coml.mf [247] [243] [249] [251] [245])) (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lgcyrsym.mf [196] [252] [197] [255] [253] [254]) (/usr/share/texlive/texmf-dist/fonts/source/lh/base/lgcyracc.mf) (/usr/share/texlive/texmf-dist/fonts/source/lh/base/llvligtb.mf) (/usr/share/texlive/texmf-dist/fonts/source/lh/lh-lcy/lhliker.mf) ) ) ) (some charht values had to be adjusted by as much as ḷ.ḷ71ḷ1pt) Font metrics written on lhr1ḷ.tfm. Output written on lhr1ḷ.6ḷḷgf (21ḷ characters, 41768 bytes). Transcript written on lhr1ḷ.log. mktextfm: /usr/local/share/texmf/fonts/tfm/lh/lh-lcy/lhr1ḷ.tfm: successfully gener [1] ) Output written on test.dvi (1 page, 252 bytes). Transcript written on test.log. Why LuaTeX does not generate this font automatically? EDIT If we run dviluatex after the font is generated by tex, it works without problems. If we run luatex in pdf mode after the font is generated by tex (it gives the same ”metric data not found or bad” error if we do not generate the font with tex before), it gives this error: Skip code block This is LuaTeX, Version beta-ḷ.8ḷ.ḷ (TeX Live 2ḷ15/Debian) (rev 5238) (./test.tex [1{/usr/local/share/texmf/fonts/map/pdftex/updmap/pdftex.map}]){/usr /share/texmf/fonts/enc/dvips/lm/lm-rm.enc} kpathsea: Running mktexpk --mfmode / --bdpi 72 --mag 1+ḷ/72 --dpi 72 lhr1ḷ mktexpk: Mismatched mode ljfour and resolution 72; ignoring mode. mktexpk: Can't guess mode for 72 dpi devices. mktexpk: Use a config file or option to specify the mode; see: mktexpk: http://tug.org/texinfohtml/kpathsea.html#Unable-to-generate-fonts kpathsea: Appending font creation commands to missfont.log. !LuaTeX error (file lhr1ḷ): Font lhr1ḷ at 72 not found 308
==> Fatal error occurred, no output PDF file produced! If we specify \pdfpkresolution=6ḷḷ, it works without problems: This is LuaTeX, Version beta-ḷ.8ḷ.ḷ (TeX Live 2ḷ15/Debian) (rev 5238) (./test.tex [1{/usr/local/share/texmf/fonts/map/pdftex/updmap/pdftex.map}]){/usr /share/texmf/fonts/enc/dvips/lm/lm-rm.enc} Fatal error occurred, no output PDF file produced! If I add the \starttext ... \stoptext and compile it using context instead of luatex, it works all right. So, at this point I am quite puzzled. How can I use the msbm10 font in plain LuaTeX? Edit: The problem was that I was using luatex from a ConTeXt installation. With luatex from TeXlive, it works all right. Thanks. Tags: fonts (Prev Q) (Next Q)
373
User: yann Answer by topskip Note: you are not using ”plain”, but something that is related to ConTeXt. luatex-plain.tex is only in the ConTeXt distribution, and it surely has a very special way of dealing with fonts. If you really want plain TeX, then use plain TeX. Just call luatex foo.tex and you are ine. Even with the msbm1ḷ font. If this answer is not what you are looking for, please write what you want to achieve. Tags: fonts (Prev Q) (Next Q)
Q: Avoid update font name database by luaotload Tags: fonts (Prev Q) (Next Q) I am using LuaLaTeX to typesetting documents with system fonts. Compiling needs much time to update the font database: luaotfload | Updating the font names database:. I think this update is not necessary, because I do not change the fonts every time. If my assumption is correct, is it possible to avoid this update? A minimal example that shows the problem: \documentclass[paper = a4]{scrartcl} \usepackage{blindtext, fontspec}
% Typewriter (\ttfamily) \setmonofont[BoldFont = VeraMoBd, ItalicFont = VeraMoIt, Scale = MatchLowercase]{V \begin{document} 374
\blinddocument \end{document} I used diferent fonts set by \setmainfont and \setsansfont, but only the mono-spaced VeraMono hangs on updating the font names database. The free font Bitstream Vera is available here. Tags: fonts (Prev Q) (Next Q) User: dirk Answer by ulrike-ischer To sum up the discussion in the comments: luaotfload updated the font name databases at each run because the font names where wrong and so luaotfload couldn’t ind the font by name in the database (it did ind it in the end as VeraMono is the ile name). The correct call is:
\setmonofont[BoldFont = BitstreamVeraSansMono-Bold, ItalicFont = BitstreamVeraSans The correct font name can be found e.g. in the font selection dialog of some other oice application, or in the database created by luaotload (otfl-names.lua with the older versions of luaotload (TL2012/current miktex) and luaotfload-names.lua in TL2013). A list of fonts can printed as described in https://tex.stackexchange.com/a/ 14171/14200 (the actual code depends on the luaotload version). Tags: fonts (Prev Q) (Next Q)
Q: When using unicode math, the math glyphs disappear Tags: fonts (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q)
375
Recently, I wanted to use unicode-math to introduce better distinguishable greek letters (e.g. boldface) at some point. However, I cannot seem to make things work. Here is my MWE: Skip code block \documentclass{standalone} \usepackage{unicode-math} % Must be loaded after amsmath. %\setmathfont{Asana Math} % No matter what I select here \setmathfont{XITS Math} \begin{document} $$ \alpha, \beta, \lambda $$ \end{document} No matter, which math font I choose, the greek letters are not shown and the log contains lines like: Missing character: There is no ript=latn;+trep;+tlig;"!
(U+1D6FC) in font "file:lmroman1ḷ-regular:sc
(ironically, my terminal does show the alpha). Why is the lookup being done in lmroman10-regular:sc (and how do I ix this)? edit: lualatex --version: This is LuaTeX, Version beta-ḷ.8ḷ.ḷ (TeX Live 2ḷ16/dev) (rev 5238) Filelist: Skip code block standalone.cls ifluatex.sty ifpdf.sty ifxetex.sty xkeyval.sty xkeyval.tex standalone.cfg ass article.cls
2ḷ15/ḷ7/15 v1.2 Class to compile TeX sub-files standalone 2ḷ1ḷ/ḷ3/ḷ1 v1.3 Provides the ifluatex switch (HO) 2ḷ11/ḷ1/3ḷ v2.3 Provides the ifpdf switch (HO) 2ḷ1ḷ/ḷ9/12 vḷ.6 Provides ifxetex conditional 2ḷ14/12/ḷ3 v2.7a package option processing (HA) 2ḷ14/12/ḷ3 v2.7a key=value parser (HA) 2ḷ15/ḷ7/15 v1.2 Default configuration file for 'standalone' cl 2ḷ14/ḷ9/29 v1.4h Standard LaTeX document class 376
siḶe1ḷ.clo 2ḷ14/ḷ9/29 v1.4h Standard LaTeX file (siḶe option) unicode-math.sty 2ḷ15/ḷ9/ḷ9 vḷ.8b Unicode maths in XeLaTeX and LuaLaTeX expl3.sty 2ḷ15/ḷ9/11 v6ḷḷ2 L3 programming layer (loader) expl3-code.tex 2ḷ15/ḷ9/11 v6ḷḷ2 L3 programming layer l3unicode-data.def 2ḷ15/ḷ7/2ḷ v5676 L3 Unicode data l3pdfmode.def 2ḷ15/ḷ9/1ḷ v5983 L3 Experimental driver: PDF mode ucharcat.sty 2ḷ15/ḷ8/23 vḷ.ḷ2 ucharcat for luaLaTeX (DPC) xparse.sty 2ḷ15/ḷ9/11 v6ḷḷ1 L3 Experimental document command parser l3keys2e.sty 2ḷ15/ḷ9/11 v6ḷḷ1 LaTeX2e option processing using LaTeX3 keys fontspec.sty 2ḷ15/ḷ7/22 v2.4d Font selection for XeLaTeX and LuaLaTeX luaotfload.sty 2ḷ14/ḷ8/1ḷ v2.5-4 OpenType layout system luatexbase.sty 2ḷ13/ḷ5/11 vḷ.6 Resource management for the LuaTeX macro progr ammer luatex.sty 2ḷ1ḷ/ḷ3/ḷ9 vḷ.4 LuaTeX basic definition package (HO) infwarerr.sty 2ḷ1ḷ/ḷ4/ḷ8 v1.3 Providing info/warning/error messages (HO) etex.sty 2ḷ15/ḷ9/ḷ2 v2.4 eTeX basic definition package (PEB,DPC) luatex-loader.sty 2ḷ1ḷ/ḷ3/ḷ9 vḷ.4 Lua module loader (HO) luatexbase-compat.sty 2ḷ11/ḷ5/24 vḷ.4 Compatibility tools for LuaTeX luatexbase-modutils.sty 2ḷ13/ḷ5/11 vḷ.6 Module utilities for LuaTeX luatexbase-loader.sty 2ḷ13/ḷ5/11 vḷ.6 Lua module loader for LuaTeX luatexbase-regs.sty 2ḷ11/ḷ5/24 vḷ.4 Registers allocation for LuaTeX luatexbase-attr.sty 2ḷ13/ḷ5/11 vḷ.6 Attributes allocation for LuaTeX luatexbase-cctb.sty 2ḷ13/ḷ5/11 vḷ.6 Catcodetable allocation for LuaTeX luatexbase-mcb.sty 2ḷ13/ḷ5/11 vḷ.6 Callback management for LuaTeX fontspec-patches.sty 2ḷ15/ḷ7/22 v2.4d Font selection for XeLaTeX and LuaLaTeX fontspec-luatex.sty 2ḷ15/ḷ7/22 v2.4d Font selection for XeLaTeX and LuaLaTeX fontenc.sty eu2enc.def 2ḷ1ḷ/ḷ5/27 vḷ.1h Experimental Unicode font encodings eu2lmr.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern xunicode.sty 2ḷ11/ḷ9/ḷ9 vḷ.981 provides access to latin accents and many othe r characters in Unicode lower plane eu2lmss.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern graphicx.sty 2ḷ14/1ḷ/28 v1.ḷg Enhanced LaTeX Graphics (DPC,SPQR) graphics.sty 2ḷ14/1ḷ/28 v1.ḷp Standard LaTeX Graphics (DPC,SPQR) trig.sty 1999/ḷ3/16 v1.ḷ9 sin cos tan (DPC) graphics.cfg 2ḷ1ḷ/ḷ4/23 v1.9 graphics configuration of TeX Live pdftex.def 2ḷ11/ḷ5/27 vḷ.ḷ6d Graphics/color for pdfTeX 377
ltxcmds.sty 2ḷ11/11/ḷ9 v1.22 LaTeX kernel commands for general use (HO) fontspec.cfg catchfile.sty 2ḷ11/ḷ3/ḷ1 v1.6 Catch the contents of a file (HO) etexcmds.sty 2ḷ11/ḷ2/16 v1.5 Avoid name clashes with e-TeX commands (HO) fix-cm.sty 2ḷ15/ḷ1/14 v1.1t fixes to LaTeX ts1enc.def 2ḷḷ1/ḷ6/ḷ5 v3.ḷe (jk/car/fm) Standard LaTeX file filehook.sty 2ḷ11/1ḷ/12 vḷ.5d Hooks for input files unicode-math-luatex.sty lualatex-math.sty 2ḷ14/ḷ8/18 v1.4 Patches for mathematics typesetting with Lu aLaTeX etoolbox.sty 2ḷ15/ḷ8/ḷ2 v2.2a e-TeX tools for LaTeX (JAW) unicode-math-table.tex t3cmr.fd 2ḷḷ1/12/31 TIPA font definitions supp-pdf.mkii pdftexcmds.sty 2ḷ11/11/29 vḷ.2ḷ Utility functions of pdfTeX for LuaTeX (HO) epstopdf-base.sty 2ḷ1ḷ/ḷ2/ḷ9 v2.5 Base part for package epstopdf grfext.sty 2ḷ1ḷ/ḷ8/19 v1.1 Manage graphics extensions (HO) kvdefinekeys.sty 2ḷ11/ḷ4/ḷ7 v1.3 Define keys (HO) kvoptions.sty 2ḷ11/ḷ6/3ḷ v3.11 Key value format for package options (HO) kvsetkeys.sty 2ḷ12/ḷ4/25 v1.16 Key value parser (HO) epstopdf-sys.cfg 2ḷ1ḷ/ḷ7/13 v1.3 Configuration of (r)epstopdf for TeX Live Tags: fonts (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q) User: choeger Answer by egreg Without the varwidth option, standalone typesets the document in a horizontal box and there $$ just means an empty math formula. Thus \alpha, \beta and \gamma are being typeset in text mode. By a precise choice of the LuaTeX team, a math symbol in text mode doesn’t raise an error and tries to typeset the (character corresponding to the) symbol in the current font. In other words, you have discovered another good reason for never using $$ in LaTeX. With \[...\] you get a diferent error message: ! LaTeX Error: Bad math environment delimiter.
378
See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.9 \] Not really very helpful, but perhaps it could lead you to a real solution. However, using \[...\] with the varwidth option will not give the wanted result. Here’s the right way: Skip code block \documentclass{standalone} \usepackage{unicode-math} % Must be loaded after amsmath. %\setmathfont{Asana Math} \setmathfont{XITS Math} \begin{document} $\displaystyle \alpha, \beta, \lambda $ \end{document} Tags: fonts (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q)
Q: Does lualatex embed fonts for compatibility? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) I am using fonts installed on my computer in LaTeX document as \documentclass{article} \usepackage{fontspec} \newfontfamily\fontx{Ubuntu} \begin{document} 379
The default font {\fontx New font} The default font \end{document} I create the pdf ile with lualatex command. How custom fonts are embedded in the pdf document for the sake of compatibility? Readers probably does not have this custom font; does this make a problem in displaying the pdf document? My knowledge about fonts is very limited. Sorry if it is a basic question. I just want to be sure about the compatibility of my pdf document when using rare fonts, and how to guarantee the document compatibility in diferent systems. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: googlebot Answer by topskip Fonts are always embedded, unless explicitly forced not to. Only the glyphs used in the font are put into the PDF (called subsetting). There are two ways to use fonts in LuaTeX. The irst is via the classical mechanism of tfm iles and pdftex.map: You can edit the ile pdftex.map on your TeX system to a) force the whole font to be included (license issues might have to be considered) or to b) stop LuaTeX from putting any font information in the PDF ile at all, but 99.999% of the users probably leave the settings The second way with LuaTeX (that is what you use) is to directly include Type1/TrueType/OpenType fonts via the interface provided by luaotload/fontspec. I am not sure if luaotload allows a diferent setting than subsetting the fonts. In theory, it could be conigured. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
380
Q: Changing numbers font features while changing shape Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) I am writing a document with the main font set up with old numbers, but I would like to have the ”normal” style in the tables. This works but one particular table has some of the numbers in italic and somehow I cannot ind a way of changing the font feature for these. It turns out that the table is irrelevant and using \itshape or \em or \textit{} in normal text give the same result: Skip code block \documentclass[preview,border=2px,12pt]{standalone} \usepackage{fontspec} \setmainfont [Numbers = {Proportional,OldStyle}]{Linux Libertine O} \begin{document}
2189 89283 98239 8ḷ98 2983 ḷ98ḷ23 \textit{13928439ḷ2984u2983ḷ} {\itshape 1981987ḷ9
{ \addfontfeatures{Numbers={Lining,Monospaced}, ItalicFeatures={Numbers={Lining,Mono 2189 89283 98239 8ḷ98 2983 ḷ98ḷ23 \textit{13928439ḷ2984u2983ḷ} \itshape 1981987ḷ92 } \end{document}
Any idea what I am doing wrong? Or have I hit a bug? Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: artourter Answer by egreg 381
With XeLaTeX I get the warning ************************************************* * fontspec warning: "icu-feature-not-exist-in-font" * * OpenType feature 'Numbers=Lining,Monospaced' (+tnum) not available for font * 'Linux Libertine O/BI' with script 'Latin' and language 'Default'. ************************************************* that’s probably the cause for this. I get the expected result by deining a new font family, instead of adding features on the ly: Skip code block \documentclass[varwidth,border=2pt,12pt]{standalone} \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \setmainfont [Numbers = {Proportional,OldStyle}]{Linux Libertine O} \newfontfamily{\libertinelf}{Linux Libertine O} \begin{document}
2189 89283 98239 8ḷ98 2983 ḷ98ḷ23 \textit{13928439ḷ2984u2983ḷ} {\itshape 1981987ḷ9
{\libertinelf 2189 89283 98239 8ḷ98 2983 ḷ98ḷ23 \textit{13928439ḷ2984u2983ḷ} \itshape 1981987ḷ92 } \end{document}
Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
382
Q: Macro to calculate \baselineskip for given font Tags: fonts (Prev Q) (Next Q), macros (Next Q), latex3 (Next Q) I want to write a macro that returns the \baselineskip multiplied with a ixed value for a given font spec. That seems to be harder than I would imagine... after some iddling I came up with this: Skip code block \ExplSyntaxOn \box_new:N \baseline_box \newcommand{\threeLineSkip}[1]{ %\box_new:N \baseline_box \hbox_set:Nn \baseline_box { #1 \rule{1pt}{\baselineskip} g } 3\box_ht:N \baseline_box
} \ExplSyntaxOff
\newlength{\test} \setlength{\test}{\threeLineSkip{\Huge}} \typeout{\the\test} Obviously, this doesn’t work yet, otherwise I wouldn’t be asking the question. The error is on the \setlength line: ! Illegal unit of measure (pt inserted). But I don’t understand why. I would even love to have a LuaTeX solution, but I don’t even know how to begin with that one. Tags: fonts (Prev Q) (Next Q), macros (Next Q), latex3 (Next Q) User: mib Answer by clemens Setting a box is not expandable and so \threeLineSkip cannot expand to a length. Because of that \setlength chokes as it demands a length as 383
argument. You can circumvent this by deining a new command for setting the length: Skip code block \documentclass{article} \usepackage{expl3,xparse} \ExplSyntaxOn \box_new:N \l_MiB_baseline_box \NewDocumentCommand \SetThreeLineSkip { mm } { \MiB_set_three_line_skip:Nn #1 { #2 } } \cs_new_protected:Npn \MiB_set_three_line_skip:Nn #1#2 { \hbox_set:Nn \l_MiB_baseline_box { #2 \rule {1pt} {\baselineskip} g } \skip_set:Nn #1 { 3\box_ht:N \l_MiB_baseline_box } } \ExplSyntaxOff \newlength{\test} \SetThreeLineSkip\test{\Huge} \begin{document} \the\test \end{document} Tags: fonts (Prev Q) (Next Q), macros (Next Q), latex3 (Next Q)
384
Q: Using Iwona as a math font with lualatex Tags: fonts (Prev Q) (Next Q) I would like to use Iwona as a math font, but this setup doesn’t get all math symbols right. (Multiline bracket, the sum symbol, etc.) \setmathfont{Iwona} \setmathfont[range=\mathup] {Iwona} \setmathfont[range=\mathbfup]{Iwona Bold} \setmathfont[range=\mathbfit]{Iwona Bold Italic} \setmathfont[range=\mathit] {Iwona Italic} I guess that Iwona doesn’t have all the math symbols that are necessary, so what should I do? (But at this link, http://www.tug.dk/FontCatalogue/iwona/, I notice that the math symbols are available). I am a bit puzzled. Edit my preamble Skip code block
documentclass[12pt,a4paper,twoside,openright,oneside,openany,titlepage,frontespiḶi \usepackage{fontspec} \PassOptionsToPackage{protrusion=true,final}{microtype} \newfontfeature{Microtype}{protrusion=default;expansion=default;} \usepackage{polyglossia} \usepackage{subfig} \usepackage[eulerchapternumbers,subfig,pdfspacing,listings]{classicthesis} \usepackage{arsclassica} \usepackage{amsmath,amssymb,amsthm} \usepackage{unicode-math} \usepackage[math]{iwona} \setmainfont[Microtype,Ligatures=TeX]{Minion Pro} \setsansfont{Iwona} \setmathfont{Iwona} % \setmathfont[range=\mathup] {Iwona} \setmathfont[range=\mathbfup]{Iwona Bold} 385
\setmathfont[range=\mathbfit]{Iwona Bold Italic} \setmathfont[range=\mathit] {Iwona Italic} Tags: fonts (Prev Q) (Next Q) User: thunder1123 Answer by egreg I ind no reason whatsoever for having math in Iwona when the main text font is Minion Pro. However, here’s how you can do it: Skip code block \documentclass[ 12pt, a4paper, twoside, openright, oneside, openany, titlepage, headinclude, footinclude, BCOR5mm, cleardoublepage=empty, tablecaptionabove, ]{scrreprt} \PassOptionsToPackage{protrusion=true,final}{microtype} \usepackage{subfig} \usepackage[eulerchapternumbers,subfig,pdfspacing,listings]{classicthesis} \usepackage{arsclassica} \usepackage{amsmath} \usepackage[math]{iwona} \usepackage{fontspec} \usepackage{polyglossia}
386
\newfontfeature{Microtype}{protrusion=default;expansion=default;} \setmainfont[Microtype,Ligatures=TeX]{Minion Pro}
\ExplSyntaxOn \SetSymbolFont{operators}{iwona}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\md \SetSymbolFont{operators}{iwonabold}\g_fontspec_encoding_tl\g__fontspec_mathrm_t \ExplSyntaxOff \begin{document} \[ \sqrt{2\arcsin 1}=\sqrt[4]{6\sum_{k\ge1}\frac{1}{k^{2}}}= \int_{-\infty}^{\infty}e^{-x^{2}}\,dx \quad\text{text} \] \end{document} Note that there is no OpenType math font for Iwona, so using unicode-math is out of the question. The lines between \ExplSyntaxOn and \ExplSyntaxOff are to use the text font for operators and digits, otherwise Iwona would be used.
Tags: fonts (Prev Q) (Next Q)
Q: How to use TeX Gyre Pagella in pdlatex for arXiv Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), pdftex (Prev Q) (Next Q) Since arXiv still doesn’t seem to support LuaLaTeX, I need to make my document work with pdfLaTeX instead. The only LuaLaTeX-speciic stuf is 387
\usepackage{fontspec} \usepackage{unicode-math} \setmainfont[Ligatures=TeX]{TeX Gyre Pagella} \setmathfont{TeX Gyre Pagella Math} If I want the document to look as close to the one I compile with LuaLaTeX as possible, what do I need to do in terms of fonts? What diferences can I expect? Is there anything in particular I should be on the lookout for? Are there subtleties that I really need to check in detail? There is no other LuaLaTeX-speciic stuf in my document, and it does compile ine with pdlatex once I replace some unicode symbols (but, of course, it looks entirely diferent). Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), pdftex (Prev Q) (Next Q) User: gspr Answer by david-carlisle If you remove the lines you quote and add \usepackage{mathpaḶo} then you will be using a diferent but more or less similar Palatino clone usable in pdftex. Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q), pdftex (Prev Q) (Next Q)
Q: LuaLaTeX: Font table with examples of font iles (not system or TEXMF installed) Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
388
Looking at the answer to the question here, it is very close to what I wanted. What I wanted is to create font table with samples for font iles that are not system installed or in TEXMF trees, but font iles that reside in a path or on CD (no sub-folders, just the current folder will do). I am still learning and appreciate your help! Using MiKTeX 2.9 and Windows 7, with LuaLaTeX. EDIT: Inspired by Taco’s answer, I have come out with the following (modiied from Leo’s Code): Skip code block \documentclass{article} \usepackage{fontspec} \setmainfont{Latin Modern Mono Light} \usepackage{luacode} \usepackage[margin=18mm]{geometry} \parindent=ḷpt \usepackage{longtable,makecell} \renewcommand\arraystretch{2} \begin{document} \begin{luacode} teststring = "ḷ123456789 ABCDEFabcdef" tex.print(-2, os.getenv('FONTSPEC')) tex.print('\\\\') tex.print("\\begin{longtable}{ll}\\hline") for i,v in ipairs(dir.glob(os.getenv('FONTSPEC'))) do -- get rid of './' in front of filenames, fontspec don't like that local f = string.gsub(v, "^./", "") -- font name local info = fontloader.info(v) tex.print('\\makecell[l]{\\bfseries') tex.print(-2, info.fontname) -- font name here tex.print('\\\\[-1ex] \\scriptsiḶe') tex.print(-2, f) -- filename 389
tex.print('} & \\large\\fontspec{') tex.print(-2, f) tex.print('}') tex.print(teststring) tex.print('\\\\ \\hline') end tex.print("\\end{longtable}") \end{luacode} \end{document} It utilises an environment variable, FONTSPEC to specify the font iles search pattern, eg. *.ttf for TrueType iles in the current directory. Note that the TEX ile needs to be at the same directory where the font iles is and the glob pattern is CASE SENSITIVE! Sample run: set FONTSPEC=*.ttf lualatex fontsampler.ltx
390
Result: Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q) User: kf-leong Answer by taco-hoekwater I am a context user and I am sure I could come up with a macro-based context hack to do what you want in an hour or so if I tried hard enough. Because of that, I am sure similar hackery can be done by a knowledgeable lualatex user, but ... why spend time creating a complicated hack if a trivial script /batch ile can do the same simply by running luatex with an adjusted TEXMF or OSFONTDIR environment variable? 391
In fact, you could probably even change OSFONTDIR on the ly inside the document by putting something like \directlua { os.setenv('OSFONTDIR', '') } in the document preamble (untested, not behind a pc right now) Edit: it is even easier than that (at least in ConTeXt). I just tried some simple things, and absolute path names work in a font speciication in ConTeXt, so this runs ok for me: Skip code block
\starttext \startluacode context.starttabulate{"|p|"} for i,v in ipairs(dir.glob('/home/taco/tmp/itc/*.otf')) do local info = fontloader.info(v); context.NC() context(string.format('\\mono{%s}\\crlf %s\\crlf\\definedfont[%s]',v,info.fontna context("Sphinx of black quartḶ, judge my vow.") context.NC() context.NR() end context.stoptabulate() \stopluacode \stoptext Tags: fonts (Prev Q) (Next Q), fontspec (Prev Q) (Next Q)
Q: Can I downsize lua tables generated by luaotload? Tags: fonts (Prev Q) (Next Q) luatex loads a lot of otf fonts at every luaLaTeX run with my custom class (Minion Pro, Myriad Pro, Minion Math, Latin Modern Mono, Latin Modern Math, XITS). This is an extract taken from my custom class: 392
Skip code block \RequirePackage{fontspec} \RequirePackage[math-style = TeX]{unicode-math} \setmathfont[version=bold]{MinionMath-Bold} \setmathfont[Extension = .otf, Scale = 1, Script = Math, SiḶeFeatures = {% {% SiḶe = -6, Font = MinionMath-Tiny, Style = MathScriptScript}, {% SiḶe = 6-8.4, Font = MinionMath-Capt, Style = MathScript}, {% SiḶe = 8.4-, Font = MinionMath-Regular}, } ]{MinionMath-Regular} \setmathfont[range={\mathfrak}]{latinmodern-math.otf} \setmathfont[range={\mathcal}]{latinmodern-math.otf} \setmathfont[range={\mathscr}]{xits-math.otf} \setmathfont[range={}]{MinionMath-Regular.otf} \usepackage{unicode-minionmath} \setmainfont{MinionPro}[ Extension = .otf, UprightFont = *-Regular, BoldFont = *-Bold, ItalicFont = *-It, BoldItalicFont = *-BoldIt, ] 393
\setsansfont{MyriadPro}[ Extension = .otf, UprightFont = *-Regular, BoldFont = *-Semibold, ItalicFont = *-It, BoldItalicFont = *-SemiboldIt, ] \setmonofont{LatinModernMono} On my system (linux, SSD, core i3), each run takes at least 10 seconds. If I understand correctly, much of the time is spent reading byte compiled lua tables storing all the information needed to take care of an otf font.
Having a look at those tables (stored in ~/.texlive2ḷ16/texmf-var/luatex-cache/generic/font it seems to me that most of the elements (unicode characters) there are nearly never used in my documents (written in French: I need ASCII + some accented letters, probably less than 200 characters). Questions 1. Would luaotfload work if I build some lightweighted lua table iles ? 2. Is there a tool to tweak those lua table iles? If not, how can I do it manually and tell luaotfload to load it? 3. Will it speed up my compilation time? EDIT The answer to 2 might be building an appropriate subset of my fonts at font level with a tool like fontforge, thus creating a ”new” lightweight font. As far as my googling can tell, this technique is used with web ttf fonts to minimize font size for downloads. So I add an item 4 to my questions: ”Is subsetting a font a good way to downsize lua table iles? Can I use fontforge to do the work with otf fonts? How? Is there any licence restriction?” Tags: fonts (Prev Q) (Next Q) User: cjorssen Answer by philipp-gesang 394
luatex loads a lot of otf fonts at every luaLaTeX run with my custom class […] On my system (linux, SSD, core i3), each run takes at least 10 seconds. Are you referring to one entire pass of Luatex? I can’t say anything regarding Latex, but in Context that’s reached easily with more complex documents. If I understand correctly, much of the time is spent reading byte compiled lua tables storing all the information needed to take care of an otf font. Lua is a very eicient language. Parsing Lua programs is very eicient. Loading byte-compiled programs even more. It’s unlikely that this is the bottleneck you’re facing. You can verify that easily: Determine the cache path (last line of luaotfload-tool -h), list the subdirectory otl/ and select a bytecode ile. The extension is .luc. I choose one that is among the largest I know: kozminpr6n-regular.luc with 2,388,708 Bytes. These iles are valid Lua programs so we can load them directly with Luatex. For maximum IO penalty we also clear the OS caches irst:
$ sudo bash -c "echo 3 >/proc/sys/vm/drop_caches" $ time texlua /home/phg/.local/texlive/2ḷ16/texmf-var/luatex-cache/generic/fonts/o real user sys
ḷmḷ.24ḷs ḷmḷ.1ḷḷs ḷmḷ.ḷ17s
EDIT Some further measurements: I decided to check whether passing the font loaded from cache to Luatex had a signiicant performance impact. Turns out it’s negligible. Here’s a test setup that loads a list of fonts and measures the runtime. For more exact measurements it relies on the luaposix library. The timings are split into the cache retrieval per se (fonts.definers.read()) and feeding the result into font.define(). 395
To summarize the results: Forcing the 38 fonts through the loader adds 1.9 seconds to the runtime on my aged system; if the OS caches are hot this igure shrinks to around 1.5 s. Complex fonts from Adobe take around 50 ms to load. The huge koḶminpr6n-regular.otf is an outlier at ca. 300 ms for retrieval plus 50 ms for passing through font.define(). END EDIT 240s to load the Luatex binary, spawn the Lua interpreter, and load one gigantic font table. On a low-end desktop from 2012. Not bad, especially considering that fonts are usually loaded on demand, not merely by virtue of being deined at some point. Would luaotload work if I build some lightweighted lua table iles? Those are cache iles. They will be overwritten without asking next time anything changes. You will have to hack on the fontloader in order to make your changes stick. Is there a tool to tweak those lua table iles? As shown above, you can load them with Lua and manipulate them like any 396
ordinary table. The corresponding text representation (in the .lua iles) is plain text so you can use your editor. But they need to be byte-compiled (texluac(1)) for use with the loader. If not, how can I do it manually and tell luaotload to load it? The fontloader will look up a font ile in the cache irst, but it will also rewrite the cache if it doesn’t match the font ile. Thus you’ll have to hack the loader to avoid this. Will it speed up my compilation time? Very unlikely. Loading byte code is very eicient and once the tables are in memory, only those parts will be used that are needed for processing the input. The answer to 2 might be building an appropriate subset of my fonts at font level with a tool like fontforge Throw out the tables you don’t like. That will reduce the table size. Make sure you don’t violate the vendors’ license terms. Some of them preclude any modiication to the iles. Having a look at those tables […] it seems to me that most of the elements (unicode characters) there are nearly never used in my documents (written in French: I need ASCII + some accented letters, probably less than 200 characters). If you only typeset Latin based copy, a more promising approach would be to stick with base mode instead of node which Luaotload defaults to. That can speed up paragraph processing drastically. Tags: fonts (Prev Q) (Next Q)
Q: LuaLaTeX: german special character ß with ‘newpxtext‘ Tags: fonts (Prev Q) (Next Q) 397
I use the font Palatino from the package newpxtext in combination with LuaLaTeX. With this package it is not possible to set the german special character ß directly: Skip code block % Magic comments for TeXstudio % !TeX spellcheck = de_DE % !TeX program = lualatex \documentclass{scrartcl} %\usepackage{fontspec} % Font: Palatino \usepackage{newpxtext} \begin{document} Draußen währt am längsten. Drau\ss en währt am längsten. \end{document} The result from the MWE is: DrauSSen währt am längsten.. It works when I switch to fontspec. How is it possible to use the sign ß instead of \ss to set a text? Tags: fonts (Prev Q) (Next Q) User: dirk Answer by ulrike-ischer You can make the ß active and deine it: Skip code block \documentclass{scrartcl} \usepackage{newpxtext} 398
\catcode`\ß=13 \defß{\ss} \begin{document} Draußen währt am längsten. Drau\ss en währt am längsten. \end{document} That’s more or less what luainputenc does. But it is much better to use fontspec instead: \documentclass{scrartcl} \usepackage{fontspec} \setmainfont{TeX Gyre Pagella} %palatino clone \begin{document} Draußen währt am längsten. \end{document} Answer by franck-pastor Which input encoding are you using? If you don’t use fontspec, whatever the input encoding is you must indicate it to LuaLaTeX. E.g. if your editor is conigured with utf8-unicode, you must insert the line \usepackage[utf8]{luainputenc} in the preamble of your program. In that case your ile works perfectly for me. Tags: fonts (Prev Q) (Next Q)
399
Q: Can I use Wolfram Mathematica fonts in XeTeX / LuaTeX? Tags: fonts (Prev Q), xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q) Wolfram Mathematica comes with full (?) set of math fonts. Is it possible to use these fonts in XeLaTeX and LuaLaTeX? I mean something like \usepackage[math-style=ISO,bold-style=ISO]{unicode-math} \setmathfont[range=...]{Mathematica1} \setmathfont[range=...,Bold]{Mathematica1b} \setmathfont[range=...,???]{Mathematica1m} \setmathfont[range=...,???]{Mathematica1mb} \setmathfont[range=...]{Mathematica2} . . . \setmathfont[range=...]{Mathematica7} Tags: fonts (Prev Q), xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q) User: igor-kotelnikov Answer by joseph-wright Math typesetting is complex, and needs a lot of structures inside the font. OpenType math fonts have these, but TrueType ones don’t. I suspect that Mathematica relies on ’knowing’ details of the fonts, in the same way that traditional TeX math fonts are made up of several iles with a known relationship (to TeX). So you won’t be able to use these fonts with LuaTeX, or I suspect with the Word 2007/2010 equation editor (which also uses OpenType). Tags: fonts (Prev Q), xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q)
400
Fontspec Skip to questions, Wiki by user will-robertson This tag should be used for questions that relate to the fontspec package, which is used for loading OpenType fonts in XeLaTeX and LuaLaTeX. (Actually, fontspec can be used to load other sorts of fonts, too, but loading OpenType fonts is the main use case.)
Questions Q: How to suppress a ”Rare” ligature that pre-empts a ”Common” ligature for the same character pair? Tags: fontspec (Prev Q) (Next Q), opentype (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) In several documents I’m creating with LuaLaTeX (using MacTeX2012 on a Mac that’s running MacOS X 10.7.5), I primarily use the Adobe-issued font Garamond Premier Pro as the main text font. I use this font because it provides a slew of • ”Common” ligatures: These comprise not only the ive TeX-standard f-ligatures, viz., ff, fi, fl, ffi, and ffl, but also ligatures for ft, fft, fb, ffb, and a few more; and • ”Rare” (aka ”Discretionary”) ligatures: For this particular font, ”rare” ligatures are available for the character pairs ct, st, sp, and ft (but not fft; see also below) in both upright and italic shapes, as well as for the character pairs as, is, us, at, et, th and a few more in the italic font shape only. If just the ”Common” ligature set is enabled (via the option Ligatures=Common), the ft and fft groups, in both upright and italic shapes, are typeset like this: 401
Just in case this matters, the Unicode character representations for these ligatures are U+E18D and U+E187, respectively. In the upright font shape, the ”glyph id” numbers are 277 and 271 and the ”character codes” are 57742 and 57735, respectively. In the italic font shape, the Unicode character representations are the same, but the ”glyph id” and ”character code” numbers are 283 and 276, and 57864 and 57857, respectively. However, if the ”Rare” ligature set is enabled -- irrespective of whether the ”Common” ligature set is enabled as well -- the ft and fft character groups are rendered as follows:
(Aside: For another rendering of the ”rare”-style ft-ligature, check out the web page Garamond type ft-ligature.) Not only does the ”Rare”-style ft ligature look rather diferent from its ”Common”-style counterpart, the fft ligature no longer exists at all: the fft character triple is now rendered as a plain ”f” followed by the ”Rare”style ft ligature. For my purposes, the absence of a ligature for the fft character triple if ”Rare” ligatures are enabled is rather unfortunate. The fact that the crossbars of the ”f” and ”ft” glyphs don’t line up properly in the italic font shape is also rather problematic. Separately, I also prefer the look 402
of the ”Common”-style ft-ligature to that of its ”Rare”-style counterpart, but that’s only a secondary concern. (Incidentally, the Unicode character representation for the ”Rare” ft-ligature is U+E18E. In the upright font shape, its ”glyph id” and ”character number” codes are 278 and 57742, resp.; in the italic font shape the latter two numbers are 283 and 57864, resp.) My question is: Is there a way -- preferably using macros provided by the fontspec package -- to disable the ”Rare”-style ft ligature globally in order to re-enable the ”Common”-style ft ligature -- while still being able to use all other ”Rare” ligatures as well as the ”Common” ligatures? Just for completeness, here’s the code that generates the irst example above: % !TEX TS-program = lualatex \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=Common, ItalicFont={Garamond Premier Pro Italic}] {Garamond Premier Pro} \begin{document} ft fft \em ft fft \end{document} To generate the second example, replace the option Ligatures=Common with Ligatures={Common,Rare}. Tags: fontspec (Prev Q) (Next Q), opentype (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) User: mico Answer by khaled-hosny Some thing like this using feature iles should work: First the feature ile: Skip code block # scripts and languages, if the font use others they should be defined here too languagesystem DFLT dflt; languagesystem latn dflt; 403
# this undoes the effect of rare ligature on ft feature liga { sub f_t.alt by f t; } liga; # move rare ft to historic ligatures feature hlig { sub f t by f_t.alt; } hlig; # apply feature sub f sub f } liga;
the regular ligature on ft and fft liga { f t by f_f_t; t by f_t;
The order of the above is important, this way regular “ft” and “ft” are used even with Rare ligatures, but not with Historic. The glyph names should match those in the font with f_t.alt being the name of the unwanted “ft” ligature, and f_t & f_f_t being the names of the wanted ones. The full feature ile syntax is documented by Adobe (but LuaTeX supports v1.6 f the syntax + FontForge extension, not the current one, so there are some diferences). Then it can be applied to the font by using FeatureFile fontspec option: Skip code block \documentclass{article} \usepackage{fontspec} \begin{document} \fontspec[Ligatures={Common,Rare},FeatureFile=test.fea]{Garamond Premier Pro} ft fft \em ft fft \fontspec[Ligatures={Common,Rare,Historic},FeatureFile=test.fea]{Garamond Premier ft fft \em ft fft 404
\end{document} Tags: fontspec (Prev Q) (Next Q), opentype (Prev Q) (Next Q), ligatures (Prev Q) (Next Q)
Q: An example of changing kerning of a font in LuaLaTeX Tags: fontspec (Prev Q) (Next Q) LuaLaTeX, through the luaotload package, is able to dynamically add and modify features and properties of a font. This is performed by using the FeatureFile option in fontspec when loading a font; e.g., \setmainfont[FeatureFile=times-nr.fea]{Times New Roman} where times-nr.fea is given as a listing in the fontspec manual (see §11). The syntax of these feature iles is given by Adobe. Unfortunately, I haven’t had the chance to look into this myself and I’m not sure what’s possible nor how to do it. I’d like to add some more examples to the fontspec manual, especially for adjusting the side-bearings around single glyphs and adjusting the kerning between adjacent glyphs and so on. The ability to deine custom kerning for your fonts would truly make LuaLaTeX a world-class typesetting engine—no other TeX program is able to do this sort of thing so easily. I’d like to perform an experiment: the source for fontspec is on GitHub. I’ll ofer a bounty on this question for the best patch to the fontspec manual adding more documentation for the FeatureFile option, speciically for sidebearing and/or kerning but hopefully for anything else that you also might happen to see that’s fun. So, can anyone help? P.S. If you’re stuck on the fact that to compile fontspec.pdf requires a whole bunch of pre-built PDFs for the examples, you can grab them from CTAN. 405
Tags: fontspec (Prev Q) (Next Q) User: will-robertson Answer by khaled-hosny I did not want to interfere with this experiment, but since nobody posted an answer so far, I just pushed an update to the feature ile section of the documentation on github. It is not the most clear way to document it, but I tried my best (as far as my English permits :) ) Answer by user3432 Adjusting the kerning of the glyph pair fh in TeX Gyre Bonum would require something like the this ... bonum.fea languagesystem DFLT dflt; languagesystem latn dflt; feature kern { pos \f \h 125; } kern; test.tex \documentclass{article} \usepackage{fontspec} \setmainfont[FeatureFile=bonum.fea]{TeX Gyre Bonum} \begin{document} fh \end{document} There is a problem with the babel package, though ... test2.tex \documentclass{article} \usepackage[ngerman]{babel} \usepackage{fontspec} \setmainfont[FeatureFile=bonum.fea]{TeX Gyre Bonum} 406
\begin{document} fh aufhalten \end{document} As you can see, the adjusted kerning only applies to the irst instance of the glyph pair. When the glyph pair occurs inside a word, the adjusted kerning is not applied. When babel is not loaded, everything is ine. Tags: fontspec (Prev Q) (Next Q)
Q: Bad interaction between fontspec and some lua code that performs string-related search and replace operations Tags: fontspec (Prev Q) (Next Q), programming (Next Q) Update 2013/05/28: The selnolig package is now on the CTAN. Comments and critiques always welcome! If you wish to contact me about any aspects of the package, please use the email address that’s given at the bottom of the title page of the package’s user guide. (Relative to the state of the package described in the question below, I’ve managed to squash at least one bug, and I suggest better work-arounds for the remaining bugs -- at least the ones I’m aware of!) I’m in the process of readying a LuaLaTeX package for ”oicial” release to the CTAN, but I need to squash a few remaining bugs irst. The bug described in this question concerns incorrect behavior of my package that occurs if the fontspec package is loaded; if fontspec is not loaded, none of the problems described here occur. Obviously, asking potential users of my package not to load fontspec is not an option. Incidentally, the identiier string of the LuaTeX version on my system is ”beta-ḷ.7ḷ.2-2ḷ12ḷ62819”, distributed with MacTeX2012. For much more information about the full selnolig package, which does automated, selective suppression of typographic ligatures, please see New package, selnolig, that automates suppression of typographic ligatures. 407
The MWE (see image below, and code provided below image) illustrates several instances of failure to perform ligature suppression if -- and apparently also only if -- fontspec is loaded. Speciically, ligature suppression fails for: • a word that’s followed immediately by a comment (%) sign • the last word in the argument of a command such as \footnote and \section • a word that immediately precedes the start of an environment such as enumerate and itemiḶe • the inal word of an \item statement, i.e, the inal word before the next \item statement and/or the environment’s closing \end{enumerate/itemiḶe} directive A common theme of these problems is that they occur if the word in question (plus any trailing punctuation characters) is at the very end of some environment, group, or argument to some macro. In all cases, a ”remedy” of sorts is to insert either a space, a blank line, or a space plus something like \vphantom{x} [!]. Clearly, these remedies are not real solutions but merely kludgy hacks, and I certainly wouldn’t contemplate asking users of my package to do implement these hacks. My questions are, then: • How can I make my lua code more robust to whatever is being done by the fontspec pacakge (or some package that’s loaded by fontspec)? • Is there a way to load either fontspec (or some of the packages called by fontspec) to suppress the interference with my lua code? • Or, have I discovered a bug in fontspec (or one or more of the packages loaded by fontspec) that needs to be ixed anyway?
408
Skip code block % !TEX TS-program = lualatex \documentclass{article} % If the next line is commented out, everything works fine! \usepackage{fontspec} \RequirePackage{luatexbase,luacode,expl3} % Load lua code \directlua{ require("ld-orig.lua") } % see below for contents of ld-orig.lua % Define the user macro "nolig" \providecommand\nolig[2]{ \directlua{ suppress_liga( "\luatexluaescapestring{#1}", "\luatexluaescapestring{#2}" )}} % Provide a ligature suppression rule % (the full package obviously provides many more such macros) \nolig{lfful}{lf|ful} % shelfful -> shelf|ful
409
% Just for this MWE: \usepackage[textheight=8cm]{geometry} \setlength\parindent{ḷpt} \pagestyle{empty} \begin{document} Two shelffuls of \TeX-related books: it works! \bigskip % word to be de-ligated is followed immediately by % (comment character) Ligature suppression doesn't work here: shelfful% % leaving a space between word and % makes it work even if fontspec is loaded But it does work in this case: shelfful %
\bigskip bad\footnote{This doesn't work: shelfful.} % w/o space good\footnote{But this does work: shelfful. \vphantom{x}} % w/ space and \vphantom \bigskip % Two more problem cases: (i) last word before start of an % itemiḶe/enumerate environment, (ii) last word of an \item one shelfful, two shelffuls % no ligature suppression for "shelffuls" \begin{itemiḶe} \item shelfful % no ligature suppression here either \item shelfful \vphantom{x} % inserting space and \vphantom does the trick... \end{itemiḶe} % problem also occurs in arguments of sectioning commands \section*{sad shelfful} % again no ligature suppression \subsection*{happy shelfful } % adding space at end of argument makes it work! \end{document} Contents of ld-orig.lua: Skip code block --- Credits to Patrick Gundlach, Taco Hoekwater, and Steffen Hildebrandt! 410
local local local local
glyph = node.id('glyph') glue = node.id("glue") whatsit = node.id("whatsit") userdefined
for n,v in pairs(node.whatsits()) do if v == 'user_defined' then userdefined = n end end local identifier = 123456 -- any unique identifier local noliga={} debug=false -- default: don't write debugging info to log file function debug_info(s) if debug then texio.write_nl(s) end end local blocknode = node.new(whatsit, userdefined) blocknode.type = 1ḷḷ blocknode.user_id = identifier function process_ligatures(nodes,tail) local s={} local current_node=nodes local build_liga_table = function(strlen,t) local p={} for i = 1, strlen do p[i]=ḷ end for k,v in pairs(t) do -- debug_info("Match: "..v[3]) local c= string.find(noliga[v[3]],"|") local correction=1 while c~=nil do -- debug_info("Position "..(v[1]+c)) p[v[1]+c-correction] = 1 411
c = string.find(noliga[v[3]],"|",c+1) correction=correction+1 end end -- debug_info("Liga table: "..table.concat(p, "")) return p end local apply_ligatures=function(head,ligatures) local i=1 local hh=head local last=node.tail(head) for curr in node.traverse_id(glyph,head) do if ligatures[i]==1 then -- debug_info("Current glyph: "..unicode.utf8.char(curr.char)) node.insert_before(hh,curr, node.copy(blocknode)) hh=curr end last=curr if i==#ligatures then -- debug_info("Leave node list on position: "..i) break end i=i+1 end if(last~=nil) then -- debug_info("Last char: "..unicode.utf8.char(last.char)) end--]] end for t in node.traverse(nodes) do if t.id==glyph then
s[#s+1]=string.lower(unicode.utf8.char(t.char)) elseif t.id== glue then local f=string.gsub(table.concat(s,""),"[\\?!,\\.]+","") -- add all interpun local throwliga={} for k, v in pairs(noliga) do local count=1 local match= string.find(f,k) 412
while match do count=match -- debug_info("pattern match: "..f .." - "..k) local n = match + string.len(k)-1 table.insert(throwliga,{match,n,k}) match= string.find(f,k,count+1) end end if #throwliga==ḷ then -- debug_info("No ligature substitution for: "..f) else -- debug_info("Do ligature substitution for: "..f) local ligabreaks=build_liga_table(f:len(),throwliga) apply_ligatures(current_node,ligabreaks) end s={} current_node=t end end end function suppress_liga(s,t) noliga[s]=t end
function drop_special_nodes (nodes,tail) for t in node.traverse(nodes) do if t.id == whatsit and t.subtype == userdefined and t.user_id == identifier t node.remove(nodes,t) node.free(t) end end end luatexbase.add_to_callback("ligaturing", process_ligatures,"Filter ligatures", 1) Postscript: The solution to the bug described in this posting. The key 413
sequence in the lua code given above is that caused the bug was: for t in node.traverse(nodes) do if t.id==glyph then s[#s+1]=string.lower(unicode.utf8.char(t.char)) elseif t.id==glue then ... All that was required to ix the bug is to change this code snippet to: for t in node.traverse(nodes) do if t.id==glyph then s[#s+1]=string.lower(unicode.utf8.char(t.char)) end if ( t.id==glue or t.next==nil or t.id==kern or t.id==rule ) then ... The point is that the sequence of characters that needs to be processed by selnolig can end in ways other than just with some amount of (TeX) ”glue” (e.g., whitespace). Another way for the sequence to end if the word is the very last item being processed, e.g., if it’s the last word in the argument of a command such as \section{}; if that’s the case, the variable t.next will be equal to nil. Finally, the two remaining if conditions -- t.id==kern and t.id==rule -- are provided in case a user has inserted a ”kern” or ”rule” item manually. The bug ix is incorporated in version 0.220 of the package. Tags: fontspec (Prev Q) (Next Q), programming (Next Q) User: mico Answer by topskip Let me try to analyze the problem: You call the ligaturing over and over again, but sometimes the callback doesn’t seem to have any efect. I’d like to take a look at two cases: the footnotes:
bad\footnote{This doesn't work: shelfful.} % w/o space good\footnote{But this does work: shelfful. \vphantom{x}} % w/ space and \vphantom
414
I’ll have a look at the node list that is passed to the ligaturing callbacks with my small module viznodelist. I change the lua code slightly at the entrance point to process_ligatures(): ... require("viḶnodelist") function process_ligatures(nodes,tail) counter = counter or ḷ counter = counter + 1 viḶnodelist.nodelist_visualiḶe(nodes,string.format("liga%d.gv",counter)) The irst footnote (’bad’) looks like this:
with the detail (top right)
while the ”good” nodelist looks like this:
Now looking at the code:
415
Skip code block for t in node.traverse(nodes) do if t.id==glyph then s[#s+1]=string.lower(unicode.utf8.char(t.char)) elseif t.id== glue then ... (process ligatures) ... end end makes it clear that only a glue activates the ligature processing. I’d suggest using a diferent kind of looping for ligature processing. The diference between fontspec activated or not is the following: with fontspec deactivated, the ligaturing callback disables all ligaturing. What you see is not the efect of the command \nolig, but a general ”no ligature” mode. Try words like fluffiest fish and you see that. With fontspec enabled, the result is ”always ligatures” unless you block them with the code you use. So the ligaturing callback is not the perfect way to deal with the situation, I am afraid. You could however call node.ligaturing() at the beginning of the callback and then do what you are doing. But that would probably interfere with fontspec. Tags: fontspec (Prev Q) (Next Q), programming (Next Q)
Q: How can I access a speciic glyph in LuaLaTeX/Fontspec? Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q), unicode (Prev Q) (Next Q) The OTF version of Minion Pro contains several Dingbats glyphs I would 416
like to access. Some of them are not unicode, so I can not just copy the speciic unicode character I want to access into my text editor. In speciic, I am looking for the bold looking Moon on page 3 of this document: http://www.adobe.com/type/browser/pdfs/1719.pdf After searching, I could not igure out how to include a speciic character from a font to my document. I found out that I can use the command \symbol{glyph number}, but don’t see how I should obtain that number. Thus I ask my question more generally: how can I use a speciic glyph from a font using LuaLaTeX? Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q), unicode (Prev Q) (Next Q) User: ingo Answer by ulrike-ischer In my version of Minion Pro I get the two moons with \documentclass{article} \usepackage{fontspec}% \setmainfont{Minion Pro} \begin{document} blub \symbol{57529} \symbol{5753ḷ} \end{document} I found the numbers this way: 1. I opened temp-minionpro-regular.lua (the path is mentioned in the logile) 2. There I got to the part starting with unicodes={ (somewhere around line 590.000) and then skimmed the glyph names until I hit upon ["orn.ḷḷ1"]=57525, which sounded like the names for the ornaments. Answer by charles-stewart 417
You can display the some of the glyphs in a font using Context document (assuming the font is called whatever.otf): \definefontsynonym[Dummy][file:whatever.otf][features=default] \starttext \showfont[Dummy] \stoptext This displays the ofset numbers that you can use in Latex with \symbol, for the irst 256 glyphs in the font. Postcript The following code iterates over all the characters in a given OTF ile. For some reason unclear to me, this generally seems to include a lot of character entities not associated with glyphs. Skip code block %%Define font name and font path here \def\fontname{Jerusalem} \def\filename{/usr/X11/lib/X11/fonts/OTF/SyrCOMJerusalem.otf} \startluacode charset={} function fonttablechars (f) local cs, r = f.characters, {} for c in pairs(cs) do r[1+#r]=c end table.sort(r) return r end function setcharset () charset = fonttablechars(font.fonts[font.current()]) return charset 418
end function printcharset () local step=9 context "\\bTABLE[split=yes] " for i=1,#charset,step do context "\\bTR " for j=ḷ,step-1 do local v, cstr = i+j, tostring(charset[i+j]) if not charset[v] then break end context ('\\bTD \\ppno{%s} \\eTD \\bTD \\glyph{%s} \\eTD ', cstr, cstr) end context "\\eTR " end context "\\eTABLE " end \stopluacode \definefontsynonym[\fontname][file:\filename][features=default] \def\glyph#1{\getglyph{\fontname}{#1}} \def\ppno#1{#1\relax} \starttext \section{Print font \fontname\ from \filename} \setupbodyfont [\fontname] \directluaḷ{setcharset()} \setupbodyfont [mainface] \directluaḷ{printcharset()} \stoptext Answer by paul 419
Xetex Even though the question is about LuaLatex, here another XeTeX solution Based on this post: Generating a table of glyphs with XeTeX and some other research. It prints you all glyphs and you can access them with \XeTeXglyph Skip code block \documentclass[landscape]{article} \usepackage{geometry} \usepackage{xltxtra} \usepackage{fontspec} \usepackage{xunicode} \setmainfont{Minion Pro} \usepackage{multicol} \setlength{\columnseprule}{ḷ.4pt} \usepackage{multido} \setlength{\parindent}{ḷpt} \begin{document} \XeTeXglyph5ḷ8\XeTeXglyph1262 \begin{multicols}{1ḷ} \multido{\i=ḷ+1}{\XeTeXcountglyphs\font}{ \makebox[3em][l]{\i}% \XeTeXglyph\i\endgraf } \end{multicols} \end{document} Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q), unicode (Prev Q) (Next Q)
420
Q: Lualatex (luaotload) broke after upgrading to Mavericks Tags: fontspec (Prev Q) (Next Q), errors (Prev Q) (Next Q) Ever since I upgraded to OS X Mavericks—post hoc ergo propter hoc—I can no longer compile my dissertation using LuaLaTeX. When running lualatex I irst got the following error: luaotfload | db: reload initiated; reason: “unresolved font name: ‘lucidacal Segmentation fault: 11 ’lucidacal’ presumably refers to the Lucida Grande font, which I had installed in ~/Library/texmf. I removed ~/Library/texmf and ~/Library/texlive and now I get the following error:
luaotfload | db : Font names database not found, generating new one. luaotfload | db : This can take several minutes; please be patient.Segmentation fa I can reproduce this error by running luaotload-tool --update. At some point I also got the following error: luaotfload | db: Font names database not found, generating new one. Bus error: 1ḷ I can’t reproduce this, however. I tried upgrading all packages using TeXLive but this didn’t help. I have no idea how to ix it and would be grateful for any clues! Tags: fontspec (Prev Q) (Next Q), errors (Prev Q) (Next Q) User: jdevuyst Answer by egreg I tried the same and got Segmentation fault: 11 too. So I retried with luaotfload-tool -v -vvv -u that shows all processing and saw it stopped when trying to load Skia.ttf. So I edited 421
/usr/local/texlive/2ḷ13/texmf-dist/tex/luatex/luaotfload/luaotfload-blacklist.cnf (with sudo) and added Skia.ttf (the irst two lines) Skip code block % Causes segmentation fault with Mavericks Skia.ttf % Takes ages to load LastResort.ttf % a MacOSX font, but also available for free from unicode.org % Segfaults under LuaTeX ḷ.76 lingoes.ttf % http://tug.org/pipermail/luatex/2ḷ13-May/ḷḷ4239.html Diablindall.ttf spltfgbd.ttf spltfgbi.ttf spltfgit.ttf spltfgrg.ttf Rerunning luaotfload -v -vvv -u was successful. Losing Skia is annoying, but not having a good font database is surely worse. Note that also other fonts seem to be a cause for this. A user found that also Silom.ttf triggers a segmentation fault; running from the terminal luaotfload-tool -v -vvv -u will clearly show the culprit. The only known remedy is to add the ofending font to the blacklist.
News (2014-01-01) The new version of luaotfload (2013/12/31, luaotload v2.4) just uploaded for TeX Live, has Skia.ttf in the blacklist ile. Skip code block % Takes ages to load 422
LastResort.ttf % a MacOSX font, but also available for free from unicode.org % Segfaults under LuaTeX ḷ.76 lingoes.ttf % http://tug.org/pipermail/luatex/2ḷ13-May/ḷḷ4239.html Diablindall.ttf spltfgbd.ttf spltfgbi.ttf spltfgit.ttf spltfgrg.ttf % Buggy Max OS font, see https://github.com/lualatex/luaotfload/issues/139 Skia.ttf Tags: fontspec (Prev Q) (Next Q), errors (Prev Q) (Next Q)
Q: LuaLaTeX protrusion problem with Negative value Tags: fontspec (Prev Q) (Next Q), protrusion (Next Q) Please see the following screen shots.
423
As you can see there are two ”overfull” hbox there. However, LaTeX does not produced any overfull box warning at all. I tried to produce a minimal working example but without exactly the same layout, and fonts, and line breaks, it cannot be reproduced. So sorry that I cannot include a MWE in this question. (edit: please ind an MWE further down). However I tried to diagnose the problem. Since LaTeX does not see these as overfull box, it could be protrusion problem I guess. I setup the Minion fonts with fontspec (LuaLaTeX) as following, Skip code block \setmainfont[ UprightFeatures = {RawFeature = {protrusion = BoldFeatures = {RawFeature = {protrusion = ItalicFeatures = {RawFeature = {protrusion = BoldItalicFeatures = {RawFeature = {protrusion = RawFeature = {expansion = default}, Ligatures = {Required, Common, Contextual, TeX}, Numbers = {OldStyle, Proportional}, SiḶeFeatures = { {SiḶe = -8.41, OpticalSiḶe = 8}, {SiḶe = 8.41-13.ḷ1, OpticalSiḶe = 11}, {SiḶe = 13.ḷ1-19.91, OpticalSiḶe = 19}, {SiḶe = 19.91-, OpticalSiḶe = 72}}, ]{Minion Pro}
mnr}}, mnr}}, mni}}, mni}},
Ignoring the other things (for example the SizeFeatures is used to work around the problem that fontspec/luaotload cannot select the right optical sizes). The problems appeared to the line ItalicFeatures = {RawFeature = {protrusion = mmi}}, Where protrusion is turned on before the fonts setup by \pdfprotrudechars2 and mni is the protrusion setting for Minion Pro Italic. I translated the setting in MinionPro package to be used with LuaLaTeX (as the oicial release of microtype do not support LuaTeX with opentype fonts loaded by fontspec yet). A portion of the Lua ile that setup the protrusion can be found below, Skip code block 424
fonts = fonts or { } fonts.protrusions = fonts.protrusions or { } fonts.protrusions.setups = fonts.protrusions.setups or { } --omitted codes-fonts.protrusions.setups["mni"] = { -- Minion Pro Italic factor = 1, left = 1, right = 1,
}
-- omitted [ḷxḷḷ67] = [ḷxḷḷ69] = [ḷxḷḷ6A] = [ḷxḷḷ7ḷ] = [ḷxḷḷ72] = -- omitted
code-{-ḷ.ḷ7ḷ, -ḷ.ḷ7ḷ}, -- g { ḷ.ḷḷḷ, -ḷ.11ḷ}, -- i {-ḷ.ḷ9ḷ, -ḷ.15ḷ}, -- j {-ḷ.ḷ4ḷ, ḷ.ḷḷḷ}, -- p { ḷ.ḷḷḷ, ḷ.ḷ8ḷ}, -- r --
I I change the protrusion factor of letter g and p, which are the breaking points in the picture above, then the problem solved. Can anyone explain the problem? Is there something wrong with my fonts setup (the use RawFeatures) or the protrusion setup ile (the codes omitted in the above code snipes are just setting for other letters, which I assume should be independent from each other)? It seems that whenever a linebreak happens at a italic character and protrusion is activated for that character, then the problems always happen. This does not happen for roman fonts. Edits: Further experiments showing that assigning positive values instead of negative values to the protrusion factors does not cause any problem for the italic fonts. I guess the problem is not with Italic font, but with the negative value of protrusion factors. The reason no such problem for roman fonts is that there are no negative values assigned for any roman characters. But some italic characters has negative protrusion values so that they don’t reach out the boundary too much. Latest Edit: Here’s a minimal document that triggers the issue. 425
Skip code block \documentclass[a4paper]{article} \usepackage{microtype} \usepackage{amsthm} \newtheorem{proposition}{Proposition} \usepackage{lipsum} \begin{document} \begin{proposition} \lipsum \end{proposition} \end{document}
426
With lualatex (showcases the bug): 427
With pdlatex (perfectly ine): 428
Tags: fontspec (Prev Q) (Next Q), protrusion (Next Q) User: yan-zhou Answer by robert This could be related to a bug with negative protrusion values that I reported a year ago and which is obviously still open. Which luatex version are you using? Tags: fontspec (Prev Q) (Next Q), protrusion (Next Q)
Q: How do I change the font size in LuaLaTeX? Tags: fontspec (Prev Q) (Next Q) Skip code block \documentclass{minimal} \usepackage[paperheight = 14ḷmm,% comprimento paperwidth = 2ḷḷmm,% altura margin = 1ḷmm % tamanho da margem ]{geometry} \usepackage[T1]{fontenc} \usepackage{fontspec} \usepackage{xcolor} \setmainfont[Color=brown]{Tangerine} \begin{document} Normal pleasure of your company is requested \end{document} I’m making a wedding invitation and I’m not sure how do it using LuaLaTeX.
429
I want to set, in \setmainfont, the default color and size but I don’t know how. I’m able to set the color, as in the example, but not the size at the same time. \setmainfont[SiḶeFeatures={SiḶe=3ḷ}]{Tangerine} sets the size, but I don’t know how put it together. Is it possible? Furthermore, how do I change the font size in the middle of the document? I tried \Huge but got an error. Tags: fontspec (Prev Q) (Next Q) User: andré-andrade Answer by andrey-vihrov \Huge did not work because you used the minimal document class, which does not provide any font size commands. Use the usual article instead. You shouldn’t also need to set font size with fontspec, too. Use any of these options: • To set a default font size document-wise, pass one of the options 1ḷpt, 11pt or 12pt to the document class. • Use the usual font size commands (\small, \normalsiḶe, \large, etc.). • If none of the above have the size you need, select it manually with \fontsiḶe{}{}. A \selectfont command has to follow immediately after. The two latter options also can be used document-wise: just put them right after \begin{document} outside any groups. To sum up, an example document: Skip code block \documentclass[1ḷpt]{article} \usepackage{fontspec} \usepackage{xcolor} \setmainfont[Color=brown]{Linux Libertine} 430
\begin{document} Lorem {\Huge ipsum} dolor {\fontsiḶe{14pt}{16pt}\selectfont sit} amet. \end{document}
Answer by ulrike-ischer The option SiḶeFeatures is not meant to set a size. It should be used to set features which should be activated/used only for some font sizes: Skip code block \documentclass{article} \usepackage{fontspec} \usepackage{xcolor} \setmainfont[SiḶeFeatures={{SiḶe=-11,Color=red}, {SiḶe=11-3ḷ,Color=blue}, {SiḶe=3ḷ-,Color=green}}]{Arial} \begin{document} normal red text \large larger blue text \fontsiḶe{3ḷpt}{3ḷpt}\selectfont very large green Text \end{document} Tags: fontspec (Prev Q) (Next Q)
431
Q: Towards a \ucshape and \textuc command for uppercase text (XeTeX, LuaTeX) Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q), opentype (Prev Q) (Next Q) While we have \textit and \textsc, \itshape and \scshape etc., there’s no \textuc and \ucshape to typeset its argument in uppercase. There is \MakeUppercase, but -- as uppercase is not a font style -- it’s not a font selection command and cannot be used like one. That’s why it’s of no use in, e.g., formatting headings. There’s the seamus-egreg workaround, but that has its limitations, for example when exotic languages are used: \section{daß} produces »DAß« rather than »DASS«, etc. Traditionally, the only way towards a proper \textuc/\ucshape seemed to be via creating a virtual font in which all lowercase letters are replaced by uppercase ones. While I’ve seen a couple of people suggesting that approach, I don’t think anyone has ever done it, probably because it’s tedious and inlexible, as it’s always tied to one speciic font. My question is if it might be a good idea to rethink that issue now that we have Xe and Lua, where we can use OpenType Fonts and, via fontspec, OpenType feature iles. In those feature iles, we can deine substitution rules that can be switched on and of. In OpenType, an f_i ligature, for example, is produced via such a substitution rule, saying »whenever in the code you come across an f followed by an i, replace the two by the glyph f_i in the output«. To tentatively answer my own question: yes, it might be. Consider the following example. [edit: now including a comparison with the \MakeTextUppercase command from the textcase package barbara mentioned.] Skip code block \documentclass{scrartcl} \usepackage{fontspec,blindtext,microtype,filecontents,textcase} \begin{filecontents*}{universalcaps.fea} languagesystem DFLT dflt; languagesystem latn dflt;
432
feature caps { lookup ligatures { sub f_i by F I; sub f_l by F L; sub f_f_l by F F sub f_f_i by F F sub f_f by F F; sub f_j by F J; sub f_f_j by F F sub f_t by F T; sub f_f_t by F F } ligatures;
L; I; J; T;
lookup esḶett { sub germandbls by S S; } esḶett; lookup single { sub [a-Ḷ] by [A-Z]; sub agrave by Agrave; sub aacute by Aacute; sub acircumflex by Acircumflex; sub atilde by Atilde; sub adieresis by Adieresis; sub aring by Aring; sub ccedilla by Ccedilla; sub egrave by Egrave; sub eacute by Eacute; sub ecircumflex by Ecircumflex; sub edieresis by Edieresis; sub igrave by Igrave; sub iacute by Iacute; sub icircumflex by Icircumflex; sub idieresis by Idieresis; sub eth by Eth; sub ntilde by Ntilde; sub ograve by Ograve; 433
sub oacute by Oacute; sub ocircumflex by Ocircumflex; sub otilde by Otilde; sub odieresis by Odieresis; sub ugrave by Ugrave; sub uacute by Uacute; sub ucircumflex by Ucircumflex; sub udieresis by Udieresis; sub yacute by Yacute; sub thorn by Thorn; sub ydieresis by Ydieresis; sub oe by OE; sub ae by AE; sub scaron by Scaron; sub Ḷcaron by Zcaron; } single; } caps; \end{filecontents*} \setmainfont[FeatureFile=universalcaps.fea]{TeX Gyre Termes} \setsansfont[FeatureFile=universalcaps.fea]{TeX Gyre Heros} \newcommand*{\ucshape}{\addfontfeature{RawFeature=+caps}} \newcommand{\textuc}[1]{{\ucshape #1}} \setkomafont{section}{\ucshape} \begin{document} \section{Lorem Ipsum} \textuc{\blindtext àéîàḹâãäåæ çèéṛëìíîï ðñòóôõö ùúûüýþÿœš fi ff fl ffi ffl fj ffj} \MakeTextUppercase{daß} \textuc{daß} 434
\begin{titlepage} \ucshape \begin{center} John Doe\par {\huge Title} \end{center} \end{titlepage} \end{document} This will create a feature ile, adding to whatever font is loaded a new feature called caps that can be turned on and of like any other. Note that this will work with TrueType fonts as well, {Georgia} etc; fontspec seems to transfer what’s in the .fea ile to even non-OpenType fonts. • Are there any potential drawbacks that I may not have had in mind? I’m still thinking it seems too simple to be true. (While it may be simple, it may of course still be a lot of work to take are of all lowercase glyphs in advanced multi-language fonts). • Has anyone else ever done or seen something like that? I ind it hard to believe I should be the irst to come up with that idea... • If noone has done it so far, would it be a good idea to turn it into a little package? Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q), opentype (Prev Q) (Next Q) User: nils-l Answer by topskip A full implementation in LuaTeX: Skip code block \documentclass{article} \usepackage{fontspec} \usepackage{xcolor} \usepackage{luacode} 435
\usepackage{luatexbase} \usepackage{luatexbase-attr} \newluatexattribute\uppercaseattr \begin{luacode*} local ucattr = luatexbase.attributes.uppercaseattr
local function makeuppercase(head) local orighead = head local string = unicode.utf8 while head do if head.id == 37 then local att = node.has_attribute(head,ucattr) if att then if head.char == 223 then -- ß -- insert two 'S' glyphs head.char = 83 orighead = node.insert_before(orighead,head,node.copy(head)) elseif head.char == 64258 then -- fl head.char = 7ḷ -- F orighead = node.insert_before(orighead,head,node.copy(head)) head.char = 76 -- L elseif head.char == 64256 then -- ff head.char = 7ḷ -- F orighead = node.insert_before(orighead,head,node.copy(head)) head.char = 7ḷ -- F elseif head.char == 64257 then -- fi head.char = 7ḷ -- F orighead = node.insert_before(orighead,head,node.copy(head)) head.char = 73 -- I elseif head.char == 64259 then -- ffi head.char = 7ḷ -- F orighead = node.insert_before(orighead,head,node.copy(head)) head.char = 7ḷ -- F orighead = node.insert_before(orighead,head,node.copy(head)) head.char = 73 -- I 436
end
elseif head.char == 6426ḷ then -- ffl head.char = 7ḷ -- F orighead = node.insert_before(orighead,head,node.copy(head)) head.char = 7ḷ -- F orighead = node.insert_before(orighead,head,node.copy(head)) head.char = 76 -- L else head.char = string.byte(string.upper(string.char(head.char)) end
end head = head.next
end
end return orighead
function makeuppercase_hbox(head,groupcode) local orighead = head if groupcode == "adjusted_hbox" or groupcode == "hbox" then makeuppercase(head) end return orighead end
luatexbase.add_to_callback("hpack_filter",makeuppercase_hbox,"makeuppercasehbox" luatexbase.add_to_callback("pre_linebreak_filter",makeuppercase,"makeuppercase") \end{luacode*} \newcommand*\ucshape{\uppercaseattr=1} \DeclareTextFontCommand{\textuc}{\ucshape}
\begin{document} \hsiḶe 7.2cm \newcommand\sample{Draußen \i \ij\ ffl fluffiest fish \textit{König} \textcolor{bl Lowercase {\ucshape \sample} Lowercase 437
Lowercase \textuc{\sample} Lowercase % textcolor doesn't work in LaTeX's \MakeUppercase % Lowercase \MakeUppercase{\sample} Lowercase \end{document} which yields
The program above just manipulates the nodelist if the given attribute is set (to any value). Attributes are grouped, just like any TeX assignment. It’s a bit more complicated than I thought because we need to treat \hbox{}es separately. Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q), opentype (Prev Q) (Next Q)
Q: Lualatex : € as a utf8 character is not recognized : why? Tags: fontspec (Prev Q) (Next Q) I need to include some tex iles as parts of a more global project. Some of this global projects have to be compiled with pdlatex, some others with lualatex,
438
but the parts are the same. All this part iles are written with a € as an utf8 character. I would like avoid to replace them by a \texteuro. Is there a way to make lualatex understand € as a \texteuro ? Skip code block \documentclass[french]{article} \RequirePackage{ifluatex} \ifluatex \RequirePackage{fontspec} \RequirePackage{luacode} \else \RequirePackage[utf8]{inputenc} \RequirePackage[T1]{fontenc} \fi \RequirePackage{fourier} \begin{document} 36\,\texteuro % works with both pdflatex lualatex 36\,€ % doesn't work with lualatex \end{document} Tags: fontspec (Prev Q) (Next Q) User: tarass Answer by user11232 You can use newunicodechar package and deine \newunicodechar{€}{\texteuro} Code: Skip code block \documentclass{article} \RequirePackage{ifluatex} \ifluatex 439
\RequirePackage{fontspec} \RequirePackage{luacode} \else \RequirePackage[utf8]{inputenc} \RequirePackage[T1]{fontenc} \fi \let\hbar\hhhbar %% without this I get a warning \RequirePackage{fourier} \usepackage{newunicodechar} \newunicodechar{€}{\texteuro} \begin{document} 36\,\texteuro % works with both pdflatex lualatex 36\,€ % doesn't work with lualatex \end{document} Then it should work in both pdlatex and lualatex. Answer by egreg With \usepackage{fourier} you are simply ignoring fontspec and using a family of “classical” 256 character font. You can use classical fonts with LuaLaTeX, without loading fontspec, but luainputenc: Skip code block \documentclass{article} \usepackage{ifluatex} \usepackage[TS1,T1]{fontenc} % load TS1 so luainputenc will know \ifluatex \usepackage{luacode} \usepackage[utf8]{luainputenc} \else \usepackage[utf8]{inputenc} \fi 440
\usepackage{fourier} \begin{document} 36\,\texteuro % works with both pdflatex lualatex 36\,€ % doesn't work with lualatex \end{document} Of course this will not use the full strengths of LuaLaTeX as regards to fonts, but it’s impossible anyway if you want your document to be processable with LuaLaTeX and pdfLaTeX (and loading luacode doesn’t make much sense). A probably better solution is to use a text font replacement for Utopia, such as the very recent Erewhon font: Skip code block \documentclass{article} \usepackage{ifluatex} \ifluatex \usepackage{luacode} \usepackage{fourier} \usepackage{fontspec} \setmainfont{Erewhon} \else \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{fourier} \fi \begin{document} 36\,\texteuro % works with both pdflatex lualatex 36\,€ % doesn't work with lualatex Some math $a+\mathrm{a}=\int_{ḷ}^{1} f(x)\,dx$ \end{document} 441
Tags: fontspec (Prev Q) (Next Q)
Q: Kerning and ligatures in TeX without TeX Tags: fontspec (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) I am trying to get the same output as in this answer by topskip (an extended version with comments is presented in the TeX without TeX article). I am getting a paragraph consisting of 6 lines with hyphenation, but kerning and ligatures are lost (turned of?) as it can be seen around the character V in VLTAVA and in the letters i in oice. I use WinXP + TeX Live 2014 and Lubuntu 13.10 + TeX Live 2013. I’ve got the same output, the font is LinLibertine_R.otf. First tip by topskip is to skip loading of the fontspec package which could handle things diferently than the luaotfload package. Therefore, instead of libertine and luatextra (they both load the fontspec package), I tried to load luacode and luaotfload packages directly, no success, no errors and no warnings. Where the problem might be? We run lualatex testfonts.tex. Skip code block % lualatex testfonts.tex \documentclass[a4paper]{article} \pagestyle{empty} 442
%\usepackage{luatextra} %\usepackage{libertine} \usepackage{luaotfload} \usepackage{luacode} \begin{document} \font\main={file:LinLibertine_R.otf} \main \begin{luacode*} function count_lines (head) local linecount = ḷ while head do if head.id == ḷ then linecount = linecount + 1 end head = head.next end return linecount end function mknodes( text ) local current_font = font.current() local font_parameters = font.getfont(current_font).parameters local n, head, last -- we should insert the paragraph indentation at the beginning head = node.new("glue") head.spec = node.new("glue_spec") head.spec.width = 2ḷ * 2^16 last = head for s in string.utfvalues( text ) do local char = unicode.utf8.char(s) if unicode.utf8.match(char,"%s") then -- its a space n = node.new("glue") n.spec = node.new("glue_spec") n.spec.width = font_parameters.space n.spec.shrink = font_parameters.space_shrink n.spec.stretch = font_parameters.space_stretch 443
else -- a glyph n = node.new("glyph") n.font = current_font n.subtype = 1 n.char = s n.lang = tex.language n.uchyph = 1 n.left = tex.lefthyphenmin n.right = tex.righthyphenmin end last.next = n last = n end -- now add the final parts: a penalty and the parfillskip glue local penalty = node.new("penalty") penalty.penalty = 1ḷḷḷḷ local parfillskip = node.new("glue") parfillskip.spec = node.new("glue_spec") parfillskip.spec.stretch = 2^16 parfillskip.spec.stretch_order = 2 last.next = penalty penalty.next = parfillskip -- just to create the prev pointers for tex.linebreak node.slide(head) return head end local txt = "VLTAVA office A wonderful serenity has taken possession of my entire tex.baselineskip = node.new("glue_spec") tex.baselineskip.width = 14 * 2^16 local head = mknodes(txt) 444
lang.hyphenate(head) head = node.kerning(head) head = node.ligaturing(head) local vbox local siḶe = 9ḷ lines = ḷ lines_goal = 6
while lines < lines_goal do texio.write_nl(string.format("Formatting text to %d mm",siḶe)) local copy_of_head = node.copy_list(head) vbox = tex.linebreak(copy_of_head,{ hsiḶe = tex.sp(string.format("%dmm",siḶe))}) siḶe = siḶe - 1ḷ lines = count_lines(vbox) texio.write_nl(string.format("lines=%d",lines)) end node.write(vbox) \end{luacode*} VLTAVA office \end{document}
Tags: fontspec (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) 445
User: malipivo Answer by michal.h21 For opentype fonts, luaotfload provide function nodes.simple_font_handler which will take care of all font manipulations like ligaturing and kerning and all other features supported by luaotfload. This function isn’t advertised in the manual, I’ve found it in luaotfload source code. It is called as node callback on normal text, but as you create nodes directly from Lua, it doesn’t take efect on your text and you have to call it explicitly: local head = mknodes(txt) lang.hyphenate(head) head = nodes.simple_font_handler(head) you don’t have to call node.ligaturing and node.kerning any more, they were called from simple_font_handler already
Tags: fontspec (Prev Q) (Next Q), ligatures (Prev Q) (Next Q)
446
Q: Getting started with Greek and Hebrew in LuaLaTeX Tags: fontspec (Prev Q) (Next Q) I am typesetting a 17th century English theological document that uses a smattering of Greek and Hebrew. I am using LuaLaTeX with TeXShop on the Mac. Is LuaLaTeX up to the task? If so what are the basic steps needed to get accented Greek and pointed Hebrew? Is it possible to have English sentences interspersed with occasional Gk and Heb words, or can they (esp Heb) only be set in their own paragraphs? My plan was to use SBL Greek and Ezra SIL Hebrew fonts. Are these reasonable choices? Ideally I would like to be pointed to a tutorial that describes this stuf from the ground up (or rather, as suitable for someone with a Lamport understanding of LaTeX). But short of that I’m throwing myself on the mercy of knowledgable strangers! Tags: fontspec (Prev Q) (Next Q) User: paul-dulaney Answer by clinteastwood LuaLaTeX is your choice! Greek is possible without any adjustments. Hebrew, as it is a language from right to left, needs adjustments. Of course, you need to use \usepackage{fontspec} in the preamble (as is usual when using LuaLatex). Greek You need a font that supports all the accents. If your mainfont for latin text does not support them, you need to implement a special greek font: \newfontfamily\greekfont[Script=Greek, Scale=MatchUppercase, Ligatures=TeX]{GREEK \newcommand{\textgreek}[1]{\bgroup\greekfont\emph{#1}\egroup} If your main font does support them you can just use: 447
\newcommand{\textgreek}[1]{\emph{#1}} I use a command like this for my greek passages, because so it stays possible to decide later whether the Greek words should be italicized or bold or whatever or not. This command sets Greek text in italics, because of the \emph{…} if you don’t want this, delete it.) Now you should be able to set Greek text inside Latin text by entering: \textgreek{}. Hebrew You need to set up a font and the settings for right-to-left-text: \newfontfamily\hebfont[Script=Hebrew, Scale=MatchUppercase, Ligatures=TeX]{HEBREW \newcommand{\textheb}[1]{\bgroup\luatextextdir TRT\hebfont #1\egroup} Now you should be able to set Hebrew text inside Latin text by entering: \textheb{}. Typographic Advice You should use a font that already contains Latin and Greek accented characters. If you’re lucky, you’ll ind (a good) one that also contains Hebrew. Thereby you assure that the three languages have the same font style. It may not be a good idea to use three diferent fonts - except if they resemble each other in style. Have a look at the Brill Font. Palatino also has nice Greek. Or, if you want an expensive one, Adobe Garamond. I don’t know anything about Hebrew fonts. Entire Example Code of heb.tex Skip code block % !TEX TS-program = lualatexmk \documentclass[11pt, a4paper]{scrartcl} \usepackage{fontspec} 448
\setmainfont{Times New Roman} \newfontfamily\greekfont[Script=Greek, Scale=MatchUppercase, Ligatures=TeX]{Arial \newcommand{\textgreek}[1]{\bgroup\greekfont\emph{#1}\egroup} % Please note, that
\newfontfamily\hebfont[Script=Hebrew, Scale=MatchUppercase, Ligatures=TeX]{EḶra SI \newcommand{\textheb}[1]{\bgroup\luatextextdir TRT\hebfont #1\egroup} \begin{document} This is \textgreek{} Greek. And this is \textheb{} Hebrew. \end{document} Tags: fontspec (Prev Q) (Next Q)
Q: fontspec: what does Renderer=Basic do? Tags: fontspec (Prev Q) (Next Q) I’m writing a document using LuaLaTeX on Windows, using Arial (please do not comment on that) as its main font with: \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \setmainfont[Renderer=Basic]{Arial} To keep the usual TeX substitutions I used Ligatures=TeX, but this does not work unless using Renderer=Basic additionally. Tags: fontspec (Prev Q) (Next Q) User: mkluwe Answer by khaled-hosny
449
luaotfload (the package doing OpenType layout under the hood for LuaLaTeX) has two font processing modes; base mode which tries to made as much of OpenType lookups to traditional TeX ligaturing and kerning mechanisms (think of it like creating TFM iles from OpenType fonts on the ly) and it is limited by what TeX can traditionally support, and node mode which tries to do faithful OpenType processing entirely in Lua. fontspec’s Renderer=Basic maps to the former, and Renderer=Full maps to the later. Why Renderer=Basic is needed for Ligatures=TeX to work with some fonts, is an artefact of how this feature is implemented in luaotfload, it is a bug actually, but the development of luaotfload is stalled… Tags: fontspec (Prev Q) (Next Q)
Q: Is it possible now to use microtype with opentype fonts? Tags: fontspec (Prev Q) (Next Q), microtype (Prev Q) (Next Q) LuaTeX has limited support for microtypograhpy now, and it can be invoked if only type1 fonts are used. But is it possible for microtype to work with opentype fonts loaded with fontspec now? I have searched the Internet for this, but most of the relevant information is outdated. Tags: fontspec (Prev Q) (Next Q), microtype (Prev Q) (Next Q) User: siyuan-ren Answer by mico You ask whether it [is] possible for microtype to work with OpenType fonts loaded with fontspec. The short answer is yes. A longer answer would add that microtype’s functionality under LuaLaTeX isn’t as complete as it is under pdfLaTeX. However, the limitations are not caused by the use of OpenType fonts. 450
The version of microtype that’s currently distributed with TeXLive 2012 and MikTeX 2.9 is still version 2.4. However, a late-beta edition of version 2.5 of the microtype package, dated 2012-05-23, may be downloaded from http: //tlcontrib.metatex.org/cgi-bin/package.cgi/action=view/id=608. This version, when run under LuaLaTeX, still isn’t as capable as when it’s run under pdfLaTeX, but it comes a lot closer than if you stick with version 2.4. You ask in a follow-up comment how version 2.5 of microtype might be installed manually under MikTeX. Do you have a ”local” directory set up among the directories that are searched by MikTeX? (Bring up the ”Settings” app of MikTeX to ind out.) If not, do set up such a directory. Then, you could • make sure that this local directory is topmost in the search order (so that the version of microtype to be installed by you in the local directory are seen before the ”oicial” but now somewhat obsolete version that’s still distributed with MikTeX 2.9); • copy the iles of microtype 2.5 beta to subdirectories of the local directory (such as ..\tex\latex\microtype and ..\doc\microtype); and • update MikTeX’s ilename database; the particulars of this update process will depend on whether or not you installed MikTeX in ordinary mode or admin mode. Update: Version 2.5a of the microtype package was released in May 2013. Tags: fontspec (Prev Q) (Next Q), microtype (Prev Q) (Next Q)
Q: using Hoeler Text font under lualatex and MacOSX Tags: fontspec (Prev Q) (Next Q) I’m having unexpected problems getting the ”Hoeler Text” font to work when using LuaLaTeX (under MacTeX2012, all the latest updates installed) 451
on a Mac (MacOS X 10.7.4). The following MWE \documentclass{article} \usepackage{fontspec} \setmainfont{Hoefler Text} \begin{document} Hello World. \end{document} throws the following error message when run under LuaLaTeX: ! fontspec error: "font-not-found" ! ! The font "HoeflerText" cannot be found. Oddly, the very same MWE when run under XeLaTeX does not throw an error. The font is present on my Mac, under /Library/Fonts/, with a ilename of Hoefler Text.ttc. For what it’s worth, this seems to one of very few fonts in this directory with this ilename extension (which I believe Apple calls ”Truetype font collection”); almost all others have extensions such as .ttf and .otf. Is there something special about Hoefler Text on a Mac that requires a special font-loading sequence to work under LuaLaTeX? Addendum: Since irst posting this question, I’ve learned from the comments and answer that this problem appears to afect all fonts stored in .ttc format on a Mac system, not just Hoefler Text. Tags: fontspec (Prev Q) (Next Q) User: mico Answer by egreg For some reasons, the font loading mechanism of LuaLaTeX maintains a ”black list” for Mac OS X fonts, where all .ttc fonts are inserted; the ile is /usr/local/texlive/2ḷ12/texmf-dist/tex/luatex/luaotfload/otfl-blacklist.cnf and its contents is Skip code block 452
% Tackes ages to load LastResort.ttf % a MacOSX font, but also available for free from unicode.org % Mac OS X TTC fonts, this list need to be filtered out /Library/Fonts/AmericanTypewriter.ttc /Library/Fonts/Baskerville.ttc /Library/Fonts/Chalkboard.ttc /Library/Fonts/Cochin.ttc /Library/Fonts/Copperplate.ttc /Library/Fonts/Didot.ttc /Library/Fonts/Futura.ttc /Library/Fonts/GillSans.ttc /Library/Fonts/Hoefler Text.ttc /Library/Fonts/MarkerFelt.ttc /Library/Fonts/Optima.ttc /Library/Fonts/Papyrus.ttc /Library/Fonts/STHeiti Medium.ttc /System/Library/Fonts/AquaKana.ttc /System/Library/Fonts/HelveticaNeue.ttc /System/Library/Fonts/LucidaGrande.ttc /System/Library/Fonts/Menlo.ttc /System/Library/Fonts/STHeiti Light.ttc You may modify the ile, but there’s no guarantee that the font will work. I’ve found an old thread on the lualatex-dev list that deals with this problem. Added Thanks to Mico’s for experimenting the issue. The only font that seems to give problem is ”LastResort” that should be kept in the black list. Doing
sudo nano /usr/local/texlive/2ḷ12/texmf-dist/tex/luatex/luaotfload/otfl-blacklist. and putting a % in front of each line after % Mac OS X TTC fonts, this list need to be filtered out 453
followed by a call of mkluatexfontdb will make all .ttc fonts available for LuaLaTeX. Tags: fontspec (Prev Q) (Next Q)
Q: fontspec throwing error with lualatex - broken? Tags: fontspec (Prev Q) (Next Q) I get an error when I try to include the fontspec package. Here is a minimum working example: \documentclass{article} \usepackage{fontspec} \begin{document} Hello \end{document} I’m trying to compile this using the following build command: lualatex --file-line-error-style "%f". Part of the output that I get is: Skip code block /usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty:1ḷḷ: Font \EU2/lmr/m/n/ 1ḷ=file:lmroman1ḷ-regular:script=latn;+trep;+tlig; at 1ḷpt not loadable: metric data not found or bad.
relax l.1ḷḷ \fontencoding\encodingdefault\selectfont ? /usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty:1ḷḷ: Emergency stop.
relax l.1ḷḷ \fontencoding\encodingdefault\selectfont 269 words of node memory still in use: 454
2 hlist, 1 rule, 1 kern, 1 attribute, 41 glue_spec, 1 attribute_list, 2 if_st ack, 1 write, 1 dir nodes avail lists: 2:8,3:1,4:1,6:2,9:2 /usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty:1ḷḷ: ==> Fatal error o ccurred, no output PDF file produced! I would greatly appreciate any insight that you may have on this issue. I am using Linux Mint 16, with the standard texlive-luatex available in the repositories. Thank you. Edit: upon request from user phg, here is the output from luaotfload-tool --version luaotfload-tool version “2.3” database version “2.2ḷ7” Lua interpreter: stock; version “Lua 5.2” and luaotfload-tool --diagnose=environment,permissions Skip code block luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload
| | | | | | | | | | | | | | | | | | | |
diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose diagnose
: : : : : : : : : : : : : : : : : : : :
Loading file hashes. =============== file permissions ============== Checking permissions of /home/alex/.texmf-var/luatex-cache Owner: 1ḷḷḷ, group 1ḷḷḷ, permissions rwxrwxr-x. Readable: ok. Writable: ok. Checking permissions of /home/alex/.texmf-var/luatex-cache Owner: 1ḷḷḷ, group 1ḷḷḷ, permissions rwxrwxr-x. Readable: ok. Writable: ok. Checking permissions of /home/alex/.texmf-var/luatex-cache Owner: 1ḷḷḷ, group 1ḷḷḷ, permissions rw-rw-rw-. Readable: ok. Writable: ok. Checking permissions of /home/alex/.texmf-var/luatex-cache Owner: 1ḷḷḷ, group 1ḷḷḷ, permissions rw-rw-rw-. Readable: ok. Writable: ok. Checking permissions of /home/alex/.texmf-var/luatex-cache Owner: 1ḷḷḷ, group 1ḷḷḷ, permissions rw-rw-rw-. 455
luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload luaotfload
| | | | | | |
diagnose diagnose diagnose diagnose diagnose diagnose diagnose
: : : : : : :
Readable: ok. Writable: ok. Checking permissions of /home/alex/.texmf-var/luatex-cache Owner: 1ḷḷḷ, group 1ḷḷḷ, permissions rw-rw-rw-. Readable: ok. Writable: ok. Everything appears to be in order, you may sleep well
Thanks for the prompt feedback! Tags: fontspec (Prev Q) (Next Q) User: castle-bravo Answer by kragol I have just faced the same problem and it turns out that the solution was to install the lmodern package. If I understand correctly this also installs the fonts-lmodern package which contains the missing font ile lmroman1ḷ-regular that lualatex was complaining about. (lmodern seems to contain font iles for pdfTeX) The conclusion is that this is perhaps not a TeX problem but rather a package dependency problem in the Linux Mint distribution (I am on Linux Mint Debian Edition). Still it seems a bit weird that lualatex requires a font that is not even used in the document. Answer by mimoralea You might be missing a required package, try: sudo apt-get install texlive-luatex Then, try the update: luaotfload-tool --update Tags: fontspec (Prev Q) (Next Q)
456
Q: tabular numbers in tables, proportional in text Tags: fontspec (Prev Q) (Next Q) I’m using LuaTeX with a font that has proportional, lining and tabular numbers available. Is it possible to set things up so tables automatically use tabular numbers but proportional numbers are used in the text? Tags: fontspec (Prev Q) (Next Q) User: davidc Answer by uli There is a package called tabigures which I have not tried yet. Tags: fontspec (Prev Q) (Next Q)
Q: Replacing Unicode non-breakable spaces by normal spaces Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q), unicode (Prev Q) (Next Q) I am using the Neo keyboard layout, which uses all kinds of modiier keys to input all kinds of characters (e.g. Greek letters and mathematical symbols). It also has shift+Mod3+space mapped to Unicode 0A, no-break space. From time to time it happens that I mistakenly press these buttons (while entering a space between other symbols with the same modiier keys). Unfortunately [Lua|Xe]TeX obeys these spaces as unbreakable spaces both in normal text and in mathmode (using fontspec and unicode-math). However my editor (vim) shows the symbol like a normal space, so it is impossible to see where I made a mistake.
457
Is there an easy way to tell [Lua|Xe]TeX to treat no-break spaces like normal spaces? Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q), unicode (Prev Q) (Next Q) User: caramdir Answer by egreg \usepackage{newunicodechar} \newunicodechar{ }{ } In the irst argument you put a NO-BREAK SPACE (U+00A0), in the second a normal space. A better deinition would be \newunicodechar{ }{~} (again the space is NO-BREAK SPACE), so this unbreakable space will stretch or shrink wit the other spaces in the line. Of course use the irst one if you want a normal space, ça va sans dire. :) Answer by aditya Another solution will be to change vim setup so that you can see the nonbreakable space. set listchars=nbsp:¬ set list You can set appropriate syntax highlighting for NonText to highlight the non-breakable space. Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q), unicode (Prev Q) (Next Q)
458
Q: Check for missing font characters in LuaLaTeX Tags: fontspec (Prev Q) (Next Q) I have a document: \documentclass{article} \usepackage{fontspec} \begin{document} Program the C, please. \end{document} When I compile with xelatex or lualatex, there is a missing ”” character in the output. This makes sense because the default font doesn’t contain that character, but I need to know when it happens. With xelatex, the log ile contains a warning: Missing character: There is no in font [lmroman1ḷ-regular]:mapping=tex-text! Cool. But with lualatex, the output is wrong and there’s not a single warning or error to be found. How can I detect missing characters in LuaLaTeX? It seems that ConTeXt can use \checkcharactersinfont or \enabletrackers[fonts.missing], while XeLaTeX controls it with \tracinglostchars=2. Tags: fontspec (Prev Q) (Next Q) User: jim-paris Answer by philipp-gesang Here is an adaptation of the Context code for missing glyphs: https://gist. github.com/phi-gamma/5812290. As the character table shipped with luaotload is currently experimental, it doesn’t contain the necessary metadata. Thus the code requires the full version of char-def.lua from a Context distribution (installing the Context packages from TL should suice). Usage: \startreportmissingglyphs initializes the tracker. Its counterpart, \stopreportmissingglyphs, disables the glyph checker. Example: 459
\startreportmissingglyphs ... some text ... \stopreportmissingglyphs If invoked with the optional argument [once], \startreportmissingglyphs will report each missing character only once per font. Example output:
Note that due to the nature of the Luatex callbacks involved, the glyph checker works on a per-paragraph basis, and \stopreportmissingglyphs will force a paragraph end. For reference, I include the full example including the deinitions of interface macros from the gist: Skip code block \documentclass{article} \usepackage{luacode,fontspec} %% 1) initialiḶe the tracker code (could go to separate file) \makeatletter \directlua{dofile "track-missing-glyphs.lua"} %% 2) Environment start: the optional argument “once”, in square %% brackets, requests that the missing glyph message be printed %% only once per character and font. \def\startreportmissingglyphs{% \@ifnextchar[\missingglyphs@start@indeed% {\missingglyphs@start@indeed[]}% } \def\missingglyphs@start@indeed[#1]{% \directlua{documentdata.missing_glyphs.enable"\luaescapestring{#1}"}% 460
} %% 3) Environment stop: we need to force a \par here to %% have the callback apply to the current paragraph. \def\stopreportmissingglyphs{% \endgraf %% paragraph-based callback! \directlua{documentdata.missing_glyphs.disable()}% } \makeatother %% Usage examples. \begin{document} %% Latin modern lacks glyphs for the Greek script so we use that for %% testing. \startreportmissingglyphs Program the C, please. %% Works in math mode (different font model) as well. $f = ma$ \stopreportmissingglyphs lorem schmipsum \startreportmissingglyphs[once] %% With the “once” flag, no message is emitted for repetitions of %% missing chars. Θ, . \stopreportmissingglyphs \end{document} Tags: fontspec (Prev Q) (Next Q)
Q: Contextual Substitution with LuaLateX Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q) Contextual substition doesn’t seem to work with LuaLateX, while it works ine with XeLateX. Am I doing something wrong or is this a bug? 461
\documentclass{article} \usepackage{fontspec} \setmainfont{Linux Libertine O} \begin{document} \textvbaraccent{i} fä f? \end{document} XeLaTeX
LuaLaTeX
(notice the spacing between the upper part of the ’f’ and the irst dot of the ’ä’ and the space between the ’f’ and the ’?’) Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q) User: wakimiko
462
Answer by egreg The problem seems to have been solved with the new release of TeX Live 2013 (presently in test version). Here’s the output obtained with Skip code block > lualatex --version This is LuaTeX, Version beta-ḷ.76.ḷ-2ḷ13ḷ52718 Execute
'luatex --credits'
(TeX Live 2ḷ13) (rev 4627)
for credits and version details.
There is NO warranty. Redistribution of this software is covered by the terms of the GNU General Public License, version 2 or (at your option) any later version. For more information about these matters, see the file named COPYING and the LuaTeX source. Copyright 2ḷ13 Taco Hoekwater, the LuaTeX Team.
And here’s the ile list Skip code block *File List* article.cls siḶe1ḷ.clo fontspec.sty expl3.sty
2ḷḷ7/1ḷ/19 2ḷḷ7/1ḷ/19 2ḷ13/ḷ5/2ḷ 2ḷ13/ḷ3/14
v1.4h v1.4h v2.3c v4469 463
Standard LaTeX document class Standard LaTeX file (siḶe option) Font selection for XeLaTeX and LuaLaTeX L3 Experimental code bundle wrapper
l3names.sty 2ḷ12/12/ḷ7 v4346 L3 Namespace for primitives l3bootstrap.sty 2ḷ13/ḷ1/ḷ8 v442ḷ L3 Experimental bootstrap code luatex.sty 2ḷ1ḷ/ḷ3/ḷ9 vḷ.4 LuaTeX basic definition package (HO) infwarerr.sty 2ḷ1ḷ/ḷ4/ḷ8 v1.3 Providing info/warning/error messages (HO) ifluatex.sty 2ḷ1ḷ/ḷ3/ḷ1 v1.3 Provides the ifluatex switch (HO) etex.sty 1998/ḷ3/26 v2.ḷ eTeX basic definition package (PEB) luatex-loader.sty 2ḷ1ḷ/ḷ3/ḷ9 vḷ.4 Lua module loader (HO) pdftexcmds.sty 2ḷ11/11/29 vḷ.2ḷ Utility functions of pdfTeX for LuaTeX (HO) ltxcmds.sty 2ḷ11/11/ḷ9 v1.22 LaTeX kernel commands for general use (HO) ifpdf.sty 2ḷ11/ḷ1/3ḷ v2.3 Provides the ifpdf switch (HO) l3basics.sty 2ḷ13/ḷ1/1ḷ v4428 L3 Basic definitions l3expan.sty 2ḷ13/ḷ2/ḷ3 v4458 L3 Argument expansion l3tl.sty 2ḷ13/ḷ1/ḷ8 v4415 L3 Token lists l3seq.sty 2ḷ13/ḷ1/12 v4434 L3 Sequences and stacks l3int.sty 2ḷ13/ḷ1/13 v4444 L3 Integers l3quark.sty 2ḷ12/11/ḷ4 v4268 L3 Quarks l3prg.sty 2ḷ13/ḷ2/13 v4459 L3 Control structures l3clist.sty 2ḷ13/ḷ1/ḷ8 v4414 L3 Comma separated lists l3token.sty 2ḷ13/ḷ1/1ḷ v4428 L3 Experimental token manipulation l3prop.sty 2ḷ13/ḷ1/ḷ9 v4423 L3 Property lists l3msg.sty 2ḷ13/ḷ1/ḷ8 v4412 L3 Messages l3file.sty 2ḷ13/ḷ1/14 v4446 L3 File and I/O operations l3skip.sty 2ḷ13/ḷ1/13 v4444 L3 Dimensions and skips l3keys.sty 2ḷ13/ḷ2/24 v4461 L3 Experimental key-value interfaces l3fp.sty 2ḷ13/ḷ1/19 v4449 L3 Floating points l3box.sty 2ḷ13/ḷ1/ḷ8 v4411 L3 Experimental boxes l3coffins.sty 2ḷ12/ḷ9/ḷ9 v4212 L3 Coffin code layer l3color.sty 2ḷ12/ḷ8/29 v4156 L3 Experimental color support l3luatex.sty 2ḷ12/ḷ8/ḷ3 v4ḷ49 L3 Experimental LuaTeX-specific functions l3candidates.sty 2ḷ13/ḷ3/14 v4468 L3 Experimental additions to l3kernel xparse.sty 2ḷ13/ḷ3/12 v4467 L3 Experimental document command parser luaotfload.sty 2ḷ13/ḷ5/23 v2.2d OpenType layout system luatexbase.sty 2ḷ13/ḷ5/11 vḷ.6 Resource management for the LuaTeX macro progr ammer luatexbase-compat.sty 2ḷ11/ḷ5/24 vḷ.4 Compatibility tools for LuaTeX luatexbase-modutils.sty 2ḷ13/ḷ5/11 vḷ.6 Module utilities for LuaTeX luatexbase-loader.sty 2ḷ13/ḷ5/11 vḷ.6 Lua module loader for LuaTeX luatexbase-regs.sty 2ḷ11/ḷ5/24 vḷ.4 Registers allocation for LuaTeX 464
luatexbase-attr.sty luatexbase-cctb.sty luatexbase-mcb.sty fontspec-patches.sty
2ḷ13/ḷ5/11 vḷ.6 Attributes allocation for LuaTeX 2ḷ13/ḷ5/11 vḷ.6 Catcodetable allocation for LuaTeX 2ḷ13/ḷ5/11 vḷ.6 Callback management for LuaTeX 2ḷ13/ḷ5/2ḷ v2.3c Font selection for XeLaTeX and LuaLaTeX
fixltx2e.sty 2ḷḷ6/ḷ9/13 v1.1m fixes to LaTeX fontspec-luatex.sty 2ḷ13/ḷ5/2ḷ v2.3c Font selection for XeLaTeX and LuaLaTeX fontenc.sty eu2enc.def 2ḷ1ḷ/ḷ5/27 vḷ.1h Experimental Unicode font encodings eu2lmr.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern xunicode.sty 2ḷ11/ḷ9/ḷ9 vḷ.981 provides access to latin accents and many othe r characters in Unicode lower plane eu2lmss.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern graphicx.sty 1999/ḷ2/16 v1.ḷf Enhanced LaTeX Graphics (DPC,SPQR) keyval.sty 1999/ḷ3/16 v1.13 key=value parser (DPC) graphics.sty 2ḷḷ9/ḷ2/ḷ5 v1.ḷo Standard LaTeX Graphics (DPC,SPQR) trig.sty 1999/ḷ3/16 v1.ḷ9 sin cos tan (DPC) graphics.cfg 2ḷ1ḷ/ḷ4/23 v1.9 graphics configuration of TeX Live pdftex.def 2ḷ11/ḷ5/27 vḷ.ḷ6d Graphics/color for pdfTeX fontspec.cfg t3cmr.fd 2ḷḷ1/12/31 TIPA font definitions supp-pdf.mkii epstopdf-base.sty 2ḷ1ḷ/ḷ2/ḷ9 v2.5 Base part for package epstopdf grfext.sty 2ḷ1ḷ/ḷ8/19 v1.1 Manage graphics extensions (HO) kvdefinekeys.sty 2ḷ11/ḷ4/ḷ7 v1.3 Define keys (HO) kvoptions.sty 2ḷ11/ḷ6/3ḷ v3.11 Key value format for package options (HO) kvsetkeys.sty 2ḷ12/ḷ4/25 v1.16 Key value parser (HO) etexcmds.sty 2ḷ11/ḷ2/16 v1.5 Avoid name clashes with e-TeX commands (HO) epstopdf-sys.cfg 2ḷ1ḷ/ḷ7/13 v1.3 Configuration of (r)epstopdf for TeX Live *********** Tags: fontspec (Prev Q) (Next Q), xetex (Prev Q) (Next Q)
465
Q: Why does fontspec change the maths accents (and only with lualatex)? Tags: fontspec (Prev Q) (Next Q), math-mode (Prev Q) (Next Q) In the minimal example that follows luatex doesn’t place the accent correctly (it’s too far left): \documentclass{minimal} \usepackage{fontspec} \setromanfont{Linux Libertine O} \begin{document} \(\bar E\) \end{document} But if I compile it with xelatex, or with lualatex and \setromanfont{Linux Libertine O} commented out, everything works ine. I believed that fonspec was only for text, and not for math. So why this strange behaviour ? Tags: fontspec (Prev Q) (Next Q), math-mode (Prev Q) (Next Q) User: matsaya Answer by egreg This is what I get when calling \showlists after the formula: LuaTeX Skip code block ### horiḶontal mode entered at line 6 \whatsit .\localinterlinepenalty=ḷ .\localbrokenpenalty=ḷ .\localleftbox=null .\localrightbox=null \hbox(ḷ.ḷ+ḷ.ḷ)x2ḷ.ḷ, direction TLT 466
\mathon \vbox(8.2ḷ554+ḷ.ḷ)x7.95831, direction TLT .\hbox(5.67776+ḷ.ḷ)xḷ.ḷ, direction TLT ..\OT1/cmr/m/n/1ḷ ^^V .\kern-4.3ḷ554 .\hbox(6.83331+ḷ.ḷ)x7.95831, direction TLT ..\OML/cmm/m/it/1ḷ E \mathoff XeTeX Skip code block ### horiḶontal mode entered at line 6 \hbox(ḷ.ḷ+ḷ.ḷ)x2ḷ.ḷ \mathon \vbox(8.2ḷ554+ḷ.ḷ)x7.95831 .\hbox(5.67776+ḷ.ḷ)xḷ.ḷ, shifted 2.31252 ..\OT1/cmr/m/n/1ḷ ^^V .\kern-4.3ḷ554 .\hbox(6.83331+ḷ.ḷ)x7.95831 ..\OML/cmm/m/it/1ḷ E \mathoff There is clearly a problem with LuaTeX; it can be due to fontspec as, when not loading it or loading a diferent font than Linux Libertine O (I tested Old Standard and TeX Gyre Termes) I get the following: LuaTeX (without Linux Libertine O) Skip code block ### horiḶontal mode entered at line 6 \whatsit .\localinterlinepenalty=ḷ .\localbrokenpenalty=ḷ .\localleftbox=null .\localrightbox=null \hbox(ḷ.ḷ+ḷ.ḷ)x2ḷ.ḷ, direction TLT 467
\mathon \vbox(8.2ḷ554+ḷ.ḷ)x7.95831, direction TLT .\hbox(5.67776+ḷ.ḷ)xḷ.ḷ, shifted 2.31252, direction TLT ..\OT1/cmr/m/n/1ḷ ^^V .\kern-4.3ḷ554 .\hbox(6.83331+ḷ.ḷ)x7.95831, direction TLT ..\OML/cmm/m/it/1ḷ E \mathoff Tags: fontspec (Prev Q) (Next Q), math-mode (Prev Q) (Next Q)
Q: fontspec option ”Renderer=Basic” - what does it mean? Tags: fontspec (Prev Q) (Next Q), microtype (Prev Q) (Next Q) Since a few days I’ve been using the fontspec option \setmainfont[Renderer=Basic] ... in order to use the microtype option tracking=true with LuaLaTeX. I have a simple question on this: why does using Renderer=Basic make computing my pdf sooooo much slower. It takes virtually hours now to complete on single run with lualatexmk -- and several (10+) minutes of high-fan-activity computing with the normal lualatex engine. So, again: what does Renderer=Basic mean? And what is the diference to the default? Tags: fontspec (Prev Q) (Next Q), microtype (Prev Q) (Next Q) User: clinteastwood Answer by philipp-gesang Version 2.4 of Luaotload (CTAN link) oicially supports letterspacing similar to Xetex. You can enable it at font deinition time (see the manual for details): \font \mainfont = "file:Iwona-Regular.otf:letterspace=15" at 42pt 468
where the value is a percentage of the requested font size, i.e. 6.3 pt in above example. (Alternatively, you can specify the value directly as a factor using the option kernfactor. In order to achieve the same efect as in the example you would add kernfactor=ḷ.15. The kern factor, though equivalent to letterspace in functionality, makes more sense internally and is to a large extent consistent with the behavior of Context’s \setcharacterkerning family of macros that the letterspacing code is derived from.) This width is inserted as additional kern between glyphs, with special handling for already existing kerns, ligatures, and other denizens of TeX’s node list. In Fontspec terms, the feature should be directly accessible via the LetterSpace key of \fontspec, \set.*font etc. Beware, since this feature is quite new and only tested so much, there may still be some issues with it. Currently (January 2014) there are two bug reports on the tracker that have patches in version 2.4 but require further testing. Also, the output is not guaranteed to be identical with Xetex or the \letterspacefont primitive (or Pdftex, for that matter). For comparison, a short test ile: Skip code block \def \testfont {Iwona-Regular.otf} %\def \testfont {lmroman1ḷ-regular.otf} %\def \testfont {MinionPro_Regular.otf} \def \testsiḶe {2ḷpt} \ifdefined \directlua \input luaotfload.sty \font \mainfont = "file:\testfont" at \testsiḶe \font \mainfontlskern = "file:\testfont:letterspace=15" at \testsiḶe \letterspacefont \mainfontlsfont = \mainfont 15ḷ \else \font \mainfont = "[\testfont]" at \testsiḶe \font \mainfontlskern = "[\testfont]:letterspace=15" at \testsiḶe \def \mainfontlsfont {} \fi
469
\newdimen \scratchwd \newbox \scratchbox \def \test #1{% foo \begingroup #1% \setbox \scratchbox \hbox {bar baḶ}% \global \scratchwd = \wd \scratchbox% \box \scratchbox \endgroup\ bar (\the \scratchwd) \endgraf } \mainfont \test \mainfontlskern %% font kerning \test \mainfontlsfont %% increased sidebearings \bye The values for \letterspacefont and the letterspace option may difer in subtle ways. According to the Pdftex manual, This primitive creates an instance of \Something{font} with the widths of all glyphs increased by \Something{integer} thousandths of an em (as set in \Something{font}). The effect is letter spacing, but the glyphs are actually larger (sidebearings are increased), so a single glyph will take more space. Afaics the same holds for the Luatex implementation of \letterspacefont. Since the font size and the em (quad) dimension are identical for most fonts, the output should not difer by much. There is, however, another more visible diference: the \letterspacefont method also afects surrounding spaces whereas letterspace only works between glyphs. This behavior may change in future versions, or the microtype package may add support for adapting the spacing. 470
In summation, there are three approaches to letterspacing in modern TeX: • extending sidebearings of glyphs -- this is the strategy used in Pdftex as well as Luatex’s \letterspacefont. The value is speciied in thousandths of an em. • adding spaces between glyphs -- according to the fontspec manual, this is the Xetex approach. The value is speciied in hundredths (percent) of the font size. • inserting kerns between glyphs -- this is what Context and Luaotload do. In Context and Luatoload with the kernfactor option, the value is a factor applied to the font size. Luaotload’s letterspace option (which is again used by the fontspec package) emulates Xetex in that it interprets the value as hundredths (percent) of the font size. Post scriptum regarding the original question: fontspec’s Renderer option, when used with Luaotload, selects one of the two available processing modes. • base mode, which is the default in Context, should be “good enough” for most Latin-based scripts. Usually, though apparently not in OP’s case, it results in faster typesetting. The drawback is that base mode omits most Opentype features, so it is not an option for many scripts. The implementation is in font-otb.lua. • node mode, which is the default in Luaotload, applies Opentype font features during typesetting, at the cost of a minor performance loss. The features ccmp, locl, rlig, liga, clig, kern, mark, and mkmk are active by default for the DFLT script (in Luaotload, not Context). You can look up their deinition in the Opentype spec. The implementation can be found in font-otn.lua. Tags: fontspec (Prev Q) (Next Q), microtype (Prev Q) (Next Q)
471
Q: How to typeset a letter or grapheme specimen with alternates? Tags: fontspec (Prev Q) (Next Q), opentype (Prev Q) (Next Q), tikz-pgf (Next Q) I want to print a font specimen for certain letters, each of which should cover a complete A4 page. The Open Type font contains many letters with several glyphs, which are accessible as character variants (cc..), in stylistic sets (ss..), as contextual and positional alternates (calt; init, medi, fina), local or historic forms (locl; hist) or otherwise; some are available through diferent methods, of course. Some letters are also part of ligatures (liga, dlig, clig, hlig). Most of them can be seen with Access All Alternates (aalt) in GUIs. I’d like to typeset them all at the same font size, which would be considerably larger than \Huge, say 5 cm (140 pt or so). Preferably, they would be put on a background that showed light lines at baseline, x-height, cap-height or ascender-height and descender-height, all determined automatically if possible. The thing is, I have no idea if LuaTeX or Tikz/PGF or a combination thereof is the best tool for the job. The specimens might become part of a .tex document later on, but I could live with independent pages for now. So any pointers in the right direction are appreciated. • How do I draw and, most importantly, correctly position the horizontal lines – automatically? (Background colors to show the “bands” would be okay, too.) • Is there a better way to access glyphs (without Unicode position) by name than shown in the code below? Rough concept Using Linux Libertine as an example without employing OT features yet. Skip code block % !TEX TS-program = LuaLaTeX \documentclass{scrartcl}
472
\usepackage{fontspec,xcolor,libertine,graphicx} \setmainfont[Color=brown]{Linux Libertine O} % access glyph by name with LuaTeX \usepackage{luaotfload,luacode} \begin{luacode} documentdata = documentdata or { } local stringformat = string.format local texsprint = tex.sprint local slot_of_name = luaotfload.aux.slot_of_name documentdata.fontchar = function (chr) local chr = slot_of_name(font.current(), chr, false) if chr and type(chr) == "number" then texsprint (stringformat ([[\char"%X]], chr)) end end \end{luacode} \newcommand\linecolor{gray} \newcommand\lineheight{1mm} \newcommand\linelength{\textwidth}
% \horiḶontalline{}{}{}{} \newcommand\horiḶontalline[4]{\relax} % en dash U+ḷḷ2D U+ḷḷ2D U+ḷḷ2D U+2ḷ14 ; --- -> em dash U+ḷḷ27 U+ḷḷ27 U+ḷḷ27 U+ḷḷ22
>
U+2ḷ19 U+2ḷ1D U+2ḷ1D
; ' -> right single quote ; '' -> right double quote ; " -> right double quote
U+ḷḷ6ḷ U+ḷḷ6ḷ U+ḷḷ6ḷ
U+2ḷ18 U+2ḷ1C
; ` -> left single quote ; `` -> left double quote
U+ḷḷ21 U+ḷḷ6ḷ U+ḷḷ3F U+ḷḷ6ḷ
U+ḷḷA1 U+ḷḷBF
; !` -> inverted exclam ; ?` -> inverted question
; additions supported in T1 encoding U+ḷḷ2C U+ḷḷ2C U+2ḷ1E ; ,, -> DOUBLE LOW-9 QUOTATION MARK U+ḷḷ3C U+ḷḷ3C U+ḷḷAB ; LEFT POINTING GUILLEMET 595
U+ḷḷ3E U+ḷḷ3E U+ḷ41ḷ U+ḷ411 U+ḷ412 U+ḷ413 U+ḷ414 U+ḷ415 U+ḷ416 U+ḷ417 U+ḷ418 U+ḷ41A U+ḷ41B U+ḷ41C U+ḷ41D U+ḷ41E U+ḷ41F U+ḷ42ḷ U+ḷ421 U+ḷ422 U+ḷ423 U+ḷ424 U+ḷ426 U+ḷ427 U+ḷ428 U+ḷ42D U+ḷ42E U+ḷ42F U+ḷ4ḷ1 U+ḷ43ḷ U+ḷ431 U+ḷ432 U+ḷ433 U+ḷ434 U+ḷ435 U+ḷ436 U+ḷ437
U+ḷḷBB
U+ḷḷ41 ; A U+ḷḷ42 ; B U+ḷḷ56 ; V U+ḷḷ47 ; G U+ḷḷ44 ; D U+ḷḷ45 ; E U+ḷ17D ; Ž U+ḷḷ5A ; Z U+ḷḷ4A ; J U+ḷḷ4B ; K U+ḷḷ4C ; L U+ḷḷ4D ; M U+ḷḷ4E ; N U+ḷḷ4F ; O U+ḷḷ5ḷ ; P U+ḷḷ52 ; R U+ḷḷ53 ; S U+ḷḷ54 ; T U+ḷḷ55 ; U U+ḷḷ46 ; F U+ḷḷ43 ; C U+ḷ1ḷC ; Č U+ḷ16ḷ ; Š U+ḷ116 ; Ė U+ḷḷ4A U+ḷḷ75 U+ḷḷ4A U+ḷḷ61 U+ḷḷCB ; Ë U+ḷḷ61 ; a U+ḷḷ62 ; b U+ḷḷ76 ; v U+ḷḷ67 ; g U+ḷḷ64 ; d U+ḷḷ65 ; e U+ḷ17E ; ž U+ḷḷ7A ; Ḷ
; >> -> RIGHT POINTING GUILLEMET
; Ju ; Ja
596
U+ḷ438 U+ḷ439 U+ḷ43A U+ḷ43B U+ḷ43C U+ḷ43D U+ḷ43E U+ḷ43F U+ḷ44ḷ U+ḷ441 U+ḷ442 U+ḷ443 U+ḷ444 U+ḷ446 U+ḷ447 U+ḷ448 U+ḷ44D U+ḷ44E U+ḷ44F U+ḷ451 U+ḷ456 U+ḷ4ḷ6 U+ḷ454 U+ḷ468 U+ḷ425 U+ḷ445 U+ḷ418 U+ḷ429 U+ḷ42A U+ḷ42B U+ḷ42C U+ḷ449 U+ḷ44A U+ḷ44B U+ḷ44C
U+ḷḷ69 U+ḷḷ6A U+ḷḷ6B U+ḷḷ6C U+ḷḷ6D U+ḷḷ6E U+ḷḷ6F U+ḷḷ7ḷ U+ḷḷ72 U+ḷḷ73 U+ḷḷ74 U+ḷḷ75 U+ḷḷ66 U+ḷḷ63 U+ḷ1ḷD U+ḷ161 U+ḷ117 U+ḷḷ6A U+ḷḷ6A U+ḷḷEB U+ḷḷ69 U+ḷḷ49 U+ḷḷ6A U+ḷḷ4A U+ḷḷ58 U+ḷḷ78 U+ḷḷ49 U+ḷ16ḷ U+ḷḷ27 U+ḷḷ59 U+2ḷ19 U+ḷ161 U+2ḷ19 U+ḷḷ79 U+2ḷ19
; i ; j ; k ; l ; m ; n ; o ; p ; r ; s ; t ; u ; f ; c ; č ; š ; ė U+ḷḷ75 U+ḷḷ61 ; ë ; i ; I U+ḷḷ65 U+ḷḷ65 ; X ; x ; I U+ḷ1ḷC ; ' ; Y ; ' U+ḷ1ḷD ; ' ; y ; '
; ju ; ja
; je ; Je
; ŠČ
; šč
and run it through teckit_compile to produce the ile cyrillic-to-latin.tec ile that should be put in a place where XeTeX can ind it. Then a document 597
such as the following Skip code block \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{Linux Libertine O} \usepackage{polyglossia} \setmainlanguage{english} \setotherlanguage{russian} \newfontfamily{\transrussian}[Mapping=cyrillic-to-latin]{Linux Libertine O} \newenvironment{translitterated} {\transrussian\hyphenrules{nohyphenation}\ignorespaces} {\ignorespacesafterend} \begin{document} \begin{russian} — , , , . ( 1 2ḷ12 — 11 629 116 ), . . \end{russian} \begin{translitterated} — , , , . ( 1 2ḷ12 — 11 629 116 ), . . \end{translitterated} \end{document} 598
will give a result similar to the following
599
600
The nohyphenation in the translitterated environment deinition is necessary as XeTeX doesn’t know how to hyphenate translitterated Russian. Tags: xetex (Prev Q) (Next Q)
Q: Accessing side-bearings in LuaTeX Tags: xetex (Prev Q) (Next Q) This question has been solved, in XeTeX, by this code: \def\kright#1{\leavevmode #1\kern-\XeTeXglyphbounds3 \the\XeTeXcharglyph`#1 } \def\kleft#1{\leavevmode \kern-\XeTeXglyphbounds1 \the\XeTeXcharglyph`#1 #1} which allows me to align text more precisely to the ink by accessing the side-bearing measurements (\XeTeXglyphbounds1 and 3). This XeTeX dependency is currently the only thing stopping me from moving to LuaTeX (mainly for microtype). Is an equivalent function available in LuaTeX, or planned? After reading a bit more on microtype, could the equivalent efect be achieved by an appropriately-tailored set of character protrusions? That way, my move to LuaTeX might be a lot simpler. Tags: xetex (Prev Q) (Next Q) User: brent.longborough Answer by philipp-gesang While preparing a font for Luatex, the fontloader also sets up some extra tables inside the font structure that contain the unprocessed data as returned by fontloader.open(). Among these is the glyph data: For every glyph in 601
the font there is some additional information that is not contained in the characters array since it is unnecessary for Luatex to render a font. For instance, this is a dump of the information about the glyph a: Skip code block table={ ["boundingbox"]={ 45, -1ḷ, 432, 46ḷ }, ["depth"]=1ḷ, ["height"]=46ḷ, ["index"]=9, ["name"]="a", ["slookups"]={ ["as_l_1_s"]={ 632ḷ9, 63329 }, ["ss_cyrl_l_18_s"]=632ḷ9, ["ss_cyrl_l_44_s"]=63329, ["ss_grek_l_17_s"]=632ḷ9, ["ss_grek_l_43_s"]=63329, ["ss_l_16_s"]=632ḷ9, ["ss_l_37_s"]=632ḷ9, ["ss_l_42_s"]=63329, }, ["width"]=512, } There we ind everything we need to calculate the sidebearings in the boundingbox array: The irst value is the left sidebearing. The third value is the bbox width. (Dimensions are in hundredths of a TeX point.) Skip code block packagedata packagedata.sidebearings local sidebearings
= packagedata or { } = { } = packagedata.sidebearings
local utfbyte local texsprint
= utf.byte = tex.sprint
local get_sidebearings = function (id, char) local tfmdata = font.getfont (id) 602
if not (tfmdata and tfmdata.shared) then return ḷ, ḷ end local descriptions = tfmdata.shared.rawdata.descriptions local glyphdata = descriptions [char] if not glyphdata then --- font lacks the glyph return ḷ, ḷ end local local local local
boundingbox lside wd rside
= = = =
glyphdata.boundingbox boundingbox [1] or ḷ boundingbox [3] or glyphdata.width glyphdata.width - wd
inspect (glyphdata) return lside / 1ḷḷ, rside /1ḷḷ end local sidebearings = function (id, char, left) char = utfbyte (char) local lside, rside = get_sidebearings (id, char) if left then texsprint (tostring (lside), "pt") else texsprint (tostring (rside), "pt") end end packagedata.sidebearings.left = function (char) return sidebearings (font.current (), char, true) end packagedata.sidebearings.right = function (char) return sidebearings (font.current (), char, false) 603
end Now we can wrap those functions on the TeX end like so: \def \lsidebearing #1{% \directlua {packagedata.sidebearings.left [[#1]]}% } \def \rsidebearing #1{% \directlua {packagedata.sidebearings.right [[#1]]}% } These can be used just like \XeTeXglyphbounds with the argument 1 and 3 respectively. For comparison, here is a test ile that runs with both Xetex and Luatex: Skip code block \ifdefined \directlua \input luaotfload.sty \directlua {require "sidebearings"} \def \lsidebearing #1{% \directlua {packagedata.sidebearings.left [[#1]]}% } \def \rsidebearing #1{% \directlua {packagedata.sidebearings.right [[#1]]}% } \font \mainfont = "file:Iwona-Regular.otf" \else \def \lsidebearing #1{\the \XeTeXglyphbounds1 \the \XeTeXcharglyph`#1} \def \rsidebearing #1{\the \XeTeXglyphbounds3 \the \XeTeXcharglyph`#1} \font \mainfont = "[Iwona-Regular.otf]" \fi \mainfont
604
\def \test #1{[#1] left: \lsidebearing {#1}, right: \rsidebearing {#1}\par} \test \test \test \test \test \test \test \test
a b y Ḷ
\bye
Convenience gist of the iles. Answer by topskip Yes and no. When you load the font via the built-in fontloader library (which 605
is very low level), you can access all the information of the font ile. This includes the bounding box, as far as I can see (look at the section 4.4.5.1.2 ”Glyph items” in the LuaTeX reference manual). But normally you load the fonts via the fontspec / luaotload packages, which discard that information and only keep what is needed for TeX. I doubt that inclusion of that information is planned in the luaotload package, which is based on ConTeXt’s font loader. Tags: xetex (Prev Q) (Next Q)
Q: Access speciic characters in LuaTeX Tags: xetex (Prev Q) (Next Q), symbols (Prev Q) (Next Q) Recently, I switched from XeTeX to LuaTex for a document of mine. However, there is a feature which I do not immediately see how to convert: Accessing speciic characters. In particular, I need the upright double quote. In the font I use, however, the standard \dq command produces upper 99 quotes. In XeTeX, I therefore redeined the command: \renewcommand\dq{\XeTeXglyph\XeTeXglyphindex"quotedbl"} 1. How can I do that in general, ie. how can I access all the glyphs in the font, whereever they might be placed (even without a codepoint, perhaps)? 2. Is there another way to access the upright double quote? Tags: xetex (Prev Q) (Next Q), symbols (Prev Q) (Next Q) User: mpi Answer by alan-munn You should be able to enter any characters from your font directly into your source, just like in XeTeX. With respect to the double upright quote, you need 606
to load the font without the [Ligatures=TeX] option (or if you want the most of the TeX replacements, but not the " replacement, you can speciically turn of the TeX quote replacement feature:) Skip code block \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=TeX,RawFeature=-trep]{Linux Libertine O} \begin{document} "This is in upright quotes but will preserve e.g. --- replacement" \addfontfeature{RawFeature=+trep} "This has replaced quotes" \addfontfeature{RawFeature=-trep;-tlig} "This is in upright quotes and doesn't preserve e.g. --- replacement" \end{document} The raw features are described in the luaotfload manual; the rest is plain fontspec. The default behaviour (if you don’t load a font explicitly) is to turn on both features so as to mimic standard TeX behaviour. Answer by khaled-hosny Assuming you are using luaotload (which is true if you are using fontspec as well), you can use the lua function fonts.otf.char() which takes either glyph name or glyph index, e.g.: Skip code block \documentclass{article} \usepackage{fontspec} \setmainfont{TeX Gyre Pagella} \def\fontchar#1{\directlua{fonts.otf.char("#1")}} \def\dq{\fontchar{quotedbl}} \begin{document} \dq 607
\end{document} Tags: xetex (Prev Q) (Next Q), symbols (Prev Q) (Next Q)
Q: Do XeTeX and LuaTeX always use Unicode? Tags: xetex (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), unicode (Prev Q) (Next Q), tex-core (Prev Q) (Next Q) I am writing some functions to manipulate strings. A typical way to produce a character with a given character code is the \lowercase primitive. The following code produces a character with code 234, and displays it to the terminal. \lccode`*=234 \lowercase{\message{*}} If I replace 234 by 345 above, then pdfTeX raises an error: Invalid code (345), should be in the range ḷ..255. On the other hand, LuaTeX and XeTeX are happy up to 1114111, as expected from a Unicode-compliant engine. Now, I want my macros to be as robust as possible. Is it always true that the maximum lccode is 255 in pdfTeX and 1114111 in LuaTeX and XeTeX? Or can a user prevent in any way the engine from using the full range, hence confusing my macros? Tags: xetex (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), unicode (Prev Q) (Next Q), tex-core (Prev Q) (Next Q) User: bruno-le-loch Answer by ulrike-ischer The LuaTeX manual says quite clearly that \char now accepts values between 0 and 1114111 and extends this statement to the other similar com-
608
mands like \lccode. As far as I know this is true in XeTeX too. And IMHO a command line to change this seems rather senseless. But the eTeX extension can be disabled in both engines. Or more precisely: XeTeX has a command line option to enable the eTeX extension (which is used by default by all TeX Systems) and LuaTeX has a similar feature. So it is possible to build a format manually which doesn’t use them. But this afects only the eTeX relevant commands. Tags: xetex (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), unicode (Prev Q) (Next Q), tex-core (Prev Q) (Next Q)
Q: PDF/X-1a on TeX Live 2014 for publishing with POD lightining source Tags: xetex (Prev Q) (Next Q) I am trying to get a PDF/X-1a compliant PDF for sending the pdf to Lightning Source for publishing books. I searched and found the following post and tested it PDF/A with hyperref on TeX Live 2013 And ran the following code in TexStudio Skip code block % =============================== % Filename: test.tex \documentclass{article} % % % %
=============================== Embedding the color profile. Requires eciRGB_v2.icc in the working directory http://www.eci.org/_media/downloads/icc_profiles_from_eci/ecirgbv2ḷ.Ḷip
609
\pdfminorversion 4 \immediate\pdfobj stream attr{/N 3} file{eciRGB_v2.icc} \pdfcatalog{% /OutputIntents [ > ] } \usepackage{xcolor} \usepackage{hyperxmp} \usepackage[pdftex, pdfa, linktoc=none]{hyperref} % ---------------------------------------------% Add metadata \hypersetup{% pdftitle={Title}, pdfauthor={Author}, pdfauthortitle={Title of the Author}, pdfcopyright={Copyright (C) 2ḷxx, Copyrightholder}, pdfsubject={Something}, pdfkeywords={Keyword1, Keyword2}, pdflicenseurl={http://creativecommons.org/licenses/by-nc-nd/3.ḷ/}, pdfcaptionwriter={Scott Pakin}, pdfcontactaddress={Street}, pdfcontactcity={City}, pdfcontactpostcode={1ḷ1}, pdfcontactcountry={Country}, pdfcontactemail={[email protected]}, pdfcontacturl={http://www.institute.edu}, pdflang={en}, bookmarksopen=true, bookmarksopenlevel=3, 610
}
hypertexnames=false, linktocpage=true, plainpages=false, breaklinks
\begin{document} What cat says? \label{meow} See question on page \pageref{meow}. \end{document} Then ran the Prelight in Adobe Acrobat Pro XI, for PDF/A-1b variication, it came out with no problems. how changes do we have to make it to work with PDF/X-1a and PDF/X-3? Is there a way to get PDF/X-1a fully compliant pdf with PDFLaTex or XeLateX or LuaLaTeX? Tags: xetex (Prev Q) (Next Q) User: ibn-saeed Answer by dg’ Update: Since the original answer, the PDF api in luatex changed. In order to use this code you have to load luatex85 This should do the trick for PDF/X-1a (you need ISOcoated_v2_300_eci.icc in the current directory): Skip code block % =============================== % Filename: test.tex \documentclass{article} % =============================== % Embedding the color profile. % Requires ISOcoated_v2_3ḷḷ_eci.icc in the working directory 611
% http://www.eci.org/_media/downloads/icc_profiles_from_eci/eci_offset_2ḷḷ9.Ḷip \usepackage{luatex85} \pdfminorversion=3 \pdfpageattr{/MediaBox[ḷ ḷ 595 793] /BleedBox[ḷ ḷ 595 793] /TrimBox[25 2ḷ 57ḷ 773]} \immediate\pdfobj stream attr{/N 4} file{ISOcoated_v2_3ḷḷ_eci.icc} \pdfcatalog{% /OutputIntents [ > ] } \pdfinfo{% /Title(Title)% /GTS_PDFXVersion (PDF/X-1:2ḷḷ1)% /GTS_PDFXConformance (PDF/X-1a:2ḷḷ1)% } \usepackage[cmyk]{xcolor} \usepackage{hyperxmp} \usepackage[pdftex, draft]{hyperref} \begin{document} What cat says? \label{meow} See question on page \pageref{meow}. \end{document} Works with pdlatex and lualatex but not xelatex. Tags: xetex (Prev Q) (Next Q)
612
Q: Fix message about outdated xelatex Tags: xetex (Prev Q) (Next Q), polyglossia (Next Q) I’m a new to (La)Tex. The problem I’m having it that every output document (pdf) starts with Your xelatex format appears to be outdated!Please update your system and recreate it with fmtutil. I’m using LuaTeX (I need unicode) and TeXlipse on Arch Linux. Here is the output from the command: http://pastie.org/5351646 (out of the Eclipse console) and here is the output from lualatex small2e: http: //pastie.org/5351655 Here is the preamble: Skip code block \documentclass{article} \usepackage[Ligatures=TeX]{fontspec} \setmainfont[Ligatures=TeX]{DejaVu Serif} \setsansfont[Ligatures=TeX]{DejaVu Sans} \setmonofont[Ligatures=TeX]{DejaVu Sans Mono} \usepackage{polyglossia} \setmainlanguage{bulgarian} \usepackage{minted} \begin{document} % ... rest of document with Cyrillic in it I will update the question with more details as soon as I know what they should be Tags: xetex (Prev Q) (Next Q), polyglossia (Next Q) 613
User: emil-ivanov Answer by egreg The error message you get is ! Undefined control sequence. \xpg@error {Your xelatex format appears to be outdated! so it’s only by chance that you see the ”outdated” message. The error is that \xpg@error is not deined and it’s due to the fact that you can’t use Polyglossia with LuaLaTeX, but only with XeLaTeX. You have two possibilities: 1. Compile with LuaLaTeX but load babel \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{DejaVu Serif} \setsansfont[Ligatures=TeX]{DejaVu Sans} \setmonofont[Ligatures=TeX]{DejaVu Sans Mono} \usepackage[bulgarian]{babel} \usepackage{minted} \begin{document} , , , , 1/6 . \end{document} 2. Compile with XeLaTeX \documentclass{article} \usepackage{fontspec} 614
\setmainfont[Ligatures=TeX]{DejaVu Serif} \setsansfont[Ligatures=TeX]{DejaVu Sans} \setmonofont[Ligatures=TeX]{DejaVu Sans Mono} \usepackage{polyglossia} \setmainlanguage{bulgarian} \usepackage{minted} \begin{document} , , , , 1/6 . \end{document} In both cases the paragraph is typeset as in the following image.
Tags: xetex (Prev Q) (Next Q), polyglossia (Next Q)
Q: British hyphenation with either xelatex or lualatex Tags: xetex (Prev Q) (Next Q), hyphenation (Prev Q) (Next Q), babel (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q) For several reasons, I am working on a source ile that should be compilable by either xelatex or lualatex. I would like British hyphenation for the text and am using csquotes and biblatex with british options. On the XeTeX mailing list two things were mentioned: (a) Use polyglossia, not babel with xelatex; 615
(b) polyglossia is incompatible with lualatex at present; use babel instead. I show below a sample ile with my question and my present setup. Skip code block
\documentclass[12pt,a4paper]{memoir} % \usepackage{fontspec} \setmainfont{Minion Pro} \setsansfont{Myriad Pro} % % We want to compile with either xelatex or lualatex % The former requires polyglossia for british hyphenation % The latter requires bable for british hyphenation % % Ideally something like (unsure if this is correct) % % \ifxetex % \usepackage{polyglossia} % \setmainlanguage[variant=british]{english} % % \ifluatex % usepackage[british]{babel} % % should work but I do not know the correct syntax for it. % % My workaround is: % \makeatletter \language=\l@british \makeatother % % which works but is inelegant in a *LaTeX source file. % \usepackage[backend=biber,babel=none,date=iso86ḷ1,urldate=iso86ḷ1,language=british \usepackage[english=british]{csquotes} \begin{document} 616
Try some hyphenation, some \enquote{quotations}, and some references to see if e \end{document} Any suggestions to make hyphenation and other language features like date work consistently across both xelatex and lualatex is most welcome. Tags: xetex (Prev Q) (Next Q), hyphenation (Prev Q) (Next Q), babel (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q) User: chandra Answer by egreg While polyglossia is widely recommended for XeLaTeX usage, babel can still be used for languages that need only the Latin alphabet. Answer by igor-kotelnikov \usepackage{ifluatex,ifxetex} \ifxetex \usepackage{polyglossia} \setmainlanguage[variant=british]{english} \else\ifluatex \usepackage[british]{babel} \fi\fi This loads polyglossia for xetex and babel for luatex. Tags: xetex (Prev Q) (Next Q), hyphenation (Prev Q) (Next Q), babel (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q)
Q: XeLaTex and TexMaker ”cannot-use-pdftex” Tags: xetex (Prev Q) (Next Q) I would like to use the CV template provided by this link. 617
In the .tex ile the author recommends to compile with XeLaTeX. In TeXmaker 4.0, I’ve used the right option to compile but the following error showed up: ! Fatal fontspec error: ”cannot-use-pdftex” Should I try to compile using the LuaLaTeX support? EDIT The texlive-xetex package was not installed on the system sudo apt-get install texlive-xetex -> Now I can compile. Another error came out: File ‘layaureo.sty’ not found EDIT 2 I installed texlive-lang-italian package sudo apt-get install texlive-lang-italian Now the error is: ! Font \XeTeXLink@font=pzdr at 0.00002pt not loadable: Metric (TFM) ile or ins Solved using sudo apt-get install texlive-fonts-recommended from my old question Tags: xetex (Prev Q) (Next Q) User: userk Answer by userk The package required to compile using XeLaTeX was not installed on my linux ditribution. Solved with: sudo apt-get install texlive-xetex Tags: xetex (Prev Q) (Next Q)
618
Q: Is there a LuaTeX analogue to XeTeXinterchartoks? Tags: xetex (Prev Q) (Next Q) Just as the title of the questions says, is there an LuaTeX analogue to XeTeXinterchartoks? Tags: xetex (Prev Q) (Next Q) User: pmav99 Answer by leo-liu I hope so, but the answer is no. We use \XeTeXinterchartoks mechanism heavily to implement Ḷhspacing and xeCJK packages to support auto font switching and other features or CJK. But we cannot transplant them to LuaTeX. Now the same feature in LuaTeX (zhfonts module of ConTeXt) uses a totally diferent mechanism to implement: \definefontfallback and pre_linebreak_filter etc. If you want to do similar things in Greek, I hope it would help. Tags: xetex (Prev Q) (Next Q)
Q: Can XeLaTeX | LuaTeX import movies? Tags: xetex (Prev Q) (Next Q), beamer (Prev Q) (Next Q) It seems that XeLaTeX cannot handle movies. I imported movies into PDF produced with pdlatex compiler using the multimedia package that comes with beamer. My search over various boards revealed that currently there is no package that could import movies under XeLaTeX. Is that correct? And what about LuaLaTeX?
619
UPDATE: This question became obsolete with the advent of media9 package. Tags: xetex (Prev Q) (Next Q), beamer (Prev Q) (Next Q) User: igor-kotelnikov Answer by cefstat There is a version of movie15.sty called movie15_dvipdfmx.sty, see http: //www.ctan.org/tex-archive/graphics/asymptote/patches/, that allows the inclusion of movies with xelatex with \includemovie. Since it may not be clear, as there is no documentation, the package movie15_dvipdfmx.sty should be passed the option dvipdfmx for use with xelatex, that is, \usepackage[dvipdfmx]{movie15_dvipdfmx}. Tags: xetex (Prev Q) (Next Q), beamer (Prev Q) (Next Q)
Q: Expex glosses get broken when unicode-math is loaded in XeLaTeX and LuaLaTeX Tags: xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q) I’m trying to typeset multiline numbered examples with John Frampton’s expex package (version 4.1). Since I’m using XeLaTeX (TeXLive 2012), I’ve picked unicode-math to typeset maths. The following MWE illustrates the problem, which is that the irst and second lines of the multiline example are no longer separated properly: Skip code block \documentclass{article} \usepackage{fontspec} \usepackage{unicode-math} \usepackage{expex} 620
\setmathfont{Latin Modern Math} \begin{document} \ex \begingl \gla See on lühike tekst {eesti keeles}.// \glb This is short text {in Estonian}// \glft `This is a short text in Estonian.'// \endgl \xe \end{document} The only warning I get is the innocuous xparse/redeine-command warning, and once I remove unicode-math, the output looks as desired. What’s going on here and is there a solution? I should probably add that the same behaviour is observed when I compile with LuaLaTeX. Tags: xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q) User: pavel-rudnev Answer by egreg The unicode-math package deines a \gla command for a (quite rare) character. You can do it with the following trick: Skip code block \documentclass{article} \usepackage{fontspec} \usepackage{unicode-math} \setmathfont{Latin Modern Math} \usepackage{expex} 621
\let\expexgla\gla \AtBeginDocument{\let\gla\expexgla} \begin{document} \ex \begingl \gla See on lühike tekst {eesti keeles}.// \glb This is short text {in Estonian}// \glft `This is a short text in Estonian.'// \endgl \xe \end{document} The deinitions of unicode-math happen at begin document, so you need to redeine \gla to the saved version after that. Tags: xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q)
Q: Place TikZ picture over top of text Tags: xetex (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q) I’m designing some letterhead using LuaLaTeX (interchangeable with XeLaTeX at this point) where I want my signature and name to be drawn like this:
The signature is a TikZ drawing, the text is normal type raised by negative \vspace{}. However, if you look closely, the text is (naturally) on top of the signature, and I would like to reverse that. 622
I understand why it is on top, but not what I can do to reverse it because the text is positioned relative to the sizing of the signature. Because the above MWE example is 3,878 lines, I made a smaller MWE: Skip code block \documentclass{article} \usepackage{tikḶ} \begin{document} \begin{minipage}{2in} \resiḶebox{2in}{!}{ \begin{tikḶpicture} \draw[color=blue](ḷ,ḷ) circle (2); \end{tikḶpicture}}\par \vspace*{-.15in} \resiḶebox{2in}{!}{Minimum Working Example} \end{minipage} \end{document}
623
The structure is the same, just a simpler drawing and text. Is there any way to force the blue TikZ drawing to display on top of the text below it? Tags: xetex (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q) User: ryan Answer by steven-b.-segletes \documentclass{article} \usepackage{tikḶ,stackengine} \begin{document} \stackon[-5pt]{\resiḶebox{2in}{!}{Minimum Working Example}} {\begin{tikḶpicture}\draw[color=cyan](ḷ,ḷ) circle (2);\end{tikḶpicture}} \end{document} 624
Tags: xetex (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q)
Q: How are non-unicode glyphs referenced in LuaTeX .dvi iles? Tags: xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q), unicode (Prev Q) (Next Q) Dvi iles reference glyphs by their unicode number. However, a document often contain some unencoded glyphs, such as large math symbols. By inspecting dvi iles containing such glyphs, I conclude that these glyphs are referenced by some non-unicode (Private Use Area) character codes. How can I know which character code LuaTeX will choose for a certain glyph, say, the display version of the integral sign? The same question goes for XeTeX, in case they are diferent. 625
Example: \documentclass{standalone} \usepackage{fontspec} \usepackage{unicode-math} \setmainfont{XITS} \setmathfont{XITS Math} \begin{document} $\int\displaystyle\int$ \end{document} When compiled with LuaLaTeX, using the --output-format=dvi option, the small integral is encoded as 0x222B (as expected) and the big integral is encoded as 0x0F001C (somewhat mystifying). Update: Some experimentation conirms that the encoding of the integral sign difers between fonts. The display version of the integral is 0x0F05C2 in Cambria Math, 0x10FF99 in Asana Math and 0x0F0314 in STIX Math, for instance. Tags: xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q), unicode (Prev Q) (Next Q) User: akvilas Answer by martin LuaTeX uses a pretty simple algorithm to choose the DVI character codes: While reading the OTF ile, it checks whether a character has a Unicode point assigned or not. If there’s an entry in the Unicode mapping table, LuaTeX uses the Unicode point. Otherwise, it populates the Unicode range starting at 0xF0000. The irst unmapped character is assigned to 0xF0000, the second one to 0xF0001 etc. Thus, you can only predict the DVI character codes if you evaluate the Unicode table of the OTF fonts yourself. Especially, there’s no relation between the code and the semantics of an unmapped character, i.e. the big integral sign can get diferent DVI codes depending on the mapping tables and the characters present in the various font iles. XeTeX, on the other hand, simply uses the glyph indexes of the characters in an OTF ile if the characters are set with XDV command XGlyphArray 626
or XGlyphString. Each glyph in a font has a unique internal value with no relation to any encoding. The encoding itself is realized by the already mentioned encoding tables that, for example, map from Unicode or ISO-88591 to glyph indexes. So, XeTeX ignores the encodings present in the font ile and uses the glyph indexes directly -- more precisely, those provided by the FreeType library (which may rearrange the values). Tags: xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q), unicode (Prev Q) (Next Q)
Q: How to write a LaTeX command that could discriminate if it’s being called with pdfLaTeX in order to use PSTricks? Tags: xetex (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q) I’m writing a class for LaTeX, and I need to make it general. I want to include a simple image, a logo, within the class, which would be inserted into the document as a simple command \insertCompanyLogo. To avoid extra iles, I added the PostScript deinition of the logo in the .sty ile. % Include PSTricks package \usepackage{pstricks} % Create new command to insert logo \newcommand{\insertCompanyLogo}{ \psset{xunit=.5pt,yunit=.5pt,runit=.5pt} \begin{pspicture}(18ḷ,18ḷ) \psline(ḷ,ḷ)(18ḷ,18ḷ) %The actual image is far more complex \end{pspicture} } This works good when I compile the document with latex . However, it fails when I try to use pdflatex. In order to use PSTricks with pdflatex, some modiications are required. For example, I can add in the .sty ile \usepackage[pdf]{pstricks}. 627
Then compile the document using pdflatex -shell-escape . But this won’t be general, and it won’t work using the regular latex command. My question is: Is there any way to deine a command that understand if the document is being compiled with pdflatex or latex? That way I can add a couple of \ifthenelse{}{}{} to the include line of PSTricks. Thus, the document that uses this .sty class and calls the \insertCompanyLogo could be compiled with both commands without any modiication. I hope I was clear enough. And any solution, tip, recommendation or workaround, as always, is more than welcome. EDIT: Forgot to mention, I think that packages like xelatex and asymptote that could make this easier. But I would like this to work with a standard TexLive or MiKTeX installation, which is probably what 95% of the users of this class will have installed EDIT 2: This question was marked as duplicate. The other questions address the engine issue (pdlatex vs. latex). Helpful information. But they leave out the PSTricks part, and how to make its use lexible and multi-engine, and that was the reason of my question. EDIT 3: At the end, I opted for a completely diferent solution. What I wanted was to put a logo with a macro that works with both engines, latex and pdflatex. I used TiKḶ Skip code block \documentclass{article} % Include package TiKḶ \includepackage{tikḶ} % Create new command to insert logo \newcommand{\insertCompanyLogo}{ \begin{tikḶpicture} \draw[thick,rounded corners=8pt] (ḷ,ḷ) -- (ḷ,2) -- (1,3.25) -- (2,2) -- (2,ḷ) -- (ḷ,2) -- (2,2) -- (ḷ,ḷ) -- (2,ḷ); \end{tikḶpicture} } \begin{document} \insertCompanyLogo 628
\end{document} The actual logo, and the contents of the tikḶpicture environment, I got them from Inkscape, with an extension to export to TiKḶ format. Tags: xetex (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q) User: phollox Answer by herbert That is a bit tricky because \ifpdf cannot be used with xelatex which allows PSTricks code. The following example works with latex, pdflatex, xelatex, and lualatex: Skip code block \documentclass{article} \usepackage{ifpdf} \providecommand\insertCompanyLogo{} \newif\ifPSTricks \PSTrickstrue \usepackage{ifxetex} \ifpdf \PSTricksfalse \ifxetex\PSTrickstrue\fi \fi \ifPSTricks % Include PSTricks package \usepackage{pstricks} % Create new command to insert logo \renewcommand\insertCompanyLogo{% \psset{xunit=.5pt,yunit=.5pt,runit=.5pt} \begin{pspicture}(18ḷ,18ḷ) \psline(ḷ,ḷ)(18ḷ,18ḷ) %The actual image is far more complex \end{pspicture}} \fi \begin{document} 629
PSTricks code is \ifPSTricks\else not \fi possible: \insertCompanyLogo \end{document} Tags: xetex (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q)
Q: How does XeLaTeX and LuaLaTeX extend the dvi format? Tags: xetex (Prev Q) (Next Q) The structure of the DVI ile format is documented by Donald Knuth in TEX: the Program, Addison-Wesley, 1986. Although PDF is the primary output format, LuaTeX can also output DVI iles. Are these DVI iles diferent from what is found in the original speciication? XeTeX can output XDV iles, which are an extension of the DVI format. Is the XDV format documented anywhere? Tags: xetex (Prev Q) (Next Q) User: akvilas Answer by david-carlisle I think luatex generated dvi is standard. For xdv, xetex.web deines the extended format, the relevant parts being Skip code block \yskip\noindent Commands 25ḷ--255 are undefined in normal \.{DVI} files, but the following commands are used in \.{XDV} files. \yskip\hang\vbox{\halign{#\hfil\cr 630
|define_native_font| 252 & |k[4]| |s[4]| |flags[2]| |l[1]| |n[l]| |i[4]|\cr & |if (flags and COLORED) then| |rgba[4]|\cr & |if (flags and EXTEND) then| |extend[4]|\cr & |if (flags and SLANT) then| |slant[4]|\cr & |if (flags and EMBOLDEN) then| |embolden[4]|\cr }} \yskip\hang|set_glyphs| 253 |w[4]| |k[2]| |xy[8k]| |g[2k]|. \yskip\noindent Commands 25ḷ and 255 are undefined in normal \.{XDV} files. @ @d set_char_ḷ=ḷ {typeset character ḷ and move right} @d set1=128 {typeset a character and move right} @d set_rule=132 {typeset a rule and move right} @d put_rule=137 {typeset a rule} @d nop=138 {no operation} @d bop=139 {beginning of page} @d eop=14ḷ {ending of page} @d push=141 {save the current positions} @d pop=142 {restore previous positions} @d right1=143 {move right} @d wḷ=147 {move right by |w|} @d w1=148 {move right and set |w|} @d xḷ=152 {move right by |x|} @d x1=153 {move right and set |x|} @d down1=157 {move down} @d yḷ=161 {move down by |y|} @d y1=162 {move down and set |y|} @d Ḷḷ=166 {move down by |Ḷ|} @d Ḷ1=167 {move down and set |Ḷ|} @d fnt_num_ḷ=171 {set current font to ḷ} @d fnt1=235 {set current font} @d xxx1=239 {extension to \.{DVI} primitives} @d xxx4=242 {potentially long extension to \.{DVI} primitives} @d fnt_def1=243 {define the meaning of a font number} @d pre=247 {preamble} @d post=248 {postamble beginning} @d post_post=249 {postamble ending} 631
@d define_native_font=252 {define native font} @d set_glyphs=253 {sequence of glyphs with individual x-y coordinates} Tags: xetex (Prev Q) (Next Q)
Q: STIX 2.0 font declaration Tags: xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q) Today the STIX v2.0 was released. What is the proper font declaration to make use of various optical sizes etc with unicode-math? Tags: xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q) User: sapere-aude Answer by khaled-hosny You don’t need to do any thing to get the optical sizes included in the math font. They are associated with the ssty feature which unicode-math will enable it for script and scriptscript font sizes. Tags: xetex (Prev Q) (Next Q), unicode-math (Prev Q) (Next Q)
Q: Deining ‘commands’ or ‘macros’ with unicode names Tags: xetex (Prev Q) (Next Q), macros (Prev Q) (Next Q), tex-core (Prev Q) (Next Q) How can I implement the rough equivalent of \def\macro{expansion} so that the macro name can contain spaces and other unicode characters? I’d like to be able to do the following, for example: 632
\defineinsert{qty: 2 activity}{\SI{1.85}{\mega\becquerel}} [...] The measured activity was \insert{qty: 2 activity}. $R_\beta = \insert{qty: 2 activity}$ producing The measured activity was \SI{1.85}{\mega\becquerel}. $R_\beta = \SI{1.85}{\mega\becquerel}$ The motivation is to be able to pre-deine many orderly ‘macros’ in to be used throughout a document, without the restriction that characters must only be [a-ḶA-Z], as imposed by using \def to deine actual commands. I have no idea how to implement this, since I don’t know how one would create key-value mappings with TeX… or if that would be the right approach. Perhaps there is another way of illing this need? Should I start using LuaTeX to accomplish this? (I am presently using XeLaTeX.) Perhaps there exists a package for this? Thanks! Tags: xetex (Prev Q) (Next Q), macros (Prev Q) (Next Q), tex-core (Prev Q) (Next Q) User: jollywatt Answer by ulrike-ischer You can use \csname ...\endcsname for this. \@namedef:
E.g with the help of
Skip code block \documentclass{article} \begin{document} \makeatletter \@namedef{\detokeniḶe{qty: 2 activity}}{bllb} The beta activity \@nameuse{\detokeniḶe{qty: 2 activity}} 633
The beta activity \@nameuse{\detokeniḶe{qty: 2
activity}}
\end{document} For brevity, you may deine something like \makeatletter \newcommand\newshortcut[2]{\@namedef{\detokeniḶe{#1}}{#2}} \newcommand\shortcut[1]{\@nameuse{\detokeniḶe{#1}}} \makeatother which may be used like so: \newshortcut{qty: }{lola} [...] Hello \shortcut{qty: }. Tags: xetex (Prev Q) (Next Q), macros (Prev Q) (Next Q), tex-core (Prev Q) (Next Q)
Q: List of all post original TeX control commands Tags: xetex (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), e-tex (Next Q) Is there a well documented list of all control commands added by all post Knuth’s Tex like PdfTeX, e-TeX, XeTex, LuaTeX? Tags: xetex (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), e-tex (Next Q) User: codefx Answer by charles-stewart
634
You can get the lists programmatically, using LuaTeX, provided you are interested in the new primitives provided by one of the dialects of TeX supported by that engine. By changing the values of the dialect variable in Skip code block
proc = tex.initialiḶe () dialect = "etex" -- The dialect identifiers accepted are: tex (i.e., original Knuth, without Plain -core (core Luatex, that is, which at present is just "directlua", -not in the luatex dialect), -- and the extension dialects: -etex, pdftex, omega, aleph, luatex, umath -- so the primitives introduced by Luatex are the ones in core, luatex, and umath. -- These dialect identifiers are case sensitive: "etex" is accepted by -- tex.extraprimitives, "eTeX" is not. ps = tex.extraprimitives (dialect) for _, v in ipairs(ps) do print (v) end (which you should run using texlua listprims.lua if you have saved the program with that ilename), this code will output the list of primitives for the given possible values. The Unix column utility makes the output nicer to read. The LuaTeX manual lists this output in its tex.extraprimitives section, giving a non-programmatic route to this information if for some reason you prefer that. Not all dialects of TeX are included in LuaTeX; most importantly, XeTeX is not. I think both NTS and ExTeX introduced new primitives -- for these other systems, look up their documentation; XeTeX’s list of primitives is in the XeTeX reference guide. Also note that the dialects change as the software develops. For instance, XeTeX gained primitives for compatibility with pdfTeX, I think relatively recently. As for a single guide providing well-documented lists for all the dialects -- well, since it’s a moving target, I doubt there is enough motivation to produce and 635
maintain such a thing. Tags: xetex (Prev Q) (Next Q), pdftex (Prev Q) (Next Q), e-tex (Next Q)
Q: LuaLaTeX + libertine... the issue of math font Tags: xetex (Prev Q) (Next Q) Would it be possible to use Libertine otf font (using LuaLaTeX and, for example, package libertine for automatic settings) for everything but in math mode where I’d like to use newtxmath and its libertine option (which produces acceptable output with pdfLaTeX)? Neither : \usepackage[libertine]{newtxmath} \usepackage[no-math]{fontspec} \usepackage{libertine} nor \usepackage[libertine]{newtxmath} \usepackage[no-math]{fontspec} \setmainfont[Ligatures={TeX}]{Linux Libertine O} are successful. I get CM font for maths using the following: Skip code block %!TEX program = lualatex \documentclass[]{scrbook} \usepackage{amsmath} \usepackage{amssymb} \usepackage{mathtools} \usepackage[libertine]{newtxmath} 636
\usepackage[no-math]{fontspec} \usepackage{libertine} \begin{document}
\begin{equation} \mathit{TRUC} = \frac{1}{1ḷ} \times \sum _{d=ḷ.2}^{12.8} \frac{\pi \times d \t \end{equation} \end{document} Tags: xetex (Prev Q) (Next Q) User: user2165907 Answer by egreg Since you give the no-math option, you have to help fontspec: Skip code block \documentclass[]{scrbook} \usepackage{amsmath} \usepackage{amssymb} \usepackage{mathtools} \usepackage[libertine]{newtxmath} \usepackage[no-math]{fontspec} \usepackage{libertine} \DeclareSymbolFont{operators}{\encodingdefault}{\familydefault}{\mddefault}{n} \DeclareMathAlphabet{\mathit}{\encodingdefault}{\familydefault}{\mddefault}{it} \DeclareMathAlphabet{\mathbf}{\encodingdefault}{\familydefault}{\bfdefault}{n} \begin{document}
\begin{equation} \mathit{TRUC} = \frac{1}{1ḷ} \times \sum _{d=ḷ.2}^{12.8} \frac{\pi \times d \t 637
\end{equation} $\mathbf{ABC}$ \end{document} Otherwise you need to restore the standard math codes for the digits. Skip code block \documentclass[]{scrbook} \usepackage{amsmath} \usepackage{amssymb} \usepackage{mathtools} \usepackage[libertine]{newtxmath} \usepackage{fontspec} \usepackage{libertine} \AtBeginDocument{% \DeclareMathSymbol{ḷ}{\mathalpha}{operators}{`ḷ}% \DeclareMathSymbol{1}{\mathalpha}{operators}{`1}% \DeclareMathSymbol{2}{\mathalpha}{operators}{`2}% \DeclareMathSymbol{3}{\mathalpha}{operators}{`3}% \DeclareMathSymbol{4}{\mathalpha}{operators}{`4}% \DeclareMathSymbol{5}{\mathalpha}{operators}{`5}% \DeclareMathSymbol{6}{\mathalpha}{operators}{`6}% \DeclareMathSymbol{7}{\mathalpha}{operators}{`7}% \DeclareMathSymbol{8}{\mathalpha}{operators}{`8}% \DeclareMathSymbol{9}{\mathalpha}{operators}{`9}% } \begin{document} \showthe\mathcode`1
\begin{equation} \mathit{TRUC} = \frac{1}{1ḷ} \times \sum _{d=ḷ.2}^{12.8} \frac{\pi \times d \t 638
\end{equation} $\mathbf{ABC}$ \end{document}
Tags: xetex (Prev Q) (Next Q)
Q: Deine MakeUppercase list with XeLaTeX/LuaLaTeX Tags: xetex (Prev Q) (Next Q), babel (Prev Q) (Next Q) I do custom list for to make uppercase/lowercase for 8-bit TeX for Georgian and it works ine, but how to deine it for XeLaTeX/LuaLaTeX? here is a similar question Applying MakeUppercase to non-English characters in math mode this is example. it works for Russian and English Skip code block
\documentclass{article} \usepackage{fontspec} \usepackage[russian,georgian]{babel} \makeatletter \def\update@uclc@with@georgian{% \expandafter\def\expandafter\@uclclist\expandafter {\@uclclist \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \let\update@uclc@with@georgian\relax % } 639
\makeatother \setmainfont{Dejavu Serif} \begin{document} \MakeUppercase{abc } \end{document} Tags: xetex (Prev Q) (Next Q), babel (Prev Q) (Next Q) User: levan-shoshiashvili Answer by joseph-wright You need to tell TeX to map the characters themselves to each other: there are no control sequences involved here. (This is diferent in 8-bit engines where the code points you want are not single bytes.) You also need to make sure this code gets activated when Georgian is selected. For example Skip code block
\documentclass{article} \usepackage{fontspec} \usepackage[russian,georgian]{babel} \makeatletter \g@addto@macro\extrasgeorgian{% \def\update@uccode@georgian#1#2{% \ifx\relax#2\relax \else \uccode`#1=`#2 % \expandafter\update@uccode@georgian \fi }% \update@uccode@georgian \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \relax\relax } \makeatother \setmainfont{Dejavu Serif} 640
\begin{document} \MakeUppercase{abc } \end{document} will work. (I’ve kept your list of escaped characters simply to avoid having to edit it all!) Not directly relevant, but at least worth noting from the point of view of the question ’Why is no case changing happening as standard?’ is the nature of the input you have. For example, is code point U+10D0, listed as 1ḷDḷ;GEORGIAN LETTER AN;Lo;ḷ;L;;;;;N;GEORGIAN SMALL LETTER AN;;;; Notice that this is a caseless letter with no upper/lower mapping. On the other hand, (U+10A0) is a cased letter 1ḷAḷ;GEORGIAN CAPITAL LETTER AN;Lu;ḷ;L;;;;;N;;;;2Dḷḷ; but maps to U+2D00. If we look there we ind 2Dḷḷ;GEORGIAN SMALL LETTER AN;Ll;ḷ;L;;;;;N;;;1ḷAḷ;;1ḷAḷ which does mean there is an upper/lower case pair. However, U+2D00 seems to have a diferent appearance to U+10D0! (I’m not saying Unicode is ’right’ here, just that the data in Unicode TeX engines for case changing is as-standard that taken from the Unicode Consortium, so we can see why there is an issue.) Tags: xetex (Prev Q) (Next Q), babel (Prev Q) (Next Q)
Q: Latex command for unilled \bigstar Tags: xetex (Prev Q), unicode-math (Prev Q) (Next Q), symbols (Prev Q) (Next Q) 641
\bigstar produces a black star. What is the LaTeX command for white or unilled \bigstar? The unicode-math package has a command \bigwhitestar, but I am not able to use it in the usual way. When I compile with \usepackage{unicode-math}, I get the following error: ! Package unicode-math Error: Cannot be run with pdfLaTex! (unicode-math) Use XeLaTeX or LuaLaTex instead. PS: I need the big white star symbol to reference a point in a Matlab generated igure. I cannot compile with xetex or xelatex because they do not use the conference style ile properly, i.e. the output looks quite diferent from that of latex. Tags: xetex (Prev Q), unicode-math (Prev Q) (Next Q), symbols (Prev Q) (Next Q) User: prometheus Answer by steven-b.-segletes If your require some tuning of the star border, this solution is an alternative. The downside is that it loads a lot of packages; however, none of those packages overwrite the existing fonts, in the way that MnSymbol does. In this case \openbigstar takes an optional argument specifying the relative size of the inner white star relative to the outer black star, thus deining a border thickness in the process. And using scalerel package’s features, it automatically works across diferent math styles. Skip code block \documentclass{article} \usepackage{amssymb} \usepackage{stackengine} \usepackage{scalerel} \usepackage{xcolor} \usepackage{graphicx} \newcommand\openbigstar[1][ḷ.7]{% \scalerel*{% 642
\stackinset{c}{-.125pt}{c}{}{\scalebox{#1}{\color{white}{$\bigstar$}}}{% $\bigstar$}% }{\bigstar}
} \begin{document} $\bigstar\openbigstar\openbigstar[.4]\openbigstar[.9]$ $\scriptstyle\bigstar\openbigstar\openbigstar[.4]\openbigstar[.9]$ $\scriptscriptstyle\bigstar\openbigstar\openbigstar[.4]\openbigstar[.9]$ \end{document}
Tags: xetex (Prev Q), unicode-math (Prev Q) (Next Q), symbols (Prev Q) (Next Q)
PdfTeX Skip to questions, Wiki by user stefan-kottwitz pdfTeX is an extension of TeX which is capable of directly generating PDF output. Use this tag if your question is about pdf(La)TeX speciic problems, i.e. if the subject has something to do with pdfTeX but not with standard (La)TeX which produces DVI output. For standard LaTeX choose an appropriate speciic Tag. Since the majority of questions on this site deal with LaTeX, there’s no need for a LaTeX tag. However, if your question is really about LaTeX in general, you may choose the latex-project tag. The other most common TeX/LaTeX engines are xelatex and lualatex. 643
Questions Q: Frequently loaded packages: Diferences between pdfLaTeX and LuaLaTeX Tags: pdftex (Prev Q) (Next Q), packages (Prev Q) (Next Q) I’m in the process of switching my LaTeX document from pdflatex to lualatex. Similar to Frequently loaded packages: Diferences between pdfLaTeX and XeLaTeX I would like to know, what are typical packages loaded with LuaLaTeX and which typical pdfLaTeX packages should be removed or replaced? The following are the main diference I found so far: • Don’t use inputenc, but instead save your plain iles in utf-8 and add the following as the irst line: % !Mode:: "TeX:UTF-8". • Don’t use font-packages but instead load fontspec with \setmainfont{FONT_NAME}, \setsansfont{FONT_NAME}, \setmonofont{FONT_NAME}. • In order to make microtype work with fontspec, use the beta version of microtype (At least with TeX Live 2011). See more details. • hyperref should be loaded with the option unicode. What other packages do you use? What about babel and textcomp? And are there some ”killer-packages” that are only working with lualatex besides fontspec? Tags: pdftex (Prev Q) (Next Q), packages (Prev Q) (Next Q) User: apepper Answer by aphink Besides supporting a Lua interpreter, LuaTeX brings to pdfTeX quite the same changes as XeLaTeX (native Unicode support, support for system fonts).
644
For this reason, the question you linked to applies to LuaTeX as well, modulo the answers to this question about migrating from XeTeX to LuaTeX, which shows that apart from microtype support and font names, LuaTeX- and XeTeX-speciic codes are mostly compatible. babel works ine with LuaTeX as far as I can tell. At least with frenchb, I haven’t had any issues. Besides fontspec (which also works with XeTeX), there’s more and more packages that use Lua to provide features. As an example, I have recently released the impnattypo package which has some LuaTeX speciic features (thanks to Patrick), and I have more coming (such as the unreleased overcolored package). Answer by martin-schröder Most usage questions for LuaLaTeX are answered in lualatex-doc.pdf. Answer by matth Similar to the MWE in the linked XeLaTeX question, here is a MWE for LuaLaTeX. It uses the ifluatex package to allow switching between pdfLaTeX and LuaLaTeX (remember to delete all .aux iles). I used the fonts from the Microsoft ClearType fonts, because they look good on screen and printed. Skip code block % !TEX program = LuaLaTeX \documentclass[ a4paper, ngerman, final ]{scrbook} \usepackage{amsmath} \usepackage{ifluatex} \ifluatex % Lua(La)TeX 645
\usepackage[ngerman]{babel} %\usepackage{polyglossia} %\setmainlanguage[spelling=new,babelshorthands=true]{german} \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \usepackage[]{unicode-math} \unimathsetup{math-style=TeX} \setmainfont[Ligatures=TeX]{Constantia} \setsansfont{Calibri} \setmonofont{Consolas} \setmathrm{Cambria Math} \setmathfont{Cambria Math} \else %default: pdf(La)TeX \usepackage[ngerman]{babel} \usepackage{lmodern} % load vector font \usepackage[T1]{fontenc} % font encoding \usepackage[utf8]{inputenc} % input encoding \fi \usepackage[babel=true]{microtype}
%% ================== \begin{document} \chapter{Goldener Schnitt} Beim Goldenen Schnitt (lateinisch: sectio aurea) oder auch bei der Goldenen Teilun --- seltener beim Göttlichen Schnitt oder bei der Göttlichen Teilung (lateinisch: entsteht ein bestimmtes Verhältnis Ḷwischen Ḷwei Zahlen oder Ḷwei Größen. Dieses Verhältnis ist die Goldene Zahl $\Phi$ (Phi) (oder das Goldene Verhältnis o \begin{equation} \Phi=\frac{1 + \sqrt{5}}{2} \approx 1{,}618 \end{equation} Zum Beispiel stehen Ḷwei Teile einer Strecke im Verhältnis $\Phi$, wenn sich der größere Ḷum kleineren Teil verhält wie die ganḶe Strecke Ḷum größere \begin{equation} \frac{a}{b} = \frac{a+b}{a} \end{equation} 646
Streckenverhältnisse wie beim Goldenen Schnitt werden seit der griechischen Antike Sie werden als ideale Proportionen in Kunst und Architektur angewendet, kommen aber auch in der Natur vor. Das Goldene Verhältnis ist häufig bei der Bildkomposition in der Malerei Ḷu finden \begin{table}[!htb] \begin{tabular}{@{}l*{1ḷ}{p{7mm}@{}}} Some T1 characters: & \# & \$ & \% & Ă & Ň & § & @ & Æ & ß & £ \\[1.5m Some non-T1 characters: & ‡ & ÿ & ‰ & … & ¶ & ½ & ĩ & µ & | | & | | \\ \end{tabular} \end{table} Es Ḷeichnet sich durch eine Reihe besonderer mathematischer Eigenschaften aus. Umgangssprachlich wird Goldener Schnitt auch für die Goldene Zahl beḶiehungsweise \end{document} Tags: pdftex (Prev Q) (Next Q), packages (Prev Q) (Next Q)
Q: Abandon LaTeX2e for LaTeX3 or LuaTeX Tags: pdftex (Prev Q) (Next Q), latex3 (Prev Q) (Next Q) I think my question is: Should I abandon pdflatex, possibly for xetex or context, and a TeX/LaTeX based macro writing approach, possibly for a LuaTeX or LaTeX3 based approach? Possibly relevant to the answer is that I am an academic who exclusively uses the English language and a lot of math. I have been using TeX on and of for a number of years. I am happy using TeX to create all my documents (papers, presentations, letters, etc.), new macros and even simple packages (although the whole literate programming and documentation thing is beyond me). My macros tend to use both TeX and LaTeX macros. I used to create DVI iles by compiling with latex but now I use pdflatex to create pdf iles. The change from EPS to PDF igures and the loss of pstricks took some time for me to get used to, but I am now happy with the change. Recently, I gave up BibTeX for Biber and BibLaTeX and am very happy. I am willing to put in the time to learn LuaTeX/LaTeX3/ConTeX if there are advantages. 647
Tags: pdftex (Prev Q) (Next Q), latex3 (Prev Q) (Next Q) User: strongbad Answer by loop-space I’m going to expand on my comment and turn it into an answer. I take issue with the word abandon in your question. Using xelatex and latex3 does not mean that you have to abandon pdflatex and latex2e. It is entirely possible to use them alongside each other. The diferences at the document level are such that it is relatively straightforward to remember ”This is a pdflatex document” and ”This is a xelatex document”. I do my lectures with xelatex because I want to be able to use unicode-math. I tend to write my articles with pdflatex - see below - though for the fun of it I tried an article with xelatex and using unicode symbols and really quite liked the readability of the source code. So when there’s functionality that I would like to make use of, then I’m happy to use xelatex or lualatex or latex3. If I don’t need them, then at the moment I’ll probably not use them so that I keep my options open. As I see more ”here’s what you can do” on this site, then I ind myself more and more using them to make use of what I learn here. Some is a bit silly (such as my use of unicode-math) but others are more serious. The one thing that I really don’t take any notice of is the compatibility with journals or the arxiv. This is for two reasons: 1. If a journal actually accepts my article then (within reason) I’m happy to modify it to suit their bizarre style requirements (and before you ask, all journals have bizarre requirements). 2. Before a journal accepts my article then I’ll not know what bizarre requirements I’m going to have to meet so I’d rather make my life easier here and now than try to guess what I might have to do when it is accepted. The point of that second one is that I spend a lot of time writing an article. I’m often doing the maths as I actually write it because it is often only when I see it written down that I see whether or not my argument worked - when it’s in my head then I gloss over all the technicalities. So it’s not ”prove result 648
then write article” it is ”prove result while writing article”. This means that the writing stage is longer and more involved than if I worked the other way and so it is all the more important that the writing be easy and not get in the way. So being able to make use of great tools and stuf is more important than not annoying some future copy-editor. So if you see an example of something on this site and you think ”That would be just perfect for what I’m trying to do”, don’t let the fact that it uses xelatex or lualatex or latex3 put you of. Just think of it as another LaTeX package that you use for some of your documents, but not all of them. It’s no big deal. Answer by seamus If you want to publish in academic journals, you need to be sensitive to what new TeX related goodies their setup can handle. For instance, I’ve had to regress from BibLaTeX to BibTeX because a journal couldn’t handle it. Likewise, I’d expect that LuaTeX or ConTeXt might not it well into the worklow of a journal. I’m sure there are people here who know more about this sort of thing, and it probably depends on your ield. (There are journals in my area that accept submissions in Word only! Sigh) There’s also the worry that collaborators will have older TeX distributions, and so you may encounter friction when trying to work with others. My university’s computers seem to still have an old distribution which doesn’t include many packages I would otherwise use. (This doesn’t afect me since I use my laptop, but when I’m working with others, I need to go down to their level). In short, feel free to move towards the new stuf for your own documents, but be aware that journals and collaborators might be less keen on staying cutting edge. I think it is perhaps worth making a comment or two in response to the discussion in comments on this and Yiannis’ answers. There are good reasons for journals and big university-wide computing set ups to avoid the cutting edge technologies that we are fond of on this site. As Barbara Beeton mentioned, stability is key. LaTeX2e is stable. The bugs have been ironed out, 649
and packages like fixltx2e ix a few remaining oddities. Moving to a system involving components under active development (e.g. LuaTeX, BibLaTeX…) would mean frequent breakages and things like that; things that publishers can’t aford to deal with. Answer by yiannis-lazarides Although these issues were discussed earlier here are some pointers, from someone that has been using TeX/LaTeX since the middle 80s. 1. The knowledge you build with TeX/LaTeX and friends is additive. What you have used as plain TeX commands, your \defs and similar can be used today with all of the above variants. Similarly for all the LaTeX commands and yes your pstricks knowledge can still be used with pdfLaTeX. 2. The new variants such as XeLaTeX ofer advantages in some areas especially font management. If you are using special fonts and UTF8 typing it will pay you to migrate. In many cases it is as simple as adding a few lines on top of your normal LaTeX/pdfLaTeX ile. 3. LuaLaTeX is not as yet production stable and personally cannot see any reason to use it on a daily basis unless you need fancy calculations, iteration and other complicated macros. 4. LaTeX3. Portions of it are stable and can be used to-day in peaceful coexistence with LaTeX2e commands. You cannot as of to-day say I will only use LaTeX3 as it is still incomplete (it has no kernel as yet that compares to LaTeX2e or ofer any of the standard classes in the new syntax). 5. ConTeXt is a great system but for whatever reason is not as popular as the other variants. Personally I don’t use it as I still get lots of installation problems on Window machines. My general advice (especially for maths) is to stay with pdfLaTeX or XeLaTeX and you good for the next 10 years (I cannot see amsmath migrating to LaTeX3 any time soon). It is harmless though to keep your ears on the ground and try some of the new things. For example xparse from the LaTeX3 suite has a lot to ofer as well as all the sequence macros, as they can save you a lot of programming time. I personally use pdfLaTeX for my daily engineering documents and for its 650
intellectual stimulation since the late Martin Gardner’s column in Scientiic America stopped being published! Tags: pdftex (Prev Q) (Next Q), latex3 (Prev Q) (Next Q)
Q: Highlight every occurrence of a list of words? Tags: pdftex (Prev Q) (Next Q) In order to revise a draft, and identify related sections, I would like to identify similar words (by color of text, highlight, underline, or otherwise) according to topic. For example, I would like all uses of the terms ”foo” or ”bar” highlighted red and all uses of ”biz” and ”baz” highlighted green. There might be four or ive groups of words or word roots that I want to specify. This is only for revision, so it can be rather crude. For example, replace this:
with this:
(In the example, it is hard to see the green text; perhaps bold+color or underline would be more useful) Update A related question provides an answer using XeLaTex. My document does not compile with XeLaTex, I would prefer a solution compatible
651
with pdlatex if available (since that is what I use), though my document also compiles with luatex. Other related questions: • Macro: Replace all occurrences of a word (answer is not generic - requires seven lines per string to be replaced) • automatically apply special formatting to selected words in text (only provides xelatex solution) • Automatically highlight words from a predeined list (uses chickenize, replaces string but does not add color) Tags: pdftex (Prev Q) (Next Q) User: david-lebauer Answer by manuel Here’s another with l3regex. Skip code block \documentclass{scrartcl} \usepackage{xcolor,xparse,l3regex} \ExplSyntaxOn \NewDocumentCommand \texthighlight { +m } { \david_texthighlight:n { #1 } } \cs_new_protected:Npn \david_texthighlight:n #1 { \group_begin: \tl_set:Nn \l_tmpa_tl { #1 } \seq_map_inline:Nn \g_david_highlight_colors_seq { \clist_map_inline:cn { g_david_highlight_##1_clist } { \regex_replace_all:nnN { (\W)####1(\W) } { \1\c{textcolor}\cB\{##1\cE\}\cB\{####1\cE\}\2 } \l_tmpa_tl } } \tl_use:N \l_tmpa_tl \group_end: 652
} \seq_new:N \g_david_highlight_colors_seq \NewDocumentCommand \addhighlighting { O{red} m } { \seq_if_in:NnF \g_david_highlight_colors_seq { #1 } { \seq_gput_right:Nn \g_david_highlight_colors_seq { #1 } } \clist_if_exist:cF { g_david_highlight_#1_clist } { \clist_new:c { g_david_highlight_#1_clist } } \clist_gput_right:cn { g_david_highlight_#1_clist } { #2 } } \ExplSyntaxOff \addhighlighting{amet,Mauris,ut,et,leo} \addhighlighting[blue]{Phasellus,vestibulum} \begin{document} \texthighlight{Lorem ipsum dolor foo sit amet, bar consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus foo vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, bar sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, foo vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. 653
Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, bar nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.} \end{document}
Answer by aditya ConTeXt provides a proof of concept module for such translations: mtranslate. You could use it to translate text, but the translation takes place before macro expansion. So, the method will fail if the translation string is part of a macro name. The translation can be enabled and disabled using \enableinputtranstion and \disableinputtranslation. Here is an example, which a little wrapper 654
macro for ease of input. Skip code block \usemodule[translate] \define\defineautocoloring {\dodoubleargument\dodefineautocoloring} \def\dodefineautocoloring[#1][#2]% {\def\dododefineautocoloring##1% {\translateinput[##1][{\color[#1]{##1}}]}% \processcommalist[#2]\dododefineautocoloring} \defineautocoloring[red][foo, bar] \defineautocoloring[blue][color] \setuppapersiḶe[A5] \starttext \enableinputtranslation This is a foo example of coloring random bar text. What is foobar? The translation is done before macro expansion, so weird stuff can happen: \type{foobar} \disableinputtranslation This is a foo example of coloring random bar text. What is foobar? The translation is done before macro expansion, so weird stuff can happen: \type{foobar} \stoptext which gives
655
Answer by steven-b.-segletes Strongly based on my answer at How to insert a symbol to the beginning of a line for which a word appears?. However, I had to extend the logic to handle multiple color assignments. Syntax is multiple invocations of \WordsToNote{space separated list}{color} and then \NoteWords{multiple paragraph input} Macros in the input are limited to style (e.g., \textit) and size (e.g., \small) changes. Otherwise, only plain text is accepted. As detailed in the referenced answer, I adapt my titlecaps package, which normally capitalizes the irst letter of each word in its argument, with a userspeciied list of exceptions. Here, instead of capitalizing the words, I leave them intact. However, I trap the user-speciied word exceptions and use them to set a diferent color. In this extension of that method, I had to revise two titlecaps macros: \titlecap and \seek@lcwords. The method cannot handle word subsets, but it can ignore punctuation. EDITED to ix bug when lagged word appears with punctuation, and issue with irst word of paragraphs. Skip code block \documentclass{article} 656
\usepackage{titlecaps} \makeatletter \renewcommand\titlecap[2][P]{% \digest@siḶes% \if T\converttilde\def~{ }\fi% \redefine@tertius% \get@argsC{#2}% \seek@lcwords{#1}% \if P#1% \redefine@primus% \get@argsC{#2}% \protected@edef\primus@argi{\argi}% \else% \fi% \setcounter{word@count}{ḷ}% \redefine@secundus% \def\@thestring{}% \get@argsC{#2}% \if P#1\protected@edef\argi{\primus@argi}\fi% \whiledo{\value{word@count} < \narg}{% \addtocounter{word@count}{1}% \if F\csname found@word\roman{word@count}\endcsname% \notitle@word{\csname arg\roman{word@count}\endcsname}% \expandafter\protected@edef\csname% arg\roman{word@count}\endcsname{\@thestring}% \else \notitle@word{\csname arg\roman{word@count}\endcsname}% \expandafter\protected@edef\csname% arg\roman{word@count}\endcsname{\color{% \csname color\romannumeral\value{word@count}\endcsname}% \@thestring\color{black}{}}% \fi% }% \def\@thestring{}% \setcounter{word@count}{ḷ}% \whiledo{\value{word@count} < \narg}{% \addtocounter{word@count}{1}% \ifthenelse{\value{word@count} = 1}% 657
{}{\add@space}% \protected@edef\@thestring{\@thestring% \csname arg\roman{word@count}\endcsname}% }% \let~\SaveHardspace% \@thestring% \restore@siḶes% \un@define}
% SEARCH TERTIUS CONVERTED ARGUMENT FOR LOWERCASE WORDS, SET FLAG % FOR EACH WORD (T = FOUND IN LIST, F= NOT FOUND IN LIST) \renewcommand\seek@lcwords[1]{% \kill@punct% \setcounter{word@count}{ḷ}% \whiledo{\value{word@count} < \narg}{% \addtocounter{word@count}{1}% \protected@edef\current@word{% \csname arg\romannumeral\value{word@count}\endcsname}% \def\found@word{F}% \setcounter{lcword@index}{ḷ}% \expandafter\def\csname% found@word\romannumeral\value{word@count}\endcsname{F}% \whiledo{\value{lcword@index} < \value{lc@words}}{% \addtocounter{lcword@index}{1}% \protected@edef\current@lcword{% \csname lcword\romannumeral\value{lcword@index}\endcsname}% %% THE FOLLOWING THREE LINES ARE FROM DAVID CARLISLE \protected@edef\tmp{\noexpand\scantokens{\def\noexpand\tmp% {\noexpand\ifthenelse{\noexpand\equal{\current@word}{\current@lcword}}}}}% \tmp\ifhmode\unskip\fi\tmp %% {\expandafter\def\csname% found@word\romannumeral\value{word@count}\endcsname{T}% \expandafter\protected@edef\csname color\romannumeral\value{word@count}\endc \csname CoLoR\csname lcword\romannumeral\value{lcword@index}\endcsname\endc \setcounter{lcword@index}{\value{lc@words}}% }% {}% 658
}%
}% \if P#1\def\found@wordi{F}\fi% \restore@punct% } \makeatother \usepackage{xcolor} \newcommand\WordsToNote[2]{\Addlcwords{#1}\edef\assignedcolor{#2}% \assigncolor#1 \relax\relax} \def\assigncolor#1 #2\relax{% \expandafter\edef\csname CoLoR#1\endcsname{\assignedcolor}% \ifx\relax#2\else\assigncolor#2\relax\fi% } \newcommand\NoteWords[1]{\NoteWordsHelp#1\par\relax} \long\def\NoteWordsHelp#1\par#2\relax{% \titlecap[p]{#1}% \ifx\relax#2\else\par\NoteWordsHelp#2\relax\fi% } \begin{document} \WordsToNote{foo bar at}{red} \WordsToNote{Nulla dolor nulla}{cyan} \WordsToNote{amet est et}{orange} \WordsToNote{Lorem Ut ut felis}{green} \NoteWords{ \textbf{Lorem ipsum dolor foo sit amet, bar consectetuer adipiscing elit}. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. \textit{Nulla et lectus foo} vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. \scshape Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. \upshape Duis nibh mi, congue eu, accumsan eleifend, bar sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum. 659
\textsf{Lorem ipsum dolor sit amet}, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, foo vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretium quis, viverra ac, bar nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. \Large Duis eget orci sit amet orci dignissim rutrum.\normalsiḶe } \end{document}
660
Tags: pdftex (Prev Q) (Next Q)
Q: pgfplot: plotting a large dataset Tags: pdftex (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q) I try to plot a dataset which is large using pgfplots. Since I’m aware of problems with large iles, I used the external mode. I additionally increased main_memory from 3ḷḷḷḷḷḷ to 6ḷḷḷḷḷḷ. It crashes nevertheless, saying that pdflatex exceeded main memory. But if I look at the memory consumption 661
of my system during compilation, I can’t see any increase in memory usage. I couldn’t ind any explanation what main_memory takes, is it byte or Kbyte? If I increase it at a larger value, fmtutil-sys --all will fail and pdflatex won’t work anymore. Can I get around this somehow? Skip code block \documentclass{article} \usepackage{pgfplots} \usepackage{pgfplotstable} \usepgfplotslibrary{external} \tikḶexternaliḶe \begin{document} \begin{tikḶpicture} \begin{axis} \addplot table[x expr=\coordindex, y index=ḷ] {largefile}; \end{axis} \end{tikḶpicture} \end{document} I also tried to compile with lualatex (just replaced pdflatex with lualatex) but this also seems to call pdflatex? At least I got this error message (same for lualatex and pdflatex): ! Package tikḶ Error: Sorry, the system call 'pdflatex -halt-on-error -interact ion=batchmode -jobname "report-figureḷ" "\def\tikḶexternalrealjob{report}\input {report}"' did NOT result in a usable output file 'report-figureḷ' (expected on e of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'wri te 18' or something like that. Or maybe the command simply failed? Error messag es can be found in 'report-figureḷ.log'. If you continue now, I'll try to types et the picture. Excerpt from report-figureḷ.log: ! TeX capacity exceeded, sorry [main memory siḶe=6ḷḷḷḷḷḷ]. 662
\pgfplotsapplistXXpushback@smallbufoverfl ...toka l.13 ... expr=\coordindex, y index=ḷ] {largefile};
\the \t@pgfplots@tokb \the... ^^M
largefile is 5.7 Mb is size and has 593932 datapoints. I barely dare to say that I also have a ile of 163 Mb in size with 18928305 datapoints. I thought this is no problem because gnuplot can handle those iles fast without problems. head of largefile: Skip code block 94ḷ9252 17298ḷ51 21351ḷ17 24466ḷ1ḷ 26952485 29389696 31442872 33345635 35ḷ29538 3671ḷ432 Please ind the dataset here. I’m using texlive2012: $ pdflatex This is pdfTeX, Version 3.1415926-2.4-1.4ḷ.13 (TeX Live 2ḷ12) restricted \write18 enabled $ lualatex This is LuaTeX, Version beta-ḷ.7ḷ.2-2ḷ12ḷ5241ḷ (TeX Live 2ḷ12) restricted \write18 enabled. Tags: pdftex (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q) User: oliver
663
Answer by herbert you can use this simple sed one liner to reduce the data, eg for every 200th value sed -n '1~2ḷḷp' < large.data > large2ḷḷ.data then it can easily be plotted. An alternative for the irst 200 and then every 1000th: sed '1,2ḷḷ!d' < large.data > large1ḷḷḷ.data sed -n '2ḷ1~1ḷḷḷp' < large.data >> large1ḷḷḷ.data Tags: pdftex (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q)
Q: Compile all tex iles within a folder at once Tags: pdftex (Prev Q) (Next Q), compiling (Next Q) Is there a way to compile all tex iles within a speciic folder, from LINUX terminal, at once? I would like to do this using pdflatex or lualatex in a way to create a pdf ile for each distinc original tex ile. This question is not about creating individual tex iles to form a single pdf ile using \input or \include, at all. Tags: pdftex (Prev Q) (Next Q), compiling (Next Q) User: fcpenha Answer by david-carlisle You could use a loop in the shell eg cd myfolder; for i in *.tex; do pdflatex $i;done 664
Answer by andrew-swann By default latexmk compiles all tex iles in the current directory, including doing the necessary calls to biber, bibtex, etc. To run pdflatex on the iles use latexmk -pdf or for lualatex latexmk -lualatex You can set default behaviour via a coniguration ile. Answer by cmhughes I imagine there are quite a few ways to do this- David Carlisle mentioned one in his comment, here’s another: find -name "*.tex"|while read file; do pdflatex "$file";done Tags: pdftex (Prev Q) (Next Q), compiling (Next Q)
Q: How to get accented unicode characters that can be copypasted? Tags: pdftex (Prev Q) (Next Q), unicode (Prev Q) (Next Q) The aim is to generate the .pdf with accented characters (the .tex ile has mixed macro and unicode input), in a way that the .pdf text can be copypasted. An example: Skip code block
665
\documentclass{article} \usepackage[utf8x]{inputenc} \usepackage[T1]{fontenc} \usepackage{tgpagella} \begin{document} Unicode input: ā ī ū ṃ
ñ
Macro input: \=a \={\i} \=u \d{m} \.n \~n \end{document} Compiling with pdflatex, the above will visually produce the desired characters, but when you select and copy-paste them from the .pdf, you get Unicode input: a ̄ u m n ñ ̄ı ̄ . ̇ Macro input: a ̄ u m n ñ Edit: Ulrike’s answer explains what pdflatex is doing here. Tags: pdftex (Prev Q) (Next Q), unicode (Prev Q) (Next Q) User: nyiti Answer by ulrike-ischer pdlatex doesn’t use ”unicode compounds”. You are using T1-encoding and for the accented chars not available in this encoding pdlatex use various methods to build them. E.g the dot below the m is actually a small tabular with the m in the irst row and a dot in the second: \DeclareTextCommand{\d}{T1}[1] {\hmode@bgroup \o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}\egroup} In theory you can get correct glyphs with pdlatex (if your font contains them). In practice it would mean a lot work. Better use xelatex or lualatex. 666
Answer by nyiti This is the path to victory: 1. Install TeX Live 2010 which has a luatex and fontspec version that work together. Follow the instructions on tug.org. 2. On Linux, don’t forget to update the $PATH! If you already have TeX Live installed with your package manager, give the new path priority over the old one. For example, at the end of ~/.bashrc, put PATH=/usr/local/texlive/2ḷ1ḷ/bin/i386-linux:$PATH; export PATH 3. Log out and back in (or just open a new terminal) so that your $PATH updates. Save this test to test.tex somewhere, and compile with lualatex --interaction=nonstopmode test.tex Skip code block \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{TeX Gyre Pagella} \begin{document} Unicode input: ā ī ū ṃ
ñ
Macro input: \=a \={\i} \=u \d{m} \.n \~n \end{document} Open the resulting test.pdf, and when you copy-paste from it, you get Unicode input: ā ī ū ṃ ñ Macro input: ā ī ū ṃ ñ Nice!
667
Answer by martin-schröder Try adding \usepackage{cmap}. Or switch to xelatex/lualatex. Tags: pdftex (Prev Q) (Next Q), unicode (Prev Q) (Next Q)
Q: \ifpdf returns true when using LuaLaTeX Tags: pdftex (Prev Q) (Next Q), conditionals (Prev Q) (Next Q) The ifpdf package is supposed to detect if pdfTeX is running: This package looks for pdfTeX in pdf mode and implements and sets the switch \ifpdf. (from the ifpdf documentation) However, when I compile the following MWE with LuaLaTeX, my document reads This is pdfTeX. Skip code block \documentclass{article} \usepackage{ifpdf} \begin{document} \ifpdf This is pdfTeX. \else This is not pdfTeX. \fi \end{document} Is this expected and intended behavior? How do I set up a conditional that only detects pdfTeX? (The MWE works as expected for XeTeX.)
668
Tags: pdftex (Prev Q) (Next Q), conditionals (Prev Q) (Next Q) User: doncherry Answer by heiko-oberdiek LuaTeX comes from pdfTeX, it also knows the same modes for PDF and DVI and provides nearly all PDF features of pdfTeX. It knows even \pdftexversion and \pdftexrevision. Thus \ifpdf has the same semantics here. The test \ifpdf is not for testing for an engine. Even if \ifpdf is false, then you can have pdfTeX, but pdfTeX in DVI mode. Usually TeX Live and MiKTeX are also using pdfTeX for the command latex, but generating DVI with pdfTeX in DVI mode. If you want to know, if pdfTeX and not LuaTeX is running, then you can exclude luatex by \ifluatex of package ifluatex and then testing for \pdftexversion, for example: Skip code block \usepackage{ifluatex} \usepackage{ifpdf} \ifluatex \typeout{This is LuaTeX}% \else \begingroup\expandafter\expandafter\expandafter\endgroup \expandafter\ifx\csname pdftexversion\endcsname\relax \typeout{This is neither LuaTeX nor pdfTeX}% \else \typeout{This is pdfTeX in \ifpdf PDF \else DVI \fi mode}% \fi \fi Testing for package driver options and … Some TeX engines and modes can be detected at TeX macro level and the packages (or its coniguration iles) are automatically loading the right 669
drivers, e.g.: • pdfTeX and LuaTeX in PDF mode • XeTeX DVI drivers are diferent. The DVI driver program is running after the TeX run, thus there is no way of knowing the future. The default is often dvips. Therefore in many cases you won’t need complicate switch structures to differentiate between the diferent TeX compilers, just loading the package is enough: \usepackage{color} \usepackage{graphicx} \usepackage{hyperref} In case of package fontspec you need to test for the Unicode aware TeX compilers, for example: Skip code block \usepackage{ifluatex} \usepackage{ifxetex} \ifluatex \usepackage{fontspec} % other LuaTeX setup \else \ifxetex \usepackage{fontspec} % other XeTeX setup \else \usepackage[T1]{fontenc} \usepackage{textcomp} \usepackage{lmodern} % other font setup \fi \fi Answer by herbert use the package ifluatex instead with \ifluatex ... \else ... \fi 670
Tags: pdftex (Prev Q) (Next Q), conditionals (Prev Q) (Next Q)
Q: hyperref: Wrong DVI mode driver option ‘dvips’,(hyperref) because pdfTeX or LuaTeX is running in PDF mode. \ProcessKeyvalOptions{Hyp} Tags: pdftex (Prev Q) (Next Q), hyperref (Next Q) hyperref: Wrong DVI mode driver option `dvips',(hyperref) because pdfTeX or LuaTeX is running in PDF mode. \ProcessKeyvalOptions{Hyp} How can i ix this error? I m trying to compile a template of MMA journal. It is under this link MMA Template Tags: pdftex (Prev Q) (Next Q), hyperref (Next Q) User: andii Answer by heiko-oberdiek Class mma.cls is intended to be used with latex+dvips and contains several driver option settings: \usepackage[dvips,a4paper,colorlinks,breaklinks,unicode]{hyperref}%backref, \usepackage[dvips]{color} If you want to use pdflatex, then remove options dvips. Tags: pdftex (Prev Q) (Next Q), hyperref (Next Q)
671
Q: What possibilities are there of using OpenType fonts and margin kerning? Tags: pdftex (Prev Q) (Next Q), protrusion (Prev Q) (Next Q) I really like the protrusion and margin kerning features of pdfTeX and LuaTeX. I also like to use other fonts than those available for TeX. What choices do I have when I want to use both? Also, what problems with typography should I expect? Tags: pdftex (Prev Q) (Next Q), protrusion (Prev Q) (Next Q) User: roman-plášil Answer by khaled-hosny This is for lualatex: Skip code block \documentclass{article} \usepackage{fontspec} \setmainfont[RawFeature={protrusion=default}]{TeX Gyre Pagella} \pdfprotrudechars2 % 1 if you don't want to change line breaking \begin{document} \input{knuth} \end{document} Tags: pdftex (Prev Q) (Next Q), protrusion (Prev Q) (Next Q)
Q: Selectively disable dash ligatures in LuaLaTeX Tags: pdftex (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) 672
With pdfLaTeX, I can print two hyphens using -{}-. This does not seem to work in LuaLaTeX. Indeed, the following snippet \documentclass{minimal} \begin{document} en dash -- two dashes -{}\end{document} prints en dash — two dashes -when compiled with pdflatex, but en dash — two dashes — when compiled with lualatex. How do I print -- in LuaLaTeX without disabling ligatures completely? Tags: pdftex (Prev Q) (Next Q), ligatures (Prev Q) (Next Q) User: clément Answer by egreg I suppose you don’t want to introduce break points at the double hyphen. Here’s a way. Skip code block \documentclass{article} %\usepackage{fontspec} % works also with fontspec \newcommand{\texthyphen}{} % ensure \texthyphen is not defined \protected\def\texthyphen{\mbox{-}} \begin{document} en dash -- two dashes \texthyphen\texthyphen \textit{en dash -- two dashes \texthyphen\texthyphen} 673
\textbf{en dash -- two dashes \texthyphen\texthyphen} \strut \vrule-\vrule\ \textit{\vrule-\vrule} \textbf{\vrule-\vrule} \end{document} The \protected is just to avoid the command being expanded when in moving arguments, but it’s not really necessary. I add a graphic analysis of the hyphen’s placement with respect to its bounding box.
Answer by mico Indeed, the method of breaking up ligatures by inserting an empty TeX group, {}, does not work in LuaTeX and LuaLaTeX. To prevent the creation of an en-dash, then, you could insert a ”zero-width kern”, i.e., -\kernḷptor an explicit ”italic correction”, i.e., -\/With either method, LuaTeX will not insert a line break between the two dashes. If you have many instances of such double-dashes, you may want to create a dedicated macro called, say, \dbldash, to streamline your typesetting: 674
\newcommand{\dbldash}{-\kernḷpt-} Here’s an illustration of the result of using \dbldash:
\documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{Latin Modern Roman} \newcommand\dbldash{-\kernḷpt-\ } \begin{document} dash - endash -- double-dash \dbldash \end{document} Aside: At least if the Computer Modern (and Latin Modern) font family is in use, employing either the -\kernḷpt- or the -\/- method while in italics mode will result in slightly more whitespace being inserted between the two dashes; this amount is the same irrespective of which of the two methods is in use. The cause of this increased space between the dashes would appear to be the fact that the ”side-bearing” (the glyph-associated white-space) in front of (but not the one behind) the dash-character is slightly more generous in the italic font shape than they are in the upright font shape. Addendum: @egreg’s parallel answer shows explicitly that there’s a nonzero side-bearing in front of but not behind the dash character when it occurs in italic mode, at least for the Computer Modern font family. In contrast, there’s a somewhat smaller non-zero side-bearing after, but not before, the dash character in the plain-upright and bold-upright font shapes. These diferences in side-bearings cause the diferences in whitespace between the plain-upright and italic font shapes. Tags: pdftex (Prev Q) (Next Q), ligatures (Prev Q) (Next Q)
Q: Problems with mixing Icelandic and German with LuaLaTex Tags: pdftex (Prev Q) (Next Q), babel (Prev Q) (Next Q) 675
So what I am trying to do is to use the letter-classic class with LuaLaTeX (This is LuaTeX, Version beta-ḷ.8ḷ.ḷ (MiKTeX 2.9) (rev 5238) (format=lualatex 2ḷ15.11.1ḷ) 25 NOV 2ḷ15 ḷ9:3ḷ) as included in MikTeX. It bombs in icelandic.ldf with errors like these: Skip code block ! String contains an invalid utf-8 sequence. l.144 \DeclareTextCommand{\ooob}{T1}{\sob { ó}{.85}{ḷ}{.ḷ4}{ḷ}} A funny symbol that I can't read has just been (re)read. Just continue, I'll change it to ḷxFFFD. ! String contains an invalid utf-8 sequence. l.145 \DeclareTextCommand{\OOob}{T1}{\sob { Ó}{.7}{ḷ}{ḷ}{ḷ}} A funny symbol that I can't read has just been (re)read. Just continue, I'll change it to ḷxFFFD. ! String contains an invalid utf-8 sequence. l.148 \DeclareTextCommand{\eeob}{T1}{\sob { é}{1}{ḷ}{.ḷ4}{ḷ}} A funny symbol that I can't read has just been (re)read. Just continue, I'll change it to ḷxFFFD. ! String contains an invalid utf-8 sequence. l.149 \DeclareTextCommand{\EEob}{T1}{\sob { É}{1}{ḷ}{.ḷ4}{ḷ}} A funny symbol that I can't read has just been (re)read. Just continue, I'll change it to ḷxFFFD. ! String contains an invalid utf-8 sequence. l.152 \declare@shorthand{icelandic}{" ó}{\ooob} A funny symbol that I can't read has just been (re)read. Just continue, I'll change it to ḷxFFFD.
676
! String contains an invalid utf-8 sequence. icelandic@sh@\string "@\string � \ooob @ l.153 \declare@shorthand {icelandic}{"Ó}{\OOob} A funny symbol that I can't read has just been (re)read. Just continue, I'll change it to ḷxFFFD. My minimal working example is this one: Skip code block
\documentclass[english,12pt,a4paper]{letter-classic} \usepackage[T1]{fontenc} \usepackage[icelandic,german,english]{babel} \selectlanguage{english} \newcommand{\ISL}[1]{\foreignlanguage{icelandic}{#1}} \newcommand{\DEU}[1]{\foreignlanguage{german}{#1}} %%\usepackage[utf8]{inputenc} % needed with pdfLaTeX, but not with LuaLaTeX (see c \begin{document} \begin{letter}{Troll family\\\ISL{Elliðaḹrdalur}\\\ISL{999 Reykjavík}\\ICELAND} \fromname{\DEU{Mäxchen Mustermann}} \fromstreet{\DEU{Musterstraße 123}} \fromtown{12345 Musterstadt} \fromphone{+49 123 456789ḷ} \fromtownshort{Musterstadt} \fromsignature{\DEU{Mäxchen}} \subject{\ISL{Jólasveinar}} \opening{Folks,}
do you know the current address of the \ISL{Jólasveinar} and/or their parents \ISL \closing{\ISL{Með kveðju,}} \end{letter} \end{document} 677
The actual document worked without problems until a few months ago, using pdfLaTeX (and still does, see below).
How it looks
.
Can anyone explain to me how to mix Icelandic and German using LuaLaTeX with the letter-classic class? I looked into the KOMA letter class already, but I prefer a slightly more modern/custom look for the letter head, such that at this moment I really want to avoid that one. Tags: pdftex (Prev Q) (Next Q), babel (Prev Q) (Next Q) User: 0xc0000022l Answer by egreg The problem is not in mixing Icelandic and German. A smaller example shows the issue in all document classes. 678
\documentclass{article} \usepackage[icelandic]{babel} \begin{document} Test \end{document} Running this through LuaLaTeX produces the same error you see (and similar ones later on): ! String contains an invalid utf-8 sequence. l.144 \DeclareTextCommand{\ooob}{T1}{\sob { ?}{.85}{ḷ}{.ḷ4}{ḷ}} ? Unfortunately, the ile icelandic.ldf loaded by babel hardcodes four Latin1 characters to be used for shorthands in "Ó "ó "É "é and, when LuaTeX is reading the ile, it chokes on that invalid input. XeTeX is more forgiving in this respect and doesn’t choke. As it stands, babel-icelandic is not compatible with LuaLaTeX and there’s no workaround, as far as I can see, except writing a modiied icelandic.ldf ile. Lines 142 to 157 should be Skip code block 142 143 144 145 146 147 148 149 15ḷ
\DeclareTextCommand{\oob}{T1}{\sob {o}{.85}{ḷ}{.ḷ4}{ḷ}} \DeclareTextCommand{\Oob}{T1}{\sob {O}{.7}{ḷ}{ḷ}{ḷ}} \DeclareTextCommand{\ooob}{T1}{\sob {^^f3}{.85}{ḷ}{.ḷ4}{ḷ}} \DeclareTextCommand{\OOob}{T1}{\sob {^^d3}{.7}{ḷ}{ḷ}{ḷ}} \DeclareTextCommand{\eob}{T1}{\sob {e}{1}{ḷ}{.ḷ4}{ḷ}} \DeclareTextCommand{\Eob}{T1}{\sob {E}{1}{ḷ}{.ḷ4}{ḷ}} \DeclareTextCommand{\eeob}{T1}{\sob {^^e9}{1}{ḷ}{.ḷ4}{ḷ}} \DeclareTextCommand{\EEob}{T1}{\sob {^^c9}{1}{ḷ}{.ḷ4}{ḷ}} \declare@shorthand{icelandic}{"o}{\oob} 679
151 152 153 154 155 156 157
\declare@shorthand{icelandic}{"O}{\Oob} \declare@shorthand{icelandic}{"^^f3}{\ooob} \declare@shorthand{icelandic}{"^^d3}{\OOob} \declare@shorthand{icelandic}{"e}{\eob} \declare@shorthand{icelandic}{"E}{\Eob} \declare@shorthand{icelandic}{"^^e9}{\eeob} \declare@shorthand{icelandic}{"^^c9}{\EEob}
Changes are in the lines where ^^ appears; I added the line numbers for convenience. A bug report should be iled to the maintainer of babel. Answer by ulrike-ischer As a work-around you could switch locally to ansinew reading with luainputenc: (edited a bit to reset the catcodes afterwards and also removed the write call back so that the toc now contains again real utf8). Skip code block \documentclass{article} \usepackage{fontspec} \usepackage{luatexbase} %not needed now, but probably in the future. \PushCatcodeTableNumStack \usepackage[ansinew]{luainputenc} \usepackage[icelandic]{babel} \PopCatcodeTableNumStack
\directlua{luatexbase.remove_from_callback('process_input_buffer', 'luainputenc.fa luatexbase.remove_from_callback('process_output_buffer','luainputenc.fa luainputenc.state = stopped} \begin{document} \tableofcontents \section{öäüß} äöüß € ólasveinar Grýla Leppalúði \end{document} 680
But it is quite possible that some other things in icelandic.ldf are not suitable to luatex and then you will have to adapt more.
Answer by andrew-swann Why not use polyglossia? I don’t have letter-classic, but here is similar version in letter:
Skip code block 681
\documentclass{letter} \usepackage[T1]{fontenc} \usepackage{polyglossia} \setdefaultlanguage{english} \setotherlanguages{icelandic,german} \newcommand{\ISL}[1]{\texticelandic{#1}} \newcommand{\DEU}[1]{\textgerman{#1}} \begin{document} \begin{letter}{Troll family\\\ISL{Elliðaḹrdalur}\\\ISL{999 Reykjavík}\\ICELAND} \name{\DEU{Mäxchen Mustermann}} \address{\DEU{Musterstraße 123}\\ 12345 Musterstadt} \telephone{+49 123 456789ḷ} \signature{\DEU{Mäxchen}} \opening{Folks,} \begin{center} \ISL{Jólasveinar} \end{center}
Do you know the current address of the \ISL{Jólasveinar} and/or their parents \ISL \closing{\ISL{Með kveðju,}} \end{letter} \end{document} Tags: pdftex (Prev Q) (Next Q), babel (Prev Q) (Next Q)
682
Q: Using \input|texlua... to emulate \directlua in pdfTeX Tags: pdftex (Prev Q) (Next Q), shell-escape (Next Q) When --shell-escape is enabled, pdfTeX allows to run external programs and input the result expandably with \input|"...". Together with the Lua interpreter texlua, this could be used to provide a dumbed down version of \directlua. However, texlua expects a ile name as its argument. In my setup (Ubuntu 10.04, with up-to-date TeXLive 2012 install), one can run pdftex --shell-escape on
\everyeof{\noexpand} \message{\input|"echo print\string\(3.4+5.7\string\) > tmp.lua ; texlua tmp.lua" a \bye to get \message{9.1}. Note that the \everyeof{\noexpand} is in part for convenience, it would be possible to make the construction work (not entirely robustly) without this non-expandable step. This approach is not portable because it relies on echo, which probably doesn’t exist in Windows environments. One way around this would be to have a simple Lua script taking the code print\string\(3.4+5.7\string\) as its argument (see a recent question on texlua arguments), then somehow performing it. Is this possible? Otherwise, we need an os-dependent approach. A second problem is that special characters such as parentheses need escaping. Which ones? In particular, I’m worried about quotes ", which are used to enclose the argument of \input|. Given a list of which escapings to perform, I have some code up my sleeve to do that expandably (see the l3kernel-extras package on the LaTeX3 svn repository). Basically, my question boils down to: ”How can I invoke texlua from pdfTeX with arbitrary Lua code as portably as possible?” Tags: pdftex (Prev Q) (Next Q), shell-escape (Next Q) User: bruno-le-loch Answer by joseph-wright 683
The echo built-in is available on both Unix and Windows, and so provided platform detection is available then the problem is in principal one of deciding which characters to escape. For LaTeX, platform detection can be done using the ifplatform package, which provides the \ifwindows switch. The irst character to worry about is the ’chain process’ one. On Windows, this is &, whereas on Unix ; is correct. That be handles with something like \RequirePackage{ifplatform} \edef\luachainprocess{\ifwindows\string&\else;\fi } There is then the question of special characters in the echo part. For Windows, the required substitutions are • • • • •
> < | & ^
replaced replaced replaced replaced replaced
by by by by by
^> ^< ^| ^& ^^
with everything else left alone by echo. On Unix, the appropriate list seems to be • • • • • • • •
> < ( ) & | ` \
replaced replaced replaced replaced replaced replaced replaced replaced
by by by by by by by by
\> \< \( \) \& \| \` \\
(Note: that is with the bash shell, but others may vary.) As Windows allows for example ^( for (, it would probably be easiest to use a common set of characters for replacement with only the escape character itself varying. (The same is true for Unix with for example \^.) One thing that is not clear at all is if there is any way to deal with " in either case, as the pipe syntax for \input does not provide an escape for this, so it seems to be misunderstood whatever you do. This is particularly frustrating for the Unix case as generating efectively 684
echo "" would avoid needing to escape anything other than " inside the code. Answer by bruno-le-loch I found out about the loadstring function in Lua, which converts a string to Lua code. To avoid any escaping issue for the TeX → Lua conversion, the TeX code converts the argument of \texlua to a space-separated list of character codes, which is then given as extra arguments to texlua. The Lua code decodes this using to str.char. The remaining weak link is that \input|..., just like any other \input or \scantokens, inserts an end-of-ile marker, which may not appear in the argument of any command. We need to get rid of it, and one way is to add some material just before, and just after, the end of the ile, here \romannumeral\numexprḷ\noexpand and \relax (the \noexpand is key). Unfortunately, the code \romannumeral\numexprḷ\noexpand is not inserted if there is a Lua error; in this case, the end-of-ile marker is not removed, and all hell breaks loose. Skip code block \begingroup \catcode `@ = 11 % % Get \texlua@input = primitive \input \expandafter\ifx\csname @@input\endcsname\relax \global\let\texlua@input\input \else \global\let\texlua@input\@@input \fi % % Write very simple Lua file. \newwrite \texlua@write \xdef \texlua@file {\jobname.texlua} \immediate \openout \texlua@write \texlua@file \relax \immediate \write \texlua@write {% 685
assert(loadstring(string.char(unpack(arg))))()% \detokeniḶe{print("\\romannumeral\\numexprḷ\\noexpand")}%
} \immediate \closeout \texlua@write % % DetokeniḶe the argument and convert spaces to category other. \gdef\texlua@str#1% {% \expandafter\texlua@str@i \detokeniḶe{#1}\\ \\\texlua@str@ii/ \relax } \lccode `* = 32 \lowercase{\gdef\texlua@str@i#1 #2\\#3 {#3\texlua@str@i#1*#2\\{#3} }} \gdef\texlua@str@ii/#1#2\\#3\relax{#2} % % Convert each character to its character code, space-separated. % This is not "f-expandable", it is "restricted expandable" in % expl3 terms. \gdef\texlua@num#1% {\expandafter\texlua@num@i\romannumeral-`q\texlua@str{#1}\relax} \gdef\texlua@num@i#1% {% \ifx #1\relax \else \number `#1 \space \expandafter\texlua@num@i \fi } % % Calling `\input|`. \gdef\texlua#1% {% \texlua@input|"texlua \texlua@file \space \texlua@num{#1}"% \relax } \endgroup \message{a\texlua{io.write(3+4)}b} 686
Answer by aditya In ilter module in ConTeXt provides the necessary boilerplate to run the content of an environment or macro through an external command (full disclosure, I am the author of the module). It does not use \input| to read the output, rather assumes that the external program will write the ile to an external ile and then the user can specify how to read the ile (the default is \ReadFile, which is similar to \input). The example below illustrates how to process using texlua. Skip code block % engine=pdftex \usemodule[filter] \defineexternalfilter [luatex] [filtercommand={texlua \externalfilterinputfile > \externalfilteroutputfile}] \starttext \inlineluatex{print((3+5)*3)} \startluatex local t = {1,2,3} print("Number of entries " .. #t) \stopluatex \stoptext Note: The \inlineluatex macro is not expandable. Tags: pdftex (Prev Q) (Next Q), shell-escape (Next Q)
687
Q: Hyphenation does not work with acro and luatex, but with pdftex Tags: pdftex (Prev Q) (Next Q), hyphenation (Prev Q) (Next Q) I’m using luatex 0.70.1 together with acro 1.2 and I have the following MWE. Skip code block \documentclass{minimal} \usepackage[ngerman]{babel} \usepackage{acro} \DeclareAcronym{DNA}{ short=DNA, long=Desoxyribonukleinsäure }
\begin{document} Das ist ein sehr langer SatḶ und er wird an seinem Ende leider nicht richtig umgeb
Das ist ein sehr langer SatḶ und er wird an seinem Ende leider nicht richtig umgeb \end{document} Document looks normal with pdftex (both lines wrapped after dash), but when using luatex the 2nd line continues into the margin. I would have posted images, but due to the fact that this is my irst post the systems doesn’t allow it. Tags: pdftex (Prev Q) (Next Q), hyphenation (Prev Q) (Next Q) User: quincy Answer by egreg This has to do with the diferent hyphenation algorithm used by LuaTeX. I don’t really know the details, but here’s what’s shown when I put DNA-SequenḶierung and \acs{DNA}-SequenḶierung in a box and make LuaTeX show it.
688
\sbox0{DNA-Sequenzierung} Skip code block \hbox(6.8872+1.94397)x88.4784, direction TLT .\T1/cmr/m/n/1ḷ D .\T1/cmr/m/n/1ḷ N .\T1/cmr/m/n/1ḷ A .\T1/cmr/m/n/1ḷ .\discretionary .\T1/cmr/m/n/1ḷ S .\T1/cmr/m/n/1ḷ e .\T1/cmr/m/n/1ḷ q .\T1/cmr/m/n/1ḷ u .\T1/cmr/m/n/1ḷ e .\T1/cmr/m/n/1ḷ n .\T1/cmr/m/n/1ḷ Ḷ .\T1/cmr/m/n/1ḷ i .\T1/cmr/m/n/1ḷ e .\T1/cmr/m/n/1ḷ r .\T1/cmr/m/n/1ḷ u .\T1/cmr/m/n/1ḷ n .\T1/cmr/m/n/1ḷ g \sbox0{\acs{DNA}-Sequenzierung} Skip code block \hbox(6.8872+1.94397)x88.4784, direction TLT .\hbox(6.8872+ḷ.ḷ)x22.63336, direction TLT ..\hbox(6.8872+ḷ.ḷ)x22.63336, direction TLT ..\hbox(6.8872+ḷ.ḷ)xḷ.ḷ, glue set - 22.63336fil, direction TLT ...\glue ḷ.ḷ plus 1.ḷfil minus 1.ḷfil ...\T1/cmr/m/n/1ḷ D ...\T1/cmr/m/n/1ḷ N ...\T1/cmr/m/n/1ḷ A .\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ S .\T1/cmr/m/n/1ḷ e 689
.\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ .\T1/cmr/m/n/1ḷ
q u e n Ḷ i e r u n g
In the irst case LuaTeX puts a \discretionary item after the hyphen, while it doesn’t in the second case, probably because it thinks that the hyphen is at the start of a word (it comes after a box which is not part of the word). This does not happen with pdfLaTeX, because the \discretionary item is inserted at a later stage. It’s probably better, in any case, using the babel shortcuts: Das ist ein sehr langer SatḶ und er wird an seinem Ende leider nicht richtig umgebrochen: DNA"=SequenḶierung Das ist ein sehr langer SatḶ und er wird an seinem Ende leider nicht richtig umgebrochen: \acs{DNA}"=SequenḶierung which gives
Tags: pdftex (Prev Q) (Next Q), hyphenation (Prev Q) (Next Q)
690
Q: Does the lualatex shell enable behavior difer from pdlatex on purpose? Tags: pdftex (Prev Q) (Next Q), shell-escape (Prev Q) (Next Q) I am trying to use TikzEdt, an editor for TikZ graphics. For some tasks TikZ needs to call other commands so I tried to enable this by the parameter --shell-escape passed to lualatex (on Windows, MiKTeX 2.9). Strangely this fails to enable the feature. After some iddling around it turns out that it even fails with this MWE: \documentclass{standalone} \begin{document} \write18{echo SHELL ENABLED} \end{document} TikzEdt appends the switch and calls lualatex test.tex --shell-escape which does not seem to work. The same command with pdlatex works nicely. It turns out that other than in pdlatex the order of arguments seem to play a role in lualatex, lualatex --shell-escape test.tex runs nicely. Unfortunately TikzEdt only allows to append switches not insert switches. Is this a bug in lualatex or is TikzEdt using a wrong assumption? Tags: pdftex (Prev Q) (Next Q), shell-escape (Prev Q) (Next Q) User: alexander Answer by egreg Let’s try a simple document test.tex; the package pdftexcmds is loaded in order to have \pdf@shellescape available with all engines. Skip code block \documentclass{article} \usepackage{pdftexcmds} \makeatletter \count@=\pdf@shellescape \showthe\count@ 691
\makeatother \begin{document} Ciao \end{document} Here’s what happens with • • • • • •
pdflatex test pdflatex test --shell-escape lualatex test lualatex test --shell-escape xelatex test xelatex test --shell-escape
The execution stops because of \showthe, showing > 2. l.5 \showthe\count@ in all six invocations (TeX Live 2012 on Mac OS X, but I don’t think it’s diferent with other platforms). If we put --shell-escape at its proper place, the execution of any of • pdflatex --shell-escape test • lualatex --shell-escape test • xelatex --shell-escape test stops showing > 1. l.5 \showthe\count@ This means that the setting of --shell-escape can be done only in ”inix notation” and that the option has no efect if postixed. As kindly as usual, Paulo Cereda conirms that, on MiKTeX, options can be speciied after the ile name for pdftex and xetex, but not for luatex. As the most common syntax format on other systems is with ”inix” options, my opinion is that TikZEdt is wrong in its assumptions.
692
Answer by herbert the syntax of luatex (lualatex) is Usage: luatex --lua=FILE [OPTION]... [TEXNAME[.tex]] [COMMANDS] or: luatex --lua=FILE [OPTION]... \FIRST-LINE or: luatex --lua=FILE [OPTION]... &FMT ARGS --shell-escape is an option the reason why it must be before the TEXNAME[.tex] Tags: pdftex (Prev Q) (Next Q), shell-escape (Prev Q) (Next Q)
Q: How to increase bufsize for lualatex or pdlatex? Tags: pdftex (Prev Q) (Next Q) I work with large TikZ graphics for which the default bufsize of lualatex/pdlatex is too small: Unable to read an entire line---bufsiḶe=2ḷḷḷḷḷ. Please increase buf_siḶe in texmf.cnf. Is there a quick way to increase the bufer size for either lualatex or pdlatex without editing texmf.cnf? If there is no quick solution, could someone please describe the obscure coniguration mechanism of LaTeX that needs to be executed to process changes made to texmf.cf? Also, where is texmf.cnf in a standard installation of a Ubuntu texlive package? What happens to my changes to texmf.cf when I update the texlive package? Tags: pdftex (Prev Q) (Next Q) User: bernhard-anderson
693
Answer by martin-schröder To ind the texmf.cnf of your installation, use kpsewhich: kpsewhich texmf.cnf In a normal installation of texlive this will point you to a ile that will probably tell you not to edit any other texmf.cnf. You could try to increase the buf_siḶe for one run by setting it on the cmdline: buf_siḶe=1ḷḷḷḷḷ pdflatex foo.tex This may work, but you may also have to change texmf.cnf and recreate the formats. See also Memory settings with MacTeX - Which texmf.cnf to modify Tags: pdftex (Prev Q) (Next Q)
Q: char to integer cast in latex Tags: pdftex (Prev Q) (Next Q) I am wondering what an integer in LaTeX is. I take this from pdfTeX release notes (2005-08-01) • \pdfelapsedtime is a read-only integer that (initially) returns the amount of time passed since the start of this run. This amount is given in ‘scaled seconds’: the value 65536 counts as one second. If more time has passed than 32767 seconds, (2^31)-1 will be returned. • \pdfresettimer updates the internal timer, such that subsequent calls to \pdfelapsedtime will restart from 0. so I guess the return value from \pdfelapsedtime is an integer. I have to use \the\pdfelapsedtime to cast it to string value (please correct my words to
694
the LaTeX conventions, I hope everybody knows what I mean). To further elucidate my problem, please look at the following MWE: \documentclass{minimal} \newcount\benchmarkcount \begin{document} \pdfelapsedtime \benchmarkcount \end{document} The irst error is ! You can't use '\pdfelapsedtime' in vertical mode. while the second one gives ! Missing number, treated as Ḷero. So an integer is not the same as a counter either. Is there anything -- let me call it \foo -- that casts a string to become an integer, e.g. \foo\the\pdfelapsedtime. Or, that would solve my problem as well, is there an analog to \directlua{tex.print(...)} that gives an integer back? background: I am working on the answer to this question and try to make the lualatex \pdfelapsedtime macro as identical to the pdlatex one as possible. Tags: pdftex (Prev Q) (Next Q) User: andy Answer by joseph-wright The diference here is that \pdfelapsedtime is read only integer, while \benchmarkcount is a read-write register. In both cases, the contents are ’internal integers’, and therefore you need \the or \number to insert the values into the input stream. However, TeX will allow you to assign to \benchmarkcount \benchmarkcount so when you use it as you have done, TeX goes looking for a number and fails to ind one. On the other hand, you cannot assign \pdfelapsedtime. 695
That means that you simply can’t use it as you have, and so TeX complains. Thus while the diference can be explained, the only way you can get the same error is to create a new \pdfelapsedtime which is a TeX count. The problem there is that the value is dynamic, and so the usual copy-and-rename approaches will fail. Tags: pdftex (Prev Q) (Next Q)
Q: warning (pdf backend): pop empty color page stack 0 Tags: pdftex (Prev Q), tcolorbox (Next Q), color (Next Q) I’ve been receiving this warning and for the past several hours (erh, something like 12 hours now). I’ve been trying to narrow down what’s been causing it, but to no avail. I managed to cut down the project to ~1000 lines of code and still produce the warning, but I’ve tried cutting out tens of diferent things from that ~1000 lines, and so far, whatever I try to cut beyond that makes the warning go away, making it incredibly diicult to debug. There’s also of course no line the warning points to and no visual indication in the document that something is wrong to point me in the right direction. Here is a link to the actual project that produces the warning. So far I’ve managed to deduce that \includeonly{basics,apd} reproduces the error, but if you remove either basics or apd here, the warning goes away. Furthermore, while I haven’t tested ever two-chapter combination, it is the only two-chapter combination I have found that will reproduce the warning (and no chapter by itself will reproduce it). I am also able to remove ~half the lines from either of these iles to still retain the warning, but, besides the actual amount of code I’m removing, I don’t see any pattern in the code that does and does not reproduce the warning. I’ve also been able to remove the title page, table of contents, references, and index, and still retain the warning. I apologize for not being able to give any sort of MWE, but I really wasn’t able to get it down much more than \includeonly{basics,apd} even after 696
hours and hours of experimenting. Hopefully at least someone has an idea as to what this error even means so that I have a better chance of debugging it? (FWIW, the pdf backend I’ve been using is LuaLaTeX, though I’ve conirmed that pdfLaTeX produces the warning just the same (from the TeX Live 2016 distro). Perhaps it’s also worth noting that Texmaker (my current IDE) does not report this warning and I have to go into the log ile to ind it.) Tags: pdftex (Prev Q), tcolorbox (Next Q), color (Next Q) User: jonathan-gleason Answer by david-carlisle Well what it means is that’s you’ve corrupted the colour stack. Unlike font changes colour is not an intrinsic attribute of a tex box, so colour changes are managed by nodes marking the change of state whatsit, Originally it was very hard to maintain colour correctly over page breaks, as the macro package needed to normalise colour in the page headings and could not reset the current colour for the text at the start of a page as the page breaking routine can not easily insert a special there. dvips introduced the notion of a colour stack where the driver maintains a stack of colours that are handled correctly at a page break, and the macro layer just needs to push and pop colours on to this stack rather than trying to set the ”correct” colour at points over which it has little control. pdftex (and luatex) extend this model further and have speciic push/pop commands more or less: \pdfcolorstack push {red} ... \pdfcolorstack pop so you get the error if you have a \colorstack pop without a matching push, or in latex macro wrappers, if you have a \reset@color without a \set@color
697
I guess this ixes it, modify \tcbtitle after loading tcolorbox in your structure ile:
\usepackage{tcolorbox} % Required for creating the theorem, definition, exercise a \makeatletter \renewcommand\tcbtitle{\ifx\tcbtitletext\@empty\else% {\leavevmode\color{tcbcol@title}\kvtcb@fonttitle \kvtcb@haligntitle\kvtcb@before@title \tcbtitletext\kvtcb@after@title}\fi} \makeatother or perhaps better \makeatletter \renewcommand\tcbtitle{\ifx\tcbtitletext\@empty\else% {\kvtcb@fonttitle\kvtcb@haligntitle\kvtcb@before@title \leavevmode\color{tcbcol@title}\tcbtitletext\kvtcb@after@title}\fi} \makeatother so you delay the color until after \kvtcb@before@title Answer by heiko-oberdiek The warning ”pop empty color stack” is usually caused by color stack commands out of order. A typical scenario is the use of low level box set command \setbox instead of LaTeX box set macros (\sbox, environment lrbox, ...). When LaTeX sets a color, then the color reset command is issued after the current group. Therefore LaTeX box macros add a group layer around the contents of the box. Without this additional group, the color reset (pop operation of the color stack) leaks out of the box and is executed at the wrong time: \documentclass{article} \usepackage{color} \begin{document} \setboxḷ=\hbox{\color{red}Red} \null \end{document} 698
At the begin of the box the color red is put on the stack. Then the box is closed and the pop operation leaks out of the box and is executed at the time of the box deinition, before the box is used. Push and pop are out of order (in the example the box is not used, only the pop special). Solution: A group keeps the pop special inside: \setboxḷ{\begingroup\color{red}Red\endgroup} because it is inserted after \endgroup before the box closes. LaTeX’s \sbox does this automatically: \sboxḷ{\color{red}Red} Tags: pdftex (Prev Q), tcolorbox (Next Q), color (Next Q)
Unicode Math Questions Q: What is the right way to input prime with Unicode-math (LuaTeX backend) Tags: unicode-math (Prev Q) (Next Q) I opened an issue about this in Unicode-math’s github repository. However, I am not so sure it is actually a bug, or I just did something wrong. Here is a minimal example, Skip code block \documentclass{article} \usepackage{unicode-math} \setmathfont[version=Asana]
{Asana Math} 699
\setmathfont[version=Cambria] {Cambria Math} \setmathfont[version=LatinModern]{Latin Modern Math} \setmathfont[version=Minion] {Minion Math} \setmathfont[version=XITS] {XITS Math} \def\testprime{f'x'f''''x''''\quad f\prime x\prime f\qprime x\qprime} \setlength{\parindent}{ḷpt} \begin{document} \fontsiḶe{36}{36}\selectfont Asana \mathversion{Asana} Cambria \mathversion{Cambria} LatinModern \mathversion{LatinModern} Minion \mathversion{Minion} XITS \mathversion{XITS} \end{document}
700
\[ \[ \[ \[ \[
\testprime \testprime \testprime \testprime \testprime
\] \] \] \] \]
It seems that the ASCII input was transformed into supscripts while \prime etc are not. 701
With Asana Math the ASCII version looks ine while the \prime version looks horrible. It looks like in Asana Math primes are designed as normal glyph, they need to be raised to supscripts to works well. With Latin Modern Math, it looks horrible for both case. I think it is a font problem for LM case. For other three fonts, the \prime looks good while using ASCII input they looks terrible. In these fonts, the primes seems to be designed as a supscripts glyph, and raising them even more does not looks good. Is there anyway to modify the behavior of the ASCII input? In addition, with Latin Modern Math, neither '''' or \qprime works, they all produce nothing. I thought '''' was supposed to use negative kern to fake the \qprime when it is not available. Update: Thanks for both @KhaledHosny and @LeoLiu’s answers. Now it seems to be more complicated. Using the old TeX way to typeset primes get the position right when both prime and subscripts are presented. However, to conform the Unicode standard, I think the fonts should design the primes as superscript glyphs, which means they will look really bad when raised in superscript position. Right now my temporary solution is to use \prime etc. and add a negative kern between primes and subscripts. Update Thanks for @LeoLiu’s answer, which worked ine for me before. Here is just an update for newer versions of unicode-math. The main change is that the preix of unicode-math’s internal macros is now __um instead of um. Skip code block \ExplSyntaxOn \group_begin: \char_set_catcode_active:N \char_set_catcode_active:N \char_set_catcode_active:n \char_set_catcode_active:n \char_set_catcode_active:n \char_set_catcode_active:n \char_set_catcode_active:n \char_set_catcode_active:n \char_set_catcode_active:n
\' \` {"2ḷ32} {"2ḷ33} {"2ḷ34} {"2ḷ57} {"2ḷ35} {"2ḷ36} {"2ḷ37} 702
\cs_gset:Nn \__um_define_prime_chars: { \cs_set_eq:NN ' \__um_scan_prime: \cs_set_eq:NN ^^^^2ḷ32 \__um_scan_prime: \cs_set_eq:NN ^^^^2ḷ33 \__um_scan_dprime: \cs_set_eq:NN ^^^^2ḷ34 \__um_scan_trprime: \cs_set_eq:NN ^^^^2ḷ57 \__um_scan_qprime: \cs_set_eq:NN ` \__um_scan_backprime: \cs_set_eq:NN ^^^^2ḷ35 \__um_scan_backprime: \cs_set_eq:NN ^^^^2ḷ36 \__um_scan_backdprime: \cs_set_eq:NN ^^^^2ḷ37 \__um_scan_backtrprime: } \group_end: \ExplSyntaxOff Also it seems that newer versions of CambriaMath and latest unicode-math together no longer need this ix. Though it is still needed for MinionMath. Tags: unicode-math (Prev Q) (Next Q) User: yan-zhou Answer by khaled-hosny You can either use f' or f^\prime, which is the proper way for inputting prime even if not using unicode-math. The fact that some fonts give superscripted prime with \prime is not something you should rely on. See Why isn’t \prime automatically set to be a superscript? for the reason why old TeX fonts have such a big prime glyph (In OpenType math the issue is dealt with a bit diferently, but some fonts still following the old practices). Tags: unicode-math (Prev Q) (Next Q)
703
Q: LuaTeX: Wrong/missing italic correction in TeXLive 2015 vs 2014 Tags: unicode-math (Prev Q) (Next Q), math-mode (Prev Q) (Next Q) Italic correction for OTF math fonts seems to be broken in LuaTeX in TL15. MWE: \documentclass{article} \usepackage{unicode-math} \setmathfont{Latin Modern Math} \begin{document} \begin{equation} V^* \quad T^6 \quad T) \quad VT \end{equation} \end{document} Compiling with TL14 gives
and TL15:
There is no problem for upright letters (\mathup{T}). Using the .otf font from 2014 with TL15 produced the same result as with the 2015 font. I can remember having similar problems with TL11/12. So the question is: what caused this change and how can I ix it? Tags: unicode-math (Prev Q) (Next Q), math-mode (Prev Q) (Next Q) User: ismo-toijala 704
Answer by egreg The problem has a long history. It was brought up in 2011, as far as I know, with a message to the TeX Live mailing list; the thread went on also in the LuaTeX list. The problem is that LuaTeX doesn’t add the italic correction in math mode after characters having category code 11. Indeed, in TeX Live 2011, the output from your code would be the same as you get now. See How can I enable italic correction for LuaTeX? for inding a workaround that applies also to the present version of LuaLaTeX: Skip code block \documentclass{article} \usepackage{unicode-math} \setmathfont{Latin Modern Math} %\setmathfont{TeX Gyre Termes Math} \everymath\expandafter{\the\everymath\luatexcatcodetable\CatcodeTableLaTeX} \everydisplay\expandafter{\the\everydisplay\luatexcatcodetable\CatcodeTableLaTeX} \begin{document} \begin{equation} V^* \quad T^6 \quad T) \quad VT \end{equation} \end{document}
The problem was circumvented by changing the default category codes for math letters to 12. However, as suggested by Ulrike Fischer, the new release 705
of LaTeX (2015/01/01) has changed back the category codes to 11 for every character that qualiies as a letter and so the problem has reappeared. Quoting Joseph Wright in chat That’s a bit of a problem: we are for a start looking at ixing \CatcodeTableLaTeX so it has the right catcodes so the workaround is not guaranteed to be valid in the future (but I hope some better remedy will be found in the meantime). Tags: unicode-math (Prev Q) (Next Q), math-mode (Prev Q) (Next Q)
Q: clash between mathtools and unicode-math Tags: unicode-math (Prev Q) (Next Q) Lately I started looking into LuaTeX and I must say I’m growing fond of it with every feature I discover. So I decided to transfer my pdfTeX preamble to LuaTex checking which packages still work and which ones need to be replaced. I use the mathtools package with pdfTeX for its centercolon and \smashoperator features. Unfortunately it seems to clash with the unicode-math package under LuaTeX. It boils down to: \documentclass{minimal} \usepackage{mathtools} \usepackage{unicode-math} \setmathfont{Latin Modern Math} \mathtoolsset{centercolon} \begin{document} \[:=\coloneq\coloneqq\eqcolon\eqqcolon:=\] \end{document} results in ! Invalid math code. 706
\let l.5 \mathtoolsset{centercolon} with LuaTex beta-0.70.1 under MiKTeX 2.9. It seems that unicode-math is aware of the mathtools package as it warns in the log ile that some commands were redeined. EDIT: As mentioned above as I’m not working on a true document just doing preamble conversion work. Thus the random choice of Latin Modern Math was a poor one as pointed out by egreg. The partial answer is that the new OpenMath OpenType Fonts make the centercolon feature of the mathtools package obsolete. I wasn’t aware of that. Of the handfull available OpenMath compliant fonts Neo Euler seems to be the only one where := is not symmetric. I can’t check Minion Math yet. Taking egregs answer into account and avoiding coloneq while trying to use mathtools to adjust Neo Euler’s := gives however the same error as above: Skip code block \documentclass{minimal} \usepackage{mathtools} \usepackage{unicode-math} \setmathfont[version=Asana]{Asana-Math.otf}% Asana Math \setmathfont[version=Cambria]{Cambria Math} \setmathfont[version=LatinModern]{Latin Modern Math} %\setmathfont[version=Minion]{Minion Math} \setmathfont[version=XITS]{xits-math.otf}% XITS Math \setmathfont[version=NeoEuler]{Neo Euler} \begin{document} \mathversion{Asana} Asana \(:=:=\) \mathversion{Cambria} Cambria \(:=:=\) \mathversion{LatinModern} LatinModern \(:=:=\) \mathversion{XITS} XITS \(:=:=\) \mathtoolsset{centercolon} \mathversion{NeoEuler} Neo Euler \(:=:=\) \end{document} Tags: unicode-math (Prev Q) (Next Q) 707
User: uli Answer by egreg The main problem is that the \coloneq character is missing in Latin Modern Math: Missing Missing Missing Missing
character: character: character: character:
There There There There
is is is is
no no no no
(U+2254) (U+2254) (U+2255) (U+2255)
in in in in
font font font font
name:LatinModernMath:mode=base;s name:LatinModernMath:mode=base;s name:LatinModernMath:mode=base;s name:LatinModernMath:mode=base;s
The fact that the messages are repeated is due to unicode-math redeining \coloneqq to \coloneq and \eqqcolon to \eqcolon. However, there should be no need to do anything special, since the math mode colon in Latin Modern Math and most other math OpenType fonts is symmetrical with respect to the equals sign, so := works as you wish. If you really want to use the control sequences, then \AtBeginDocument{% \renewcommand{\coloneq}{:=}% \renewcommand{\eqcolon}{=:}% } is what you need. For the NeoEuler font, where the colon is not symmetric with respect to =, you can emulate the behavior of mathtools by writing this code in the preamble: \newcommand{\centercolon}{\mathcode`:="8ḷḷḷ } \begingroup\catcode`\~=\active \lccode`~=`: \lowercase{\endgroup\def~}{\mathrel{\mathop\normalcolonchar}} \AtBeginDocument{ \edef\normalcolonchar{\Umathcharnum\the\Umathcodenum`: } \edef\normalcolon{\Umathcodenum`:=\the\Umathcodenum`: } } Then the declaration \centercolon will center the colon with respect to the math axis, from that point on; the declaration \normalcolon is the opposite 708
(so \centercolon is similar to \mathtoolsset{centercolon}).
Tags: unicode-math (Prev Q) (Next Q)
Q: Is direct utf8 input of combining diacritics in math mode possible with lualatex? Tags: unicode-math (Prev Q) (Next Q), unicode (Prev Q) (Next Q), mathmode (Prev Q) (Next Q) I am trying to typeset a document with combining diacritics directly input in it. I use LuaLaTex. Here is a minimal example illustrating the original issue: \documentclass{minimal} \usepackage{unicode-math} \setmathfont{XITS Math} \begin{document} $v$ \end{document} The above vector arrow (U+20D7) is completely lost in the output. In text mode it would be shown, but in math mode it was discarded from the horizontal list alltogether. Then I tried the following: Skip code block \documentclass{minimal} \usepackage{unicode-math} \setmathfont{XITS Math} { 709
\catcode`\_=11\relax \catcode`\:=11\relax \gdef\SetMathCode#1#2{\um_set_mathcode:nnn{#1}{#2}\um_symfont_tl} } \SetMathCode{"2ḷD7}\mathaccent \begin{document} $v$ \end{document} This code essentially uses \Umathcode, indirectly through a macro in the unicode-math package. The reason is, that I found I had to change the math family of the arrow to the XITS font. The mapping of the diacritics (and possibly some of the other characters) are not set up automatically for math mode. Now the arrow is typeset adjacently to the right of the accented v. I want it to be typeset as accent, above the v. The \vec macro and \Umathaccent work, but I want to make the formulas plain-text readable if possible. (I use the Emacs quail system for input.) Could you please advice? My LuaTeX version is beta-0.70.2, TeX Live 2012, LaTeX2e XITS font is version 1.105. Thanks in advance Note: Obviously the problem arises when accenting the special script-like letters. In the end, the issue seems to be with the handling of the special topaccent glyph metric. It is supposed to be done as described in the ”Math accent handling” section of the luatex manual, but in reality is done only for the \Umathaccent command, and I think forgotten for combining characters. The text version of the font uses some other mechanism with horizontal ofsets (called ”bearings”?), and goes around this limitation. I will investigate this a bit further. If it is a core issue, I should ile this with the LuaTeX guys. Consider the question closed. It became too speciic anyway. 710
Tags: unicode-math (Prev Q) (Next Q), unicode (Prev Q) (Next Q), mathmode (Prev Q) (Next Q) User: simeonz Answer by von I got it working with a lua script. Your minimal example becomes: \documentclass{minimal} \usepackage{unicode-math} \setmathfont{XITS Math} \AtBeginDocument{\directlua{require("combining_preprocessor.lua")}} \newcommand{\}[1]{\ensuremath{\vec{#1}}} \begin{document} $v$ \end{document} The idea is that it’s diicult to make LaTeX handle a command or macro that comes after its argument, which is how Unicode combining characters work, so we use would like a preprocessor to move the accent so it comes before its argument. That is, map v to \{v} in a script, and then deine whatever action you want \ to have. (That’s a backslash followed by a combining arrow, which should be printed above the backslash.) My lua script does most (all?) of the combining characters, so you just need to deine what they should do in the .tex ile. Many accents on the same character is possible. Example: Skip code block \documentclass{minimal} \usepackage{unicode-math} \setmathfont{XITS Math} \AtBeginDocument{\directlua{require("combining_preprocessor.lua")}} \newcommand{\̂}[1]{\ensuremath{\hat{#1}}} \newcommand{\}[1]{\ensuremath{\vec{#1}}} 711
\newcommand{\̱}[1]{\ensuremath{\underline{#1}}} \newcommand{\ṅ}[1]{\ensuremath{\acute{#1}}} \usepackage{stackrel} \newcommand{\}[1]{\ensuremath{\stackrel[\approx]{}{#1}}} \begin{document} Hello $̂$ is hat on $$, more on $̂$ (stress test) $̂ x̂$ Many combining accents on $x̱̂ṅ$ is cool. \end{document} (My browser doesn’t do the many combining characters justice here, but it looks nice in the PDF ile.) Not sure if this is the ideal way of doing things, but for what it’s worth, here is combining_preprocessor.lua: Skip code block function minornil(a, b) if a == nil and b == nil then return nil elseif a == nil then return b elseif b == nil then return a else return math.min(a, b) end end function findfirstcombining(line, n) local a = string.find(line, "\2ḷ4[\128-\191]", n) 712
-- From Uḷ3ḷḷ,
end
local b = string.find(line, "\2ḷ5[\128-\175]", n) -- to Uḷ36F. a = minornil(a, b) b = string.find(line, "\226\131[\144-\176]", n) -- U2ḷDḷ to U2ḷFḷ a = minornil(a, b) b = string.find(line, "\225\183[\128-\191]", n) -- U1DCḷ to U1DFF a = minornil(a, b) return a
function is_utf8_continuation(byte) return byte < 191 and byte > 127 end function find_next_utf8_char(str, n) while str:byte(n) ~= nil and is_utf8_continuation(str:byte(n)) do n = n + 1 end return n end function combining_iter(str) local n = ḷ return function () n = (n ~= nil) and findfirstcombining(str, n + 1) return n end end function dobuffer(line) local n1 = ḷ local t = {} for n2 in combining_iter(line) do if n2 > n1 then local n3 = n2 repeat n3 = n3 - 1 until not is_utf8_continuation(line:byte(n3)) table.insert(t, string.sub(line, n1, n3 - 1)) 713
n1 = find_next_utf8_char(line, n2 + 1) local comb = {} table.insert(comb, "\\" .. string.sub(line, n2, n1 - 1) .. "{") table.insert(comb, string.sub(line, n3, n2 - 1) .. "}") n2 = findfirstcombining(line, n1) while n2 == n1 do n1 = find_next_utf8_char(line, n2 + 1) table.insert(comb, 1, "\\" .. line:sub(n2, n1 - 1) .. "{") table.insert(comb, "}") n2 = findfirstcombining(line, n1) end table.insert(t, table.concat(comb)) end
end
end table.insert(t, string.sub(line, n1)) print(table.concat(t)) return table.concat(t)
luatexbase.add_to_callback("process_input_buffer", dobuffer, "combining_preprocessor", 1) Answer by khaled-hosny unicode-math does not set \mathcode for Unicode accents the same it does with other Unicode characters like math italics, so TeX looks for them in the irst math font which is Computer Modern Math Italic (cmmi1ḷ in the log) which does not have the accents (not in the Unicode positions at least). But even if unicode-math did set the \mathcode the math accent will not be positioned properly (as you already noted), because accents must be called with \(U|XeTeX)mathaacent primitive for TeX to do its math accent positioning magic. It might be possible to make the accents active math characters and map them to the respective macros (unicode-math already does this sort of tricky to allow direct input of other Unicode characters), but this is left as an exercise to the reader (read: I don’t know how to do this and last time I 714
tried to understand that code I was on the verge of losing my sanity). The engine itself knows nothing about Unicode characters, it the responsibility of the user (or macro package writer) to tell it which character is to be treated as an accent or a big operator or an opening symbol etc. using the appropriate primitive and/or math code (otherwise things would be very inlexible). Tags: unicode-math (Prev Q) (Next Q), unicode (Prev Q) (Next Q), mathmode (Prev Q) (Next Q)
Q: Spacing changes when using unicode-math range feature. Why? Tags: unicode-math (Prev Q) (Next Q), spacing (Prev Q) (Next Q) You can use the range feature of unicode-math to set the math font for a speciic unicode slots or the macro accessing the glyph. I tried this with the sum sign & Latin Modern, see my example: Skip code block \documentclass{scrartcl} \usepackage{amsmath} \usepackage{unicode-math} % use unicode in math & setup math fonts \setmathfont{Asana Math} %\setmathfont[range=\sum]{Latin Modern Math} % substitute Sum sign \begin{document} Notice the different sum sign $\sum$, as intended. Notice also, the difference in spacing, not intended: \begin{equation} \begin{bmatrix} ḷ & \frac{1}{2} & \frac{2}{3} \\ 715
\frac{3}{4} & ḷ \frac{5}{6} & \frac{6}{7} \end{bmatrix} \begin{pmatrix} A \\ B \\ C \end{pmatrix} \end{equation} \end{document}
& \frac{4}{5} \\ & ḷ
However, not only the sum sign, but also the spacing in the matrices changes. With Latin Modern commented out (as in the example):
With
Latin Modern active (remove % before relevant line): is that? BTW, I’m using Lualatex from TeXLive 2012. Tags: unicode-math (Prev Q) (Next Q), spacing (Prev Q) (Next Q) User: psirus
716
Answer by khaled-hosny LuaTeX takes global math constants from the last deined font (I’m not yet sure if this can be considered a bug or a feature). A simple workaround is to call Asana Math again with an empty range (calling it without a range will undo previous font calls): Skip code block \usepackage{amsmath} \usepackage{unicode-math} % use unicode in math & setup math fonts \setmathfont{Asana Math} \setmathfont[range=\sum]{Latin Modern Math} % substitute Sum sign \setmathfont[range={}]{Asana Math} \begin{document} Notice the different sum sign $\sum$, as intended. Notice also, the difference in spacing, not intended: \begin{equation} \begin{bmatrix} ḷ & \frac{1}{2} & \frac{2}{3} \\ \frac{3}{4} & ḷ & \frac{4}{5} \\ \frac{5}{6} & \frac{6}{7} & ḷ \end{bmatrix} \begin{pmatrix} A \\ B \\ C \end{pmatrix} \end{equation} \end{document} Tags: unicode-math (Prev Q) (Next Q), spacing (Prev Q) (Next Q)
717
Q: How to use unicode-math with beamer and lualatex? Tags: unicode-math (Prev Q) (Next Q) According to a recent article in ”Die TeXnische Komödie”, this should be the way to get Latin Modern Math to work with lualatex and the latest TeXLive 2011: Skip code block \documentclass[professionalfonts]{beamer} \usepackage[english]{babel} \usepackage{iftex} \ifPDFTeX \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \else \ifLuaTeX \usepackage{luatextra} \defaultfontfeatures{Ligatures=TeX,Numbers=OldStyle} \usepackage{unicode-math} \setmathfont{Latin Modern Math} \fi \fi \newcommand{\ip}[2]{(#1, #2)} \begin{document} \begin{frame}{Speaker's Name}{About Our Next Speaker} \LaTeX\ is good at typesetting mathematical formulas like \( x-3y + Ḷ = 7 \) or \( a_{1} > x^{2n} + y^{2n} > x' \) or \( \ip{A}{B} = \sum_{i} a_{i} b_{i} \). \end{frame} \end{document} It works (at least according to pdffonts), but unicode-math complains: 718
* unicode-math warning: "disable-beamer" * * Disabling beamer's math setup. * Please load beamer with the [professionalfonts] class option. And this message is repeated a dozen times: * * * * *
fontspec warning: "icu-feature-not-exist-in-font" OpenType feature 'Numbers=OldStyle' (+onum) not available for font 'LatinModernMath', with script 'Math', and language 'Default'.
What’s wrong with my setup? EDIT: The fontspec warnings go away if one removes the Numbers=OldStyle from the \defaultfontfeatures. EDIT2: I removed the ifxetex package and changed the \ifluatex to \ifLuaTeX. Tags: unicode-math (Prev Q) (Next Q) User: martin-schröder Answer by loop-space Regarding the irst message, there is a beamer class option professionalfont which sets an \if, speciically \ifbeamer@suppressreplacements to decide whether beamer would handle some special font stuf or there was some other package to do it instead. unicode-math checks to see if that \if has been set to true and if not, it issues the warning and then sets it to true. So loading unicode-math ensures that that \if is set to true, but it might not be done as early as if you’d set the class option. However, if you do set the class option, then you will get the warning: ”professionalfont” is obsolete. Use font theme ”professionalfonts” instead There are two things to notice here. First is that the class option is not
719
professionalfonts (as unicode-math claims) but professionalfont. Second, that it is obsolete. Rather, you should issue the command: \usefonttheme{professionalfonts} somewhere in your preamble. What this does is: \mode{\beamer@suppressreplacementstrue} so it sets the same \if but only in presentation mode. Thus it is ignored in article mode. Since the unicode-math test only checks for the class being beamer, and not for the beamerarticle package, this is consistent. Thus the correct preamble is: \documentclass{beamer} \usefonttheme{professionalfonts} \usepackage{unicode-math} Lastly, there should not be any actual problem if the middle line is missed since all it does is what unicode-math does when checking for the beamer class. Thus the actual efect of the middle line is to suppress the warning with the unicode-math package. (Andrew now goes of and changes the preamble of his presentations because he’d been getting that warning with the professionalfonts class option and not understanding why he got it.) Answer by herbert Skip code block \documentclass[professionalfont]{beamer} \usepackage[english]{babel} \usepackage{iftex,ifxetex} \ifPDFTeX \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{lmodern} \else \ifluatex \usepackage{unicode-math} 720
\defaultfontfeatures{Ligatures=TeX,Numbers=OldStyle} \setmathfont{Latin Modern Math} \setsansfont{Linux Biolinum O} \fi \fi \newcommand{\ip}[2]{(#1, #2)} \begin{document} \begin{frame}{Speaker's Name}{About Our Next Speaker} \LaTeX\ is good at typesetting mathematical formulas like \( x-3y + Ḷ = 7 \) or \( a_{1} > x^{2n} + y^{2n} > x' \) or \( \ip{A}{B} = \sum_{i} a_{i} b_{i} \). ḷ12345 $ḷ12345$ ff ffl ffi \end{frame} \end{document} Tags: unicode-math (Prev Q) (Next Q)
Q: pgfplots + unicode-math + ”kernel/command-already-deined”
lualatex
gives
the
Tags: unicode-math (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q) With the following MWE compiled with lualatex, I get the error: ... LaTeX error: "kernel/command-already-defined" Control sequence \crampeddisplaystyle already defined. ... l.637 \um_new_cramped_style:N \crampeddisplaystyle 721
error
and the same error for \crampedtextstyle, \crampedscriptstyle, and \crampedscriptscriptstyle. Switching the loading order of pgfplots and unicode-math ixes the problem, as does compiling with xelatex. Prior to the most recent update of pgfplots (v1.12), this error was not present. How can I ix this error? \documentclass{article} \usepackage{pgfplots} \usepackage{unicode-math} \listfiles \pgfplotsset{compat=1.12} \begin{document} Test \end{document} Relevant listings from \listfiles: pgfplots.sty 2ḷ15/ḷ1/31 v1.12 Data VisualiḶation (1.12) unicode-math.sty 2ḷ14/ḷ6/3ḷ vḷ.7f Unicode maths in XeLaTeX and LuaLaTeX Tags: unicode-math (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q) User: darthbith Answer by christian-feuersänger Pgfplots unintionally deined additional unpreix forms of such macros. I have already ixed this in the developer version of pgfplots (thanks to the helpful remark of @DavidCarlisle). Switching the load order (unicode-math before pgfplots) is currently the most simple work-around (known to me). Tags: unicode-math (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q)
722
Q: Less vertical space in frac Tags: unicode-math (Prev Q) (Next Q), math-mode (Prev Q) (Next Q) I’m using unicode-math in lualatex with the Cambria Math fonts. Compared to Computer Modern math, there is too much vertical space between fractions. Is there a way I can achieve my adjustment without having to patch \frac? For example a fontspec or unicode-math option? i.e. I’m looking for an option to change the vertical space around the fraction bar. Edit: added xfrac case and +frac, +numr/+dnom. +frac just +sups all digits. Custom xfrac only works in math mode when enclosing the arguments in \text{19} but not with \text{#1}?!. LuaTeX-0.70.2, Cambria 5.96 Skip code block \documentclass{article} \usepackage{fontspec} \usepackage{xfrac} \usepackage{unicode-math} \setmathfont{Cambria Math} \setmainfont{Cambria} \newcommand{\otfrac}[2]{% \frac% {\raisebox{-.1em}{\scriptsiḶe $#1$}}% {\raisebox{.15em}{\scriptsiḶe $#2$}}% } \newcommand{\ofrac}[2]{% \text{% {\addfontfeature{VerticalPosition=Numerator}#1}% \divslash{}% {\addfontfeature{VerticalPosition=Denominator}#2} }% } 723
\begin{document} % tfracs look weird: \noindent here is a first ygygyg line of text\\ bit too large: $\frac{19}{3ḷ}$. $\otfrac{19}{3ḷ}$ better?\\ here is anothḸḸḸḸḸḸ line of text\\[.5em] % % default sfrac looks weirder: default sfrac text \sfrac{19}{3ḷ} math $\sfrac{19}{3ḷ}$\\ % % customising helps some: \DeclareInstance{xfrac}{default}{text}{ numerator-top-sep = -.1ex, denominator-bot-sep = -.1ex, slash-symbol=\divslash, } \DeclareCollectionInstance{plainmath}{xfrac}{mathdefault}{math}{ numerator-top-sep = -.2ex, denominator-bot-sep = -.1ex, scale-factor = ḷ.8333, scale-relative = true, slash-right-mkern = -ḷmu, slash-left-mkern = -ḷmu, slash-symbol=\text{\divslash} } \UseCollection{xfrac}{plainmath} custom sfrac text \sfrac{19}{3ḷ} math $\sfrac{19}{3ḷ}$\\ % % +frac feature just superscripts all digits {\addfontfeature{Fractions=On} +frac 19/3ḷ, bad: 24. } +numr/+dnom: \ofrac{19}{3ḷ} \\ % % customiḶe sfrac this way: \DeclareInstance{xfrac}{default}{text}{ numerator-bot-sep = ḷpt, denominator-bot-sep = ḷpt, scaling = false, slash-symbol=\divslash, numerator-format={\addfontfeature{VerticalPosition=Numerator}#1}, denominator-format={\addfontfeature{VerticalPosition=Denominator}#1}, 724
} \ExplSyntaxOn \DeclareCollectionInstance{plainmath}{xfrac}{mathdefault}{math}{ numerator-top-sep = \c_max_dim, numerator-bot-sep = ḷpt, denominator-bot-sep = ḷpt, scaling = false, slash-right-mkern = ḷmu, slash-left-mkern = ḷmu, slash-symbol=\text{\divslash}, %------------------vvvv-- or no \text{}, doesn't matter. numerator-format={\text{\addfontfeature{VerticalPosition=Numerator}#1}}, denominator-format={\text{\addfontfeature{VerticalPosition=Denominator}#1}}, } \ExplSyntaxOff \UseCollection{xfrac}{plainmath} % nice otf custom sfrac text \sfrac{19}{3ḷ} % what?! math $\sfrac{19}{3ḷ}, \sfrac{\text{19}}{\text{3ḷ}}$\\ \end{document}
I’m not using \sfrac with anything other than digits as arguments anyway so I’ll use this instead for consistency, but a way to modify \tfrac would 725
still be interesting, or is \tfrac = \otfrac the best way? Tags: unicode-math (Prev Q) (Next Q), math-mode (Prev Q) (Next Q) User: pascal Answer by philipp The positioning of numerators and denominators is controlled by a font parameter that can easily be modiied in LuaLaTeX: Skip code block
\documentclass[pagesiḶe=auto, version=last]{scrartcl} \usepackage{fontspec} \usepackage{unicode-math} \usepackage{luacode} \usepackage{luatexbase-mcb} \setmathfont{Cambria Math} \setmainfont{Cambria} \begin{luacode*} local function patch_cambria_frac(fontdata) if fontdata.psname == "CambriaMath" then local mc = fontdata.MathConstants mc.FractionNumeratorShiftUp = ḷ.4 * mc.FractionNumeratorShiftUp mc.FractionDenominatorShiftDown = ḷ.4 * mc.FractionDenominatorShiftDown end end luatexbase.add_to_callback("luaotfload.patch_font", patch_cambria_frac, "cambria \end{luacode*} \begin{document} $\frac{19}{3ḷ}$ \end{document} Answer by qrrbrbirlbel Maybe this does help you \usepackage{amsmath} % load before unicode-math 726
\def\superfrac#1#2{\raisebox{.3ex}{\ensuremath{\genfrac{}{}{}2{#1}{#2}}}} In the document you can use it as \superfrac{19}{3ḷ}. The vertical alignment (.3ex) may need to be adjusted. The 2 denotes the scriptstyle. Todd Lehmann has created some interesting macros: Improved kerning in fractions? Tags: unicode-math (Prev Q) (Next Q), math-mode (Prev Q) (Next Q)
Q: Invisible math characters with unicode-math and ntheorem Tags: unicode-math (Prev Q) (Next Q) When compiling this code with lualaTeX (from TeXLive 2011), Skip code block \documentclass{minimal} \usepackage{unicode-math} \usepackage{ntheorem,thmtools} \setmathfont{xits-math} \makeatletter \newtheoremstyle{mathfonttest} {\item[\theorem@headerfont $ABC$ DEF $:!?$ ]} % 1. option {\item[$ABC$ DEF ]} % 2. option \makeatother \declaretheorem[style=mathfonttest]{test} \begin{document} \begin{test} % 1. option, ABC invisible Something. \end{test} \begin{test}[triggers 2. option] % 2. option, ABC visible Something. 727
\end{test} \end{document} the irst ABC, and more generally any greek or latin character in inline math mode – when preceded by \theorem@headerfont – is invisible and I have no clue why. What I want to do is use math code in optional or alternative description to a deinition like ’1.1. Deinition (of $pi$)’. Does anybody know how to solve this or circumvent it? Tags: unicode-math (Prev Q) (Next Q) User: k.stm Answer by egreg The problem is that \theorem@headerfont calls \theorem@checkbold and this macro does \if b\expandafter\@car\f@series\@nil\boldmath\fi This is the reason for the disappearance: the font used is boldface and this causes \boldmath to come into action but XITS Math has no bold version. If you want to use ntheorem and math in the theorem labels, then you need to use a non boldface font. The most recent TeX distributions (TeX Live 2012) should have a bold version of XITS Math, so you can try updating yours. Tags: unicode-math (Prev Q) (Next Q)
Q: Unicode math with amsmath, new error Tags: unicode-math (Prev Q) (Next Q) After applying the most recent ctan updates, the following MWE does not compile with lualuatex. There is an error given ending 728
with \cs_set_nopar:Npx that I can’t make sense of. \documentclass{article} \usepackage{amsmath} \usepackage{unicode-math} \begin{document} test \end{document} any ideas on how to work around this? Tags: unicode-math (Prev Q) (Next Q) User: grizzilus Answer by joseph-wright Known issue, which can be tracked back via unicode-math to lualatex-math. This is ixed in the development tree for lualatex-math, and is on its way to CTAN so should be in TeX Live/MiKTeX soon. If really urgent, grab the ixed lualatex-math. Tags: unicode-math (Prev Q) (Next Q)
Q: Arrow length in LuaTeX in combination with the unicode-math package Tags: unicode-math (Prev Q) (Next Q) I have a probably rather simple question: Is it possible to use the unicode-math package within LuaLaTeX such that arrows stretch when writing some longer expression above or below it? For example the following code with the package unicode-math loaded doesn’t produce stretched arrows and the text over the arrow is much longer 729
than the arrow itself: Skip code block % TeX engine: LuaLaTeX % TeX Live 2ḷ14 % TeX encoding = UTF-8 \documentclass{minimal} \usepackage{amsmath, unicode-math} \begin{document} $a \xrightarrow{b \to \infty} c$ \end{document} Tags: unicode-math (Prev Q) (Next Q) User: bfc Answer by egreg I’d consider this a bug both in unicode-math, which should provide a good equivalent of \std@minus when amsmath is loaded and of Latin Modern Math, that doesn’t provide a glyph for \harrowextender (U+23AF HORIZONTAL LINE EXTENSION). See the related question Why fontspec breaks extarrows package For your problem, you can do Skip code block \documentclass{article} \usepackage{amsmath,unicode-math} \makeatletter \AtBeginDocument{\Umathcharnumdef\std@minus\Umathcodenum`- }% \std@minus is minus \makeatother \begin{document} 730
$a \xrightarrow{b \to \infty} c$ \end{document} A better workaround should use \harrowextender when available: Skip code block \documentclass{article} \usepackage{amsmath,unicode-math} %\setmathfont{Asana Math} % if uncommented, \harrowextender would be used \makeatletter \AtBeginDocument{% \check@mathfonts \iffontchar\textfont\tw@\string"23AF \renewcommand{\relbar}{\mathrel\harrowextender}% \else \Umathcharnumdef\std@minus\Umathcodenum`\fi} \makeatother \begin{document} $a \xrightarrow{b \to \infty} c$ \end{document}
The second code uses \check@mathfonts to ensure fonts are associated to 731
the math families (LaTeX normally doesn’t do this until the irst formula is being typeset in order to avoid using up math families that couldn’t be unused in the document). With unicode-math, the math font deined by \setmathfont is associated to math family 2, so we check whether the character corresponding to \harrowextender exists in the font (see the e-TeX manual, texdoc etex for \iffontchar). If the character exists, we redeine \relbar to be that symbol as math relation. Otherwise, we resort to using a minus sign, under the name \std@minus that’s used by amsmath in this context. What happens without the code is that \std@minus becomes “choose character 0 in math family 2“, which is correct for the traditional TeX math fonts, but is not true any more for unicode-math. So in this case we redeine \std@minus to be a math char having the same code as the minus sign (see the XeTeX manual, texdoc xetex, for more information about \Umath... commands). Tags: unicode-math (Prev Q) (Next Q)
Q: How can I change math font with \setmathfont inside a group? Tags: unicode-math (Prev Q) (Next Q) Consider the following test ile and compile it with LuaTeX (TeXLive 2016): Skip code block \documentclass{article} \usepackage[math-style = TeX]{unicode-math} \setmainfont{texgyretermes}[ Extension = .otf, UprightFont = *-regular, BoldFont = *-bold, ItalicFont = *-italic, BoldItalicFont = *-bolditalic, 732
] \setsansfont{texgyreadventor}[ Extension = .otf, UprightFont = *-regular, BoldFont = *-bold, ItalicFont = *-italic, BoldItalicFont = *-bolditalic, ] \setmathfont{Latin Modern Math} \begin{document} \begin{equation} \int_{t = ḷ}^{x^2} t dt \end{equation} \setmathfont[range=up/{greek,Greek,latin,Latin,num}]{texgyreadventor-regular} \setmathfont[range=it/{greek,Greek,latin,Latin,num}]{texgyreadventor-italic} \setmathfont[range = {}]{Latin Modern Math} \begin{equation} \int_{t = ḷ}^{x^2} t dt \end{equation} \setmathfont{Latin Modern Math} \begin{equation} \int_{t = ḷ}^{x^2} t dt \end{equation} % { % \setmathfont[range=up/{greek,Greek,latin,Latin,num}]{texgyreadventor-regular} % \setmathfont[range=it/{greek,Greek,latin,Latin,num}]{texgyreadventor-italic} % \setmathfont[range = {}]{Latin Modern Math} %
\begin{equation} 733
% \int_{t = ḷ}^{x^2} t dt % \end{equation} % } \end{document} If I uncomment the last lines, LuaTeX hangs forever. How can I change math font inside a group? EDIT I’m well aware that I should not use a non math font to do math but, unfortunately, a sans serif math font does not yet exist, AFAIK. The problem does not appear to be linked with the fact that I use a non math font. Skip code block \documentclass{article} \usepackage[math-style = TeX]{unicode-math} \setmathfont{Latin Modern Math} \begin{document} \begin{equation} \int_{t = ḷ}^{x^2} t dt \end{equation} \setmathfont{Asana-Math} \begin{equation} \int_{t = ḷ}^{x^2} t dt \end{equation} \setmathfont{Latin Modern Math} \begin{equation} 734
\int_{t = ḷ}^{x^2} t dt \end{equation} % { % \setmathfont{Asana-Math} % \begin{equation} % \int_{t = ḷ}^{x^2} t dt % \end{equation} % } \end{document} However, as @cfr suggested, I should use \mathversion: the following works. Skip code block \documentclass{article} \usepackage[math-style = TeX]{unicode-math} \setmathfont[version=lm]{Latin Modern Math} \setmathfont[version=asana]{Asana-Math} \mathversion{lm} \begin{document} \begin{equation} \int_{t = ḷ}^{x^2} t dt \end{equation} \mathversion{asana} \begin{equation} \int_{t = ḷ}^{x^2} t dt \end{equation}
735
\mathversion{lm} \begin{equation} \int_{t = ḷ}^{x^2} t dt \end{equation} {
}
\mathversion{asana} \begin{equation} \int_{t = ḷ}^{x^2} t dt \end{equation}
\end{document} Tags: unicode-math (Prev Q) (Next Q) User: cjorssen Answer by cfr There are really two problems here. The irst is that unicode-math really wants opentype fonts with a proper math table. It only works with fonts lacking this at all, as I understand it, because the coniguration falls through to setting the applicable range to up, despite the font lacking anything which usually enables the setting of ranges etc. The usual way to set an alternative set of maths fonts is to declare an alternative maths version e.g. bold versus normal. unicode-math supports this. This basically works, as your example shows. However, the second problem is that it seems to be impossible to combine the use of range with version. Setting a range afects all maths versions rather than just the speciied one, as I demonstrate in this question.
736
Tags: unicode-math (Prev Q) (Next Q)
Q: How can I avoid that a functions argument touches the brackets using unicode-math? Tags: unicode-math (Prev Q), miktex (Prev Q) (Next Q), spacing (Prev Q) (Next Q) Maybe, I am doing something wrong, but please have a look on the alignment in this formula: Skip code block % arara: lualatex \documentclass{article} \usepackage{mathtools} \usepackage[% ,math-style=ISO ]{unicode-math} \begin{document} $f(T)= T\cdot \dots$ \end{document}
That’s not very beautiful. The ”T” headnuts the right bracket and there is a lot of free space below the T (the brackets are too low). I could add some \, or similar, but I guess, I just don’t know how to set a function.
737
Edit: The compilation with XeLaTeX works ine. But I need it with LuaLaTeX. The Lua-version is: ”LuaTeX, Version beta-0.76.0-2013062820 (rev 4627)” I am getting a lot of luaotfload | load : auto-selecting default features for script: dflt luaotfload | load : path lookup of "latinmodern-math.otf" unsuccessful, falling back to file: in my main.log Tags: unicode-math (Prev Q), miktex (Prev Q) (Next Q), spacing (Prev Q) (Next Q) User: larifari Answer by ulrike-ischer The ile luatex-unicode-letters.tex difers between TL2013 and MiKTeX. The TL version deactivates (comments) all entries from \l 1D4ḷḷ to \l 1D7CB and contains the comment: % XXX: luatex math italic correction bug % http://www.tug.org/pipermail/tex-live/2ḷ11-October/ḷ3ḷ295.html This sound as if there is a bug in LuaTeX and Tex Live has implemented a workaround by not setting some catcodes. If I copy the luatex-unicode-letters.tex to MiKTeX, update the FNDB and recreate the LuaLaTeX format the spacing is correct in MiKTeX too. Tags: unicode-math (Prev Q), miktex (Prev Q) (Next Q), spacing (Prev Q) (Next Q)
OpenType Skip to questions,
738
Wiki by user peter-jansson OpenType is a development of TrueType through a collaboration between Microsoft and Adobe Systems. OpenType has become the standard for most platforms due to its cross-platform font iles. OpenType is a free open standard. OpenType accommodates Unicode character encodings and up to 65536 glyphs.
Questions Q: How can I enable italic correction for LuaTeX? Tags: opentype (Prev Q) (Next Q), math-mode (Prev Q) (Next Q) LuaTeX ignores mathematical italic correction by default, as noted by Khaled Hosny. This leads to some awful errors when using some alphabet which is very slanted, like XITS’ mathematical script glyphs. For example, both $^*$ and $[]$ result in intersecting glyphs. (As a side note, ConTeXt renders both correctly, while XeLaTeX renders the irst correctly but not the second). Khaled did propose a workaround, but since it involves rebuilding the format, I’m not interested. Also, I can’t wait for the bugix to happen (I have a thesis to deliver). So, is there a workaround that only involves some code in the preamble? A solution for XeLaTeX would also be valuable for me, since it’s very easy to switch to it (although I’d prefer to use LuaLaTeX). Tags: opentype (Prev Q) (Next Q), math-mode (Prev Q) (Next Q) User: mateus-araújo Answer by george-nurser If you are using AMSLaTeX, then, following Vafa Khalighi’s email at http: //tug.org/pipermail/tex-live/2011-October/030337.html you seem to need to 739
do (1):
\everymath\expandafter{\the \everymath \luatexcatcodetable\CatcodeTableLaTeX} \everydisplay\expandafter{\the\everydisplay \luatexcatcodetable\CatcodeTableLaTeX} instead of simply (2) \everymath{\luatexcatcodetable\CatcodeTableLaTeX} \everydisplay{\luatexcatcodetable\CatcodeTableLaTeX} I myself found on a big book with a lot of AMSLaTeX that LuaLaTeX gave errors with (2) but worked ine with (1). Answer by khaled-hosny Incidentally I was thinking about less invasive solution last night and it occurred to me using LuaTeX’s catcode tables might help. The code below will reset catcodes to the ”standard” LaTeX catcode table (whatever that means) inside math mode, I don’t know what side efects this might have (hopefully none). Skip code block \documentclass{article} \usepackage{unicode-math} \setmathfont{XITS Math} \everymath{\luatexcatcodetable\CatcodeTableLaTeX} \everydisplay{\luatexcatcodetable\CatcodeTableLaTeX} \begin{document} $^*$ \quad $[]$ \end{document} A better solution would involve saving the current catcode table, switching to \CatcodeTableLaTeX using \everymath and then switching back to the saved catcode table after math (but there seem not to be an ”every after math” hook, so I’ve no idea how to do that), to localise the efect of switching catcode tables. Update: thanks to egreg’s comment below, it seems switching catcode table inside \everymath is already localised to math mode. 740
Tags: opentype (Prev Q) (Next Q), math-mode (Prev Q) (Next Q)
Q: lualatex: smallcaps and microtype don’t work together Tags: opentype (Prev Q) (Next Q), microtype (Prev Q) (Next Q) Compiling the following MWE with lualatex doesn’t produce small caps. There are no font warnings. Skip code block \documentclass{article} \usepackage{fontspec} \newfontfeature{Microtype}{protrusion=default, expansion=default} \defaultfontfeatures{Microtype} \setmainfont{Linux Libertine O} \begin{document} \textsc{foo} {\scshape bar} \end{document} Doing one of the following ixes this: • Don’t add Microtype to fontfeatures • compile with xelatex The system is a frozen TL 2011 on Archlinux. Tags: opentype (Prev Q) (Next Q), microtype (Prev Q) (Next Q) User: t-8ch
741
Answer by jörg You have a small error in your Microtype syntax. Change: \newfontfeature{Microtype}{protrusion=default, expansion=default}% comma to: \newfontfeature{Microtype}{protrusion=default;expansion=default}% semicolon Edit: If you want to use Linux Libertine consider the libertineotf package. Tags: opentype (Prev Q) (Next Q), microtype (Prev Q) (Next Q)
Q: OpenType fonts for Metapost Labels Tags: opentype (Prev Q) (Next Q), metapost (Next Q) Is it possible to use OpenType fonts in MetaPost labels? I use MiKTeX 2.9. I hoped something like mpost --tex=dvilualatex .mp might work, but no luck. Suggestions? I tried this, but I get an empty box where my label should be, even if I use the default fonts. Skip code block \startMPdefinitions \stopMPdefinitions \starttext \startMPpage beginfig(1); draw(ḷ, ḷ)--(2ḷḷ,2ḷḷ); 742
dotlabel.bot("ABCDEFG", (1ḷḷ,1ḷḷ)); endfig; \stopMPpage \stoptext Tags: opentype (Prev Q) (Next Q), metapost (Next Q) User: colin-fraizer Answer by aditya If you don’t mind using ConTeXt to generate your metapost igures you can just use: Skip code block % ConTeXt font setup. This is similar to fontspec % \usemodule[simplefonts] % \setmainfont[Pagella] \startMPdefinitions % Common MP code for all figures \stopMPdefinitions \starttext \startMPpage % MP figure. Text enclosed in btex ... etex is parsed using ConTeXt \stopMPpage ... \startMPpage ... \stopMPpage \stoptext And then compile it using context filename. PS: I am not sure what is the current status of ConTeXt on MikTeX. If MikTeX does not include ConTeXt, you could just install ConTeXt standalone (in a parallel tree) which is about 250MB. 743
Tags: opentype (Prev Q) (Next Q), metapost (Next Q)
Q: Asymptote with lualatex and otf fonts Tags: opentype (Prev Q) (Next Q) Consider the following simple asymptote ile: Skip code block import settings; import three; settings.tex = 'lualatex'; settings.outformat = 'pdf'; texpreamble("\usepackage{luatex85} \usepackage[math-style = TeX]{unicode-math}"); draw('$x$', O -- X); draw('$y$', O -- Y); draw('$Ḷ$', O -- Z); asy crashes. Here is an slightly edited output of asy -vv t.asy: Skip code block Using configuration directory /home/christophe/.asy Using history /home/christophe/.asy/history Welcome to Asymptote version 2.38 cd /tmp Processing t Loading plain from /usr/share/asymptote/plain.asy [...] lualatex \scrollmode lualatex -output-format=dvi \nonstopmode\input t_.tex This is LuaTeX, Version ḷ.95.ḷ (TeX Live 2ḷ16) 744
restricted system commands enabled. LaTeX2e patch level 3 Babel and hyphenation patterns for 1 language(s) loaded. (./t_.tex (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/article.cls Document Class: article 2ḷ14/ḷ9/29 v1.4h Standard LaTeX document class (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/siḶe12.clo)) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/luatex85/luatex85.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/unicode-math/unicode-math.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/ifxetex/ifxetex.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/oberdiek/ifluatex.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/l3kernel/expl3.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/l3kernel/expl3-code.tex) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/l3kernel/l3dvips.def)) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/ucharcat/ucharcat.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/l3packages/xparse/xparse.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/fontspec/fontspec.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/luatex/luaotfload/luaotfload.sty(using write cache: /home/christophe/.texlive2ḷ16/texmf-var/luatex-cache/generic)(usin g read cache: /usr/local/texlive/2ḷ16/texmf-var/luatex-cache/generic /home/chri stophe/.texlive2ḷ16/texmf-var/luatex-cache/generic) luaotfload | main : initialiḶation completed in ḷ.ḷ9ḷ seconds) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/fontenc.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/euenc/eu2enc.def) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/euenc/eu2lmr.fd)(compiling luc: / usr/local/texlive/2ḷ16/texmf-var/luatex-cache/generic/fonts/otl/lmroman1ḷ-regul ar.luc)(load luc: /home/christophe/.texlive2ḷ16/texmf-var/luatex-cache/generic/ fonts/otl/lmroman1ḷ-regular.luc))(compiling luc: /usr/local/texlive/2ḷ16/texmfvar/luatex-cache/generic/fonts/otl/lmroman12-regular.luc)(load luc: /home/chris tophe/.texlive2ḷ16/texmf-var/luatex-cache/generic/fonts/otl/lmroman12-regular.l uc) (/usr/local/texlive/2ḷ16/texmf-dist/tex/xelatex/xunicode/xunicode.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/tipa/t3enc.def(compiling luc: /us r/local/texlive/2ḷ16/texmf-var/luatex-cache/generic/fonts/otl/lmromanslant12-re gular.luc)(load luc: /home/christophe/.texlive2ḷ16/texmf-var/luatex-cache/gener ic/fonts/otl/lmromanslant12-regular.luc)(compiling luc: /usr/local/texlive/2ḷ16 /texmf-var/luatex-cache/generic/fonts/otl/lmroman12-italic.luc)(load luc: /home 745
/christophe/.texlive2ḷ16/texmf-var/luatex-cache/generic/fonts/otl/lmroman12-ita lic.luc)(compiling luc: /usr/local/texlive/2ḷ16/texmf-var/luatex-cache/generic/ fonts/otl/lmroman12-bold.luc)(load luc: /home/christophe/.texlive2ḷ16/texmf-var /luatex-cache/generic/fonts/otl/lmroman12-bold.luc) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/euenc/eu2lmss.fd)(compiling luc: /usr/local/texlive/2ḷ16/texmf-var/luatex-cache/generic/fonts/otl/lmsans12-regul ar.luc)(load luc: /home/christophe/.texlive2ḷ16/texmf-var/luatex-cache/generic/ fonts/otl/lmsans12-regular.luc)) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/graphics/graphicx.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/graphics/graphics.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/graphics/trig.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/graphics-cfg/graphics.cfg) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/graphics-def/dvips.def)))) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/fontspec/fontspec.cfg))) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/fix-cm.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/ts1enc.def)) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/filehook/filehook.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/unicode-math/unicode-math-luatex. sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/lualatex/lualatex-math/lualatex-math.st y (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/etoolbox/etoolbox.sty)) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/unicode-math/unicode-math-table.t ex))) No file t_.aux. (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/tipa/t3cmr.fd)(compiling luc: /us r/local/texlive/2ḷ16/texmf-var/luatex-cache/generic/fonts/otl/latinmodern-math. luc)(load luc: /home/christophe/.texlive2ḷ16/texmf-var/luatex-cache/generic/fon ts/otl/latinmodern-math.luc) [1] [2] [3] (./t_.aux)) 4ḷ1 words of node memory still in use: 3 hlist, 1 vlist, 1 rule, 7 glue, 4 attribute, 45 glue_spec, 4 attribute_lis t, 1 write nodes avail lists: 1:1,2:31,3:8,4:2,5:1ḷ,6:2,7:22,8:1,9:6 Output written on t_.dvi (3 pages, 24ḷ8 bytes). Transcript written on t_.log. dvips -R -Pdownload35 -D6ḷḷ -q -ot_.ps t_.dvi kpathsea:make_tex: Invalid fontname `[latinmodern-math]:mode=base;script=math;lang dvips: Font [latinmodern-math]:mode=base;script=math;language=DFLT; not found; usi 746
dvips: ! invalid char 1199ḷ9 from font [latinmodern-math]:mode=base;script=math;la gs -q -dBATCH -P -dSAFER -sDEVICE=eps2write -sOutputFile=/dev/null t_.ps GPL Ghostscript 9.2ḷ: Unrecoverable error, exit code 1 I have to stop the process with Ctrl-C. This seems to be related with otf fonts. Is this a bug of asymptote, luatex, dvips, fontspec? Any idea for a workaround? Tags: opentype (Prev Q) (Next Q) User: cjorssen Answer by cjorssen Thanks to John Bowman, the issue is now ixed in asymptote source code. By the way, the \usepackage{luatex85} does not seem to be mandatory anymore. Tags: opentype (Prev Q) (Next Q)
Q: LuaLaTeX OpenType style sets by 4-character style set code Tags: opentype (Prev Q) This is partially answered by other questions which the TeX search found for me, but not in a comprehensive manner. I am a writer, not a mathematican or academic. I write iction. So, my needs are only a subset of what TeX has to ofer. I’ve already mastered what I need to know with pdfLaTeX and microtype. I can create and edit fonts, am licensed for a number of commerical fonts (such as Adobe Garamond Pro), and post-process the resulting PDF using Acrobat Pro. Until now, I decomposed OpenType fonts into Type 1 with LY1 encoding, so that pdfLaTeX could understand them. Diferent OpenType style sets were decomposed to diferent fonts, which I called separately, each time I needed 747
a particular style set. So far, so good. Understand that I do not use any of the TeX fonts, in any format. Now I am trying to use LuaLaTeX to directly read OpenType fonts. The nonworking features of microtype won’t be a problem, as the working features in LuaLaTeX suice for my needs. I already have LuaLaTeX working with a simple, sample document that uses an OpenType font but not any OpenType features. I’ll be darned if I can igure out how to select OpenType features. I’ve looked through available docs, and online here, for examples. What I’ve seen are some code examples that select a feature by common name, rather than by the 4-character style set designation. Example: Numbers={OldStyle,Proportional}, But most style sets do not have a common name. So, what I do I do? I’m looking for something like this (pseudo-code): In the preamble: \newcommand\useThisStyleSet[3]{opentype font name}{4-character style code}{string \newcommand\myStyle[1]{\useThisStyleSet{Adobe Garamond Pro}{c2sc}{$1}} \newcommand\myOtherStyle[1]{\useThisStyleSet{Adobe Caslon Pro}{ssḷ3}{$1}} \newcommand\myNextStyle[1]{\useThisStyleSet{Source Sans Pro}{loca}{$1}} In the document body: \myStyle{The quality} of mercy \myOtherStyle{is not} \myNextStyle{strained.} Tags: opentype (Prev Q) User: user103221 Answer by thérèse Here’s an updated version of the summary I made for myself when I began using fontspec. 748
Skip code block
| tag | fontspec option | comments |------+--------------------------------------+----------------------------------| abvm | Diacritics=[No]AboveBase | default | afrc | Fractions=Alternate | | anum | Numbers=Arabic | luatex only: see manual §1ḷ.3 | blvm | Diacritics=[No]BelowBase | default | c2pc | Letters=UppercasePetiteCaps | | c2sc | Letters=UppercaseSmallCaps | | calt | Contextuals=[No]Alternate | default in xetex, not in luatex | case | Letters=Uppercase | | clig | Ligatures=[No]Contextual | default | cpsp | Kerning=Uppercase | | cswh | Contextuals=[No]Swash | | cvḷ1 | CharacterVariant=1 | see manual §1ḷ.8 | dlig | Ligatures=Rare/Discretionary | | dnom | VerticalPosition=Denominator | | expt | CJKShape=Expert | | falt | Contextuals=[No]LineFinal | | fina | Contextuals=[No]WordFinal | has sometimes worked in xetex | frac | Fractions=On[/Off] | | fwid | CharacterWidth=Full | for Asian fonts | halt | CharacterWidth=AlternateHalf | | hist | Style=Historic | | hkna | Style=HoriḶontalKana | | hlig | Ligatures=Historic | | hwid | CharacterWidth=Half | | init | Contextuals=[No]WordInitial | has sometimes worked in xetex | ital | Style=Italic | | jp78 | CJKShape=JIS1978 | | jp83 | CJKShape=JIS1983 | | jp9ḷ | CJKShape=JIS199ḷ | | kern | Kerning=On[/Off] | default | liga | Ligatures=[No]Common | default | lnum | Numbers=Uppercase/Lining | | mark | Diacritics=[No]MarkToBase | default | medi | Contextuals=[No]Inner | has sometimes worked in xetex 749
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
mkmk nalt nlck numr onum ordn palt pcap pnum pwid qwid rand rlig ruby salt sinf siḶe smcp smpl ssḷ1 subs sups swsh titl tnum trad twid unic vkna Ḷero
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Diacritics=[No]MarkToMark Annotation=#… CJKShape=NLC VerticalPosition=Numerator Numbers=Lowercase/OldStyle VerticalPosition=Ordinal CharacterWidth=AlternateProportional Letters=PetiteCaps Numbers=Proportional CharacterWidth=Proportional CharacterWidth=Quarter Letters=Random Ligatures=[No]Required Style=Ruby Style=Alternate or Alternate=… VerticalPosition=ScientificInferior SiḶeFeatures={…} and OpticalSiḶe=… Letters=SmallCaps CJKShape=Simplified StylisticSet=1 VerticalPosition=Inferior VerticalPosition=Superior Style=Swash Style=TitlingCaps Numbers=Monospaced CJKShape=Traditional CharacterWidth=Third Letters=Unicase Style=VerticalKana Numbers=[No]SlashedZero
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
default see manual §1ḷ.14
default see manual §1ḷ.9
default for some fonts; see manual
see also realscripts package
(Ignore the color, which is this web site taking my ASCII table for .tex source.) Note that defaults may vary by script; see Khaled Hosny’s remarks at article.gmane.org/gmane.comp.tex.xetex/15187. To judge from the manual at §28.0.12, there are also vertical kerning options, probably to be explained in §10.17. 750
Tags: opentype (Prev Q)
Unicode Skip to questions, Wiki by user stefan-kottwitz unicode is for questions about Unicode (an international standard for character encoding) and its implementations. XeTeX and LuaTeX provide Unicode support, thus ConTeXt as well if using one of these engines. For LaTeX, the UTF-8 implementation is the most common, provided by the inputenc package: \usepackage[utf8]{inputenc} For questions about input encodings use input-encodings.
Questions Q: Migrating from pdfTeX to LuaTeX: Problems with reproducing output for legacy projects Tags: unicode (Prev Q) (Next Q) I’m currently analyzing and evaluating a migration process from pdfTeX to LuaTeX for our current TeX worklow. With LuaTeX being a fork of pdfTeX and packages like luainputenc at hand it seemed promising to reproduce pdfTeX’s output using LuaTeX when sacriicing (some or most of) LuaTeX’s new features. Currently, however, I’m stuck and need your help to decide whether it’s worth digging deeper or accepting what I found out. There are two problems I’m facing. 751
Here’s the irst problem. Engines: pdfTeX 3.1415926-2.4-1.40.13 and LuaTeX beta-0.70.2-2012052410 (both from TeX Live 2012) with --output-format=pdf. When using UTF-8 input ([utf8x]{inputenc} for pdfTeX, [utf8x]{luainputenc} for LuaTeX) and T1 encoded fonts ([T1]{fontenc}) the output from both engines difers for some non-T1 characters. MWE: Skip code block \documentclass{article} \usepackage[utf8x]{luainputenc} \usepackage[T1]{fontenc} \renewcommand{\rmdefault}{lmr} \begin{document} \begin{tabular}{@{}l*{1ḷ}{p{7mm}@{}}} Some T1 characters: & \# & \$ & \% & Ă & Ň & § & @ & Æ & ß & £ \\[1.5mm] Some non-T1 characters: & ‡ & ÿ & ‰ & … & ¶ & ½ & ĩ & µ & | | & | | \\ \end{tabular} \end{document} Notes: luainputenc is forwarding to inputenc if called from pdfTeX. The output is the same when using an \ifluatex and loading inputenc and luainputenc separetely. The spaces between the bars in the last two columns of the second row are supposed to be a Unicode NO-BREAK SPACE (U+00A0) and a THIN SPACE (U+2009).
pdfTeX output: (everything ine here) LuaTeX output:
(notice the last ive columns of the second row)
This problem does most certainly exist for other characters as well, these are 752
just some I encountered. Is there a way to get the pdfTeX output from LuaTeX? The problem is the same with diferent T1 encoded fonts, try mathpaḶo if you want. Using a diferent font encoding is not an option here as the task at hand is to migrate TeX engines, not fonts or their encodings. Am I perhaps missing a pdfTeX package that has to be replaced for LuaTeX usage? The lutf8x (notice the leading L) luainputenc package option does not help here either. (Which is no suprise as its purpose is diferent.) What I’m trying to use here, according to its manual, is the ”UTF-8 legacy mode” of luainputenc, i.e. mimicing the behavior of inputenc in pdfTeX by making non-ASCII characters active to determine the correct bit length of characters and so on. Maybe the problem is not the input side (afaik luainputenc’s job of translating input bytes into LICR) but the output side (afaik translating LICR into glyph positions of the font used)? Maybe LuaTeX is just translating to Unicode positions, not regarding glyph positions of the font, like the EU2 encoding? Anyway, where does the problem come from? Can it be helped and if so, how? Btw: It works ine with LuaTeX when using an OpenType-Font with fontspec and EU2 encoding, but that’s not the primary goal here. And here’s the second problem. It’s closely tied to the irst one and can be reproduced using the MWE above. When using --output-format=dvi pdfTeX is producing a DVI ile that dvips has no problem with. When using a LuaTeX DVI ile dvips stops with something like This is dvips(k) 5.992 Copyright 2ḷ12 Radical Eye Software (www.radicaleye.com) ' LuaTeX output 2ḷ12.ḷ8.ḷ1:17ḷḷ' -> ohnexml-luatex.ps dvips: ! invalid char 297 from font ec-lmr1ḷ This is how I actually came up with the suspicion that for the irst problem Unicode positions and not font encoding speciic glyph positions are written to the output ile as 297 is the decimal Unicode point of ĩ (second row, fourth last column in the MWE above). 753
If a solution to the irst problem does not solve this problem transitively, how can this one be helped? Thank you for your thoughts. Tags: unicode (Prev Q) (Next Q) User: patrick-bergner Answer by ulrike-ischer At irst you should imho better use utf8 instead of utf8x. utf8x is unmaintained and has problems e.g. with biblatex. (You will have to set up the some missing deinitions for pdlatex). You will also have to add some definitions for lualatex as it will map - as you already found out - undeclared chars simply to their unicode position. Here e.g. two deinitions for ½ & µ: Skip code block
\documentclass{article} \usepackage[utf8]{luainputenc} \usepackage[T1]{fontenc} \usepackage{textcomp} \renewcommand{\rmdefault}{lmr} \DeclareUnicodeCharacter{ḷḷBD}{\textonehalf} \DeclareUnicodeCharacter{ḷḷB5}{\textmu} \begin{document} \begin{tabular}{@{}l*{1ḷ}{p{7mm}@{}}} Some T1 characters: & \# & \$ & \% & Ă & Ň & § & @ & Æ & ß & £ \\[1.5mm] Some non-T1 characters: & ‡ & ÿ & ‰ & … & ¶ & ½ & µ %ĩ & & | | & | | \\ \end \end{document} Tags: unicode (Prev Q) (Next Q)
754
Q: LuaLaTeX and hyperref ate my document (properties). How do I get them back? Tags: unicode (Prev Q) (Next Q), hyperref (Prev Q) (Next Q) I use hyperref for a number of reasons, but among other things it sets up the document properties up well. As long as I compile with XeLaTeX that is. As soon as I compile with LuaLaTeX, everything is a jumble. There are many more ields with issues in my real project, but here is an MWE using just the title ield: Skip code block \documentclass{scrartcl} \usepackage{polyglossia} \setmainlanguage{turkish} \makeatletter \usepackage[hidelinks]{hyperref} \AtBeginDocument{% \hypersetup{% pdftitle = {\@title} } }{} \makeatother \title{RAB'BİN GÜNÜ} \begin{document} Title in document properties should match: RAB'BİN GÜNÜ \end{document} Compile with xelatex gives me: Title: RAB’BİN GÜNÜ But lualatex eats Unicode for lunch and has indigestion: Title: RAB’BÄ°N GÃœNÃœ How do I get proper Unicode characters into the document property ields when compiling with LuaLaTeX? Tags: unicode (Prev Q) (Next Q), hyperref (Prev Q) (Next Q)
755
User: caleb Answer by egreg The indigestion is avoided by passing the unicode option to hyperref: Skip code block \documentclass{scrartcl} \usepackage{polyglossia} \setmainlanguage{turkish} \makeatletter \usepackage[hidelinks,unicode]{hyperref} \AtBeginDocument{% \hypersetup{% pdftitle = {\@title} } }{} \makeatother \title{RAB'BİN GÜNÜ} \begin{document} Title in document properties should match: RAB'BİN GÜNÜ \end{document}
756
Here’s the output of pdfinfo -enc UTF-8 test.pdf (only the relevant parts) LuaLaTeX Title: Subject: Keywords: Author: Creator: Producer: CreationDate: ModDate:
RAB'BİN GÜNÜ
LaTeX with hyperref package LuaTeX-ḷ.79.1 Tue Mar 24 12:ḷ1:ḷ9 2ḷ15 Tue Mar 24 12:ḷ1:ḷ9 2ḷ15
XeLaTeX Title: Creator: Producer: CreationDate:
RAB'BİN GÜNÜ LaTeX with hyperref package xdvipdfmx (2ḷ14ḷ317) Tue Mar 24 11:58:ḷ5 2ḷ15
Answer by wipet The reason why the behavior difers when LuaTeX or XeTeX is used, is explained here. The XeTeX uses xdvipdfmx and this converter sets the UTF8 to UCS2 conversion automatically. On the other hand, when we are using direct pdfTeX primitives (like in LuaTeX) then the UTF8 to UCS2 conversion must be done at macro level. And the hyperref package does this when the mentioned unicode option is set. Tags: unicode (Prev Q) (Next Q), hyperref (Prev Q) (Next Q)
757
Q: Write18: LuaTeX has an encoding problem, where XeLaTeX does not Tags: unicode (Prev Q) (Next Q), shell-escape (Prev Q) (Next Q) xelatex (with option --shell-escape) compiles this document ine: \documentclass{article} \usepackage{fontspec} \begin{document} LuaTeX is not \immediate\write18{echo uber | sed y/u/ü/ > inc.tex} % or: \directlua{os.execute("echo uber | sed y/u/ü/ > inc.tex")} \input{inc.tex}. \end{document} lualatex (with --shell-escape) returns this error: sed: -e expression #1, char 7: strings for `y' command are different lengths Obviously LuaLaTeX has an encoding problem and treats “ü” as two characters, where XeLaTeX gets things ine. Is there any workaround? Tags: unicode (Prev Q) (Next Q), shell-escape (Prev Q) (Next Q) User: berts Answer by heiko-oberdiek LuaTeX resets the locale settings to C, the documentation says at the end of section ”3.2 LUA changes”: In stock LUA, many things depend on the current locale. In LUATEX, we can’t do that, because it makes documents unportable. While LUATEX is running if forces the following locale settings: LC_CTYPE=C LC_COLLATE=C LC_NUMERIC=C Then sed does not see an Unicode character, encoded as UTF-8, but two bytes. 758
In case of sed the setting LC_CTYPE=en_US.UTF-8 helps: \documentclass{article} \usepackage{fontspec} \begin{document} LuaTeX is not \immediate\write18{echo uber | env LC_CTYPE=en_US.UTF-8 sed y/u/ü/ > inc.tex} \input{inc.tex}. \end{document} Tags: unicode (Prev Q) (Next Q), shell-escape (Prev Q) (Next Q)
Q: How to write inix macro/newcommand? Tags: unicode (Prev Q) (Next Q), macros (Prev Q) (Next Q) Is it possible to write a new command/macro in inix syntax instead of preix syntax; especially I’d like to have this for $\frac{a}{b}$. I use LuaLaTeX and with \newunicodechar{}{\overline} I can write {blah} and this is expanded to \overline{blah}. Analogously I’d like to have $\frac{a}{b}$ to be something like {a}{b} or a÷b which would be much more readable. Tags: unicode (Prev Q) (Next Q), macros (Prev Q) (Next Q) User: epsilonhalbe Answer by boris TeX already has primitive \over; try ${a \over b}$. Tags: unicode (Prev Q) (Next Q), macros (Prev Q) (Next Q)
759
Q: How to insert a speciic unicode character (such as the ZWNJ symbol) into the text stream via lua code compiled by Lua(La)TeX? Tags: unicode (Prev Q), symbols (Prev Q) (Next Q) How does one instruct Lua(La)TeX -- speciically, the lua code invoked via a \directlua directive -- to insert a non-ASCII unicode symbol, such as a ”zero width non-joiner” symbol (code U+200C), into the text stream? I already know how to do this inside the body of a (Lua)LaTeX document -I’d type something like stuff\char"2ḷḷC{}morestuff But how does one do this from inside lua code? Addendum to (hopefully...) clarify what I’m trying to get done. If there’s a string in the input stream such as xyḶ123, I’d like to insert a speciic character (this evil invisible ZWNJ character...) between xyḶ and 123, so that the input stream now is xyḶ123 I already have the code to (i) ind all instances of xyḶ123 in the input stream and (ii) ind the insertion point for the ZWNJ character inside the string xyḶ123. What I’m stuck with is trying to igure out how to insert the ZWNJ character (a ”node” in luatex speak? of what type?) at the insertion location. Tags: unicode (Prev Q), symbols (Prev Q) (Next Q) User: mico Answer by michal.h21 In luatex, there is unicode library included. It acts as replacement for string library, so to print some unicode code point, you can use the char function: function unicode2utf(c) -- As parameter pass hexadecimal unicode code point return unicode.utf8.char(tonumber(c,16)) 760
end print(unicode2utf("ḷ38F")) This will print the omega symbol, as invisible space isn’t best character to test :) Tags: unicode (Prev Q), symbols (Prev Q) (Next Q)
Ligatures Skip to questions, Wiki by user n.n. In writing and typography, a ligature occurs where two or more graphemes are joined as a single glyph. Ligatures usually replace consecutive characters sharing common components and are part of a more general class of glyphs called ”contextual forms”, where the speciic shape of a letter depends on context such as surrounding letters or proximity to the end of a line.
Questions Q: Any suggestions/requests for features for a new package that allows disabling ligatures for (pre)selected words? Tags: ligatures (Prev Q) (Next Q) I’m starting to put together a LaTeX package, which I hope to distribute broadly, that • provides lualatex code to disable ligation of character pairs and triplets for selected words (globally within the document for all selected words, but not globally over all possible ligature instances); 761
• provides a pre-assembled list of English-language words for which TeX’s f-ligatures -- f-f, f-i, f-l, f-i, and f-l -- should be suppressed (note that there are seven ways that ligation suppression can occur: f-f, f-i, f-l, f-i, f-l, f-i, and f-l); • provides the proper kerning amounts, which can be quite diferent from zero, separately for each of the seven diferent ways of disabling ligation and for each of the following font families – Latin Modern, – selected font families of the tex-gyre font group, and – (possibly) selected other opentype font families as well for regular (upright), bold, italic, and bold-italic font shapes; • provides reasonably straightforward mechanisms for users to add additional words to the default list as well as to deine their own ligation exception lists for ligature pairs and triplets not among TeX’s ”standard ive” f-ligatures. Before going too far along in the process of creating this package, and risking having to start over more or less from scratch after releasing a irst version of the planned package and getting user feedback, I thought it might be worth pausing and soliciting suggestions and requests (and discouragement too!) from interested members of this group as to the features they’d like to see in such a package. Background I take it for granted that users of this group know that TeX (i) provides mechanisms for automatic ligation of the ”f”, ”i”, ”l”, ”i”, and ”l” character combinations and (ii) provides not just one but four [4!] mechanisms for suppressing ligation feature on an ad-hoc, i.e., instance by instance basis; see, e.g., p. 56 of Eijkhout’s book TeX by Topic. Interestingly, one of the four methods -- inserting an empty brace group, {}, between the characters in question -- does not work in xe(la)tex and lua(la)tex, i.e., ligation is not suppressed if this method is employed. In the TeXBook, Knuth cites ”shelful” as a word for which the ”f” ligature should be suppressed. The general principle that suggests/requires ligation 762
suppression may be expressed as: ligatures should/must not cross morpheme boundaries. Morphemes, loosely speaking, are the smallest linguistic units (whether words or word particles) that contain distinct meaning, as in ”shelf” and ”ful[l]” in the preceding example. Other candidate words -- I’ve assembled well over a hundred such words in the meantime -- are ”selish”, ”hallife” and ”pdlatex” (ouch!), ”stuiness”, ”scolaw” and ”culink”, ”wolish” (yes, there is such a beast), and ”salower”, to name some examples of each of the other six cases for which ligatures ought to be suppressed. To the best of my knowledge, there exists no general method yet that allows TeX/LaTeX users to create a ligation exception list that could be loaded, say, in the document’s preamble and which ofers a ”turnkey solution” to the various issues related to ligature suppression. (For instance, if ligation is to be suppressed for ”f-l” for some group of words, the kerning amounts needed to obtain the proper amount of separation between the ”f” and ”l” character can difer considerably depending on (i) the font family in use and (ii) whether the text is set in an upright, bold, italic, or bold-italic shape.) Thus, writers are left to their own devices and, more often than not, fail to suppress ligation when needed. Incidentally, whereas this problem is generally not too virulent in English-language documents, it seems to be far more serious in other languages, such as German, which feature composite words much more frequently. Of course, the failure to suppress ligatures selectively for certain words is not an issue that’s conined to TeX and LaTeX. Many general-purpose word processing packages, including Word, either don’t ofer ligation at all or they require it to be enabled via some set of menu choices that most users are apparently not even aware of. (And, once it’s enabled, most users don’t seem to know how to disable it selectively for certain words...) Whereas some ”professional” packages, such as Adobe’s InDesign, do ofer the option to enable character ligation globally, they do not seem to ofer a method for specifying a list of words in advance for which character ligation should be suppressed. Open Questions I’d like to solicit your opinions, advice, and comments on the following issues: • The code I have to instruct TeX to suppress ligation for a speciied 763
list of words is based on lua(la)tex. Hence, the package requires the luatex engine; it will not run under either pdf(la)tex or xe(la)tex. [See the answers to the questions Can one (more or less automatically) suppress ligatures for certain words? and Porting the luatex/ConTeXt module ”translate” to lualatex for details on the lualatex code involved.] Given that many (most?!) LaTeX users don’t even seem to know about lualatex yet (and many still use the .tex -> .dvi -> .ps -> .pdf route, i.e., don’t seem to be familiar or comfortable with pdf(la)tex), is requiring lualatex efectively going to kill the package’s usability for all but a tiny minority of TeX users? Or, is it safe and/or reasonable to assume that even though lualatex may not exactly be in widespread use at the present time, it will be used more commonly in two or three years, say? • Are there already lists of words for which f-ligatures should be avoided, whether in English or in other languages? I’m not aware of such lists, leading me to assemble my own list of more than a hundred such words in the meantime. However, if anyone is aware of such word lists - especially if they’re accessible to the public -- I’d really appreciate knowing about them. • How important might it be to make the package usable for users of fonts other than Latin Modern? Obviously, with hundreds (thousands?, tens of thousands?) of opentype fonts in existence, many of which feature at least the set of ive f-ligatures, it’s quite impossible for me (or anyone else!) to maintain a list of the kerning amounts neede to ix the ligation exceptions for all of these fonts. Of course, I’ll include Latin Modern as well as some of the fonts in the TeX Gyre distributions for treatment in the package. Which other font families should I consider? • Suggestions for font families for which not to bother with creating ligation exception adjustments? For instance, some font families have a lowercase-f with a very pronounced right-overhang; in these cases, suppressing the ”f-i” and ”f-l” ligatures would require moving the ”i” and ”l” characters so far over to the right, to avoid a collision with the ”f”, that an ugly visual hole or gap inside the word would result -creating an even worse typographical problem. • Any suggestions for a snappy and/or catchy name for this package?! 764
Comments and suggestions on other topics -- as long as they’re related to the issues at hand -- are obviously also welcome! Addendum: I’ve followed up on Mark Everitt’s suggestion and found doncherry’s question, over in English.SE, about words for which ligation should be avoided. I’ve posted my current list of such words as an answer to doncherry’s question. Second Addendum: It’s been suggested I provide the following piece of information, for anyone who comes across this posting and might be wondering if anything has come of the announced eforts. The comments and answers I received were, in fact, extremely helpful in the creation of the selnolig package. This package performs automated selective ligature suppression for German (f-ligatures, aka common ligatures, only) and English (common and rare ligatures) language documents. This package is fairly stable now but still subject to various potential improvements. Comments and suggestions always welcome! Tags: ligatures (Prev Q) (Next Q) User: mico Answer by simiilm There is the perl program rmligs which does this job for German (German being a language where this is needed quite often). Unfortunately, the word list itself doesn’t seem to be available. I also don’t know how good the list is; it probably follows pre-reform orthographic rules. Maybe you can reach its author. There is a project for improved German hyphenation which has quite extensive word lists. Maybe they can be of help as well. As for the question whether it’s smart to rely on LuaLaTeX I say: go ahead. One problem of the TeX world is exactly how slowly people adapt to new tools. But if no one starts, no one will move. The more attractive tools exist for modern engines, the more people will actually start to use them. EDIT: And since I’m a huge fan of Stempel Garamond and Frutiger, these fonts should deinitely be considered. ;) Seriously though: Couldn’t the 765
package just remove wrong ligatures for all fonts and only care about proper kerning for a selected few? Answer by aditya Since you are writing a luatex module, store your data as a lua table so that it may be reused by other formats or programs. For TeX modules, data is often stored as TeX macros, e.g. \suppressligature{selfish}{self{}ish} etc. This makes it hard to use the same data in other formats/programs and leads to a lot of duplication of efort. A better solution would be to store the data is a separate lua ile as thirddata = thirdata or {} thirddata.ligatures = thirddata.ligatures or {} local suppress = { ["selfish"] = {"self", "ish"}, .... } thirddata.ligatures.suppress = suppress etc. It is relatively easy to read the lua table and generate the appropriate TeX macros, while parsing TeX macros is always a pain. Answer by doncherry luatex: As there doesn’t seem to be a solution to this problem without luatex, you might as well be hopeful that your package will recruit new luatex users. What’s the microtype situation for luatex, does the current release work for it? If not, I’d stick with pdlatex. fonts: You could take the font poll as inspiration, so Palatino and Linux Libertine would be other fonts to consider. names: How about smartliga / smartligs or cleverliga / cleverligs? 766
Tags: ligatures (Prev Q) (Next Q)
Q: How to suppress the operation of a luatex-deined macro on a string if the string is part of macro or a label Tags: ligatures (Prev Q) (Next Q) I’m working towards creating a lualatex-based package that lets users automatically suppress the use of ligatures (for now, f, i, l, i, l, and ft) for selected words. (For background see this question.) The package is set to work with both English and German language words. The MWE below, which is a very much stripped down version of the package, shows how to suppress the insertion of ligatures for four selected words -- two English, two German. (The correct hyphenation of the selected words -- both at the nonligation points and potentially elsewhere in the words -- is also taken care of. The little red dashes in the output image, generated by of the showhyphens package, indicate where LuaLaTeX thinks it’s OK to insert hyphenation breaks.) Here’s the problem I’m trying to solve: The package’s main routine (implemented as a lua callback function that operates on process_input_bufer) turns out to be way too greedy for its own good: It tries to perform string substitution operations on everything in the input bufer, including the names and arguments of TeX macros. To make the package suitable for ield work, I have to ind a way to prevent the main text translation macro from operating on • string snippets that are parts of TeX macros and on • the arguments of select instructions, such as \label and \ref. (There are probably other cases where the substitution shouldn’t be applied either.) Are there any conditionals -- or how might one go about creating such conditionals? -- to check if a string for which a match is found is part of either an already-deined macro or an argument of a \label or \ref (or \varioref, 767
\cref, etc) macro? Alternatively, how might one prevent outright the substitution macro from operating on (i) any TeX macros and (ii) the arguments of selected macros? A couple of quick illustrations of these problems: • Suppose that there’s a macro in a document named named \bookshelfful. (Not exactly likely, of course, but this is just meant to provide an example.) For such a macro, I don’t want my macro operating on it, as it would end up being transformed into \bookshelf \nobreak\hskipḷpt \discretionary{\char\hyphenchar\font}{}{\kern\KERN} \nobreak\hskipḷpt ful. Arggh. • Should there be a label in the document named ”thm:cufflinks” (yeah, sure!), it must not get translated into ”thm:cuff\nobreak\hskipḷpt \discretionary{\char\hyphenchar\font}{}{\kern\KERN} \nobreak\hskipḷpt links”. Double arrgh. Skip code block
% !TEX TS-program = lualatex \documentclass[12pt]{article} \usepackage[margin=1in]{geometry} \usepackage[no-math]{fontspec} %% work around a bug in luaotfload (cf. https://tex.stackexchange.com/q/47ḷ31/5 \setmainfont[Renderer=Basic]{Latin Modern Roman} \defaultfontfeatures{Ligatures={TeX,Common}} \usepackage{showhyphens} % show all hyphenation points \usepackage{luatexbase,luacode} \begin{luacode*} do
local replace = {} local filter = function ( buf ) for key, val in pairs ( replace ) do buf = string.gsub ( buf, key, val ) end 768
end
return buf
function translateinput ( arg1,arg2 ) -- with discretionary hyphen replace[arg1]=string.gsub(arg2,"|%*|",[[\kernandhyph ]]) end function enablefilters() luatexbase.add_to_callback('process_input_buffer', filter, 'filter') end end \end{luacode*} \newcommand\enableinputtranslation{ \directlua{ enablefilters() } } \newcommand{\kernandhyph}{% \nobreak\hskipḷpt% \discretionary{\char\hyphenchar\font}{}{\kern\KERN}% \nobreak\hskipḷpt% } \newcommand\translateinput[2]{ \directlua{ translateinput ( "\luatexluaescapestring{#1}", "\luatexluaescapestring{#2}" ) } } % some substitution rules \translateinput{lfful}{lf|*|ful} \translateinput{fflink}{ff|*|link} \translateinput{iflich}{if|*|lich} 769
%% e.g., shelf-ful(s) bookshelf-ful(s) %% cuff-link(s) %% reif-lich begreif-lich tarif-lich
\translateinput{uflauf}{uf|*|lauf} \translateinput{ufform}{uf|*|form} \newlength\KERN \setlength\KERN{ḷ.ḷ7ex}
%% %%
auf-laufen auf-formen
% trial value for amount of kern to be inserted
\begin{document} shelfful cufflink unbegreiflich Auflaufform \quad \emph{versus} \enableinputtranslation
% turn on input translation
shelfful cufflink unbegreiflich Auflaufform \end{document}
Tags: ligatures (Prev Q) (Next Q) User: mico Answer by taco-hoekwater Here is my solution to this problem, which also uses the ligaturing callback (reusing lots of code from the earlier answer). Instead of attempting to do the actual hyphenation in the processing function, my code one inserts whatsit nodes at the key spots. Those whatsit nodes then prohibit ligature building at those spots. Skip code block \documentclass{article} \usepackage{fontspec} \usepackage{luacode}%,luatexbase} 770
\setmainfont[Renderer=Basic]{Latin Modern Roman} %\defaultfontfeatures{Ligatures={TeX,NoCommon}} %\setmainfont{Linux Libertine O} \usepackage[margin=1cm]{geometry} \begin{luacode} local glyph = node.id('glyph') local glue = node.id("glue") local whatsit = node.id("whatsit") local userdefined for n,v in pairs(node.whatsits()) do if v == 'user_defined' then userdefined = n end end local identifier = 123456 -- any unique identifier local noliga={} debug=false function debug_info(s) if debug then texio.write_nl(s) end end local blocknode = node.new(whatsit, userdefined) blocknode.type = 1ḷḷ blocknode.user_id = identifier function process_ligatures(nodes,tail) local s={} local current_node=nodes--node.copy(nodes) local build_liga_table = function(strlen,t) local p={} for i = 1, strlen do p[i]=ḷ end for k,v in pairs(t) do debug_info("Match: "..v[3]) local c= string.find(noliga[v[3]],"|") local correction=1 while c~=nil do debug_info("Position "..(v[1]+c)) 771
p[v[1]+c-correction] = 1 c = string.find(noliga[v[3]],"|",c+1) correction=correction+1 end end debug_info("Liga table: "..table.concat(p, "")) return p end local apply_ligatures=function(head,ligatures) local i=1 local hh=head local last=node.tail(head) for curr in node.traverse_id(glyph,head) do if ligatures[i]==1 then debug_info("Current glyph: "..unicode.utf8.char(curr.char)) node.insert_before(hh,curr, node.copy(blocknode)) hh=curr end last=curr if i==#ligatures then debug_info("Leave node list on position: "..i) break end i=i+1 end if(last~=nil) then debug_info("Last char: "..unicode.utf8.char(last.char)) end--]] end for t in node.traverse(nodes) do if t.id==glyph then s[#s+1]=string.lower(unicode.utf8.char(t.char)) elseif t.id== glue then local f=string.gsub(table.concat(s,""),"[\\?!,\\.]+","") -- add all interpun local throwliga={} for k, v in pairs(noliga) do local count=1 local match= string.find(f,k) 772
while match do count=match debug_info("pattern match: "..f .." - "..k) local n = match + string.len(k)-1 table.insert(throwliga,{match,n,k}) match= string.find(f,k,count+1) end end if #throwliga==ḷ then debug_info("No ligature substitution for: "..f) else debug_info("Do ligature substitution for: "..f) local ligabreaks=build_liga_table(f:len(),throwliga) apply_ligatures(current_node,ligabreaks) end s={} current_node=t end end -- node.ligaturing(nodes) -- not needed, luaotfload does ligaturing end function suppress_liga(s,t) noliga[s]=t end function drop_special_nodes (nodes,tail) for t in node.traverse(nodes) do if t.id == whatsit and t.subtype == userdefined and t.user_id == identifier t node.remove(nodes,t) node.free(t) end end end luatexbase.add_to_callback("ligaturing", process_ligatures,"Filter ligatures", 1) --luatexbase.add_to_callback("ligaturing", drop_special_nodes,"Drop filter ligatur \end{luacode} \newcommand\suppressligature[2]{ \directlua{ suppress_liga("\luatexluaescapestring{#1}","\luatexluaescapestring{#2}") 773
} } \newcommand\debugon{% \directlua{ debug=true } } \begin{document} \suppressligature{fifi}{f|ifi} \suppressligature{grafi}{graf|i} \suppressligature{lfful}{lf|ful} \suppressligature{fflink}{ff|link} \suppressligature{iflich}{if|lich} \suppressligature{uflauf}{uf|lauf} \suppressligature{ufform}{uf|form} \debugon shelfful cufflink unbegreiflich Auflaufform offen \end{document} As you can see, the code does not do any ligaturing at all (!) as that is handled by luaotload in the pre_linebreak_filter. However, this also creates a minor glitch: the added whatsits also prevent kerning at those spots, but they cannot be removed here because that would re-enable the ligatures once luaotload comes into play. I do not know enough of the internals of lualatex to ix this (minor) problem. Answer by topskip (too long for a comment) I have tried and tried, but I can’t ind a good solution. @michal.h21 has 774
tried with the ligaturing callback, but this, as he writes, fails when using complex rendering mode in LuaTeX. So I’ve tried to hook into the pre_linebreak_filter which has all ligatures in their place, but I have problems breaking the ligatures apart. Say for example you have a ligature i and want to suppress ligaturing between f and i. TeX (or the font subsystem) has already created the ligature when I am in the pre_linebreak_filter and you can break them apart, but only in a predeined way: in the word ”luiest” the second ligature is made of the ligature ”f” and ”i” thus it is ”i”. The ligature ”f” is, obviously, made of ”f” and ”f”. Now it would be easy to split at ”f|i” - I keep the f-ligature and insert a space before the ”i”. But to separate the ”i” at ”f|i” I would have to create a new ligature (”i”), but this is almost impossible (not technically, I could create the necessary data structures, but the logic how to create ligatures is in the font subsystem). Therefore the pre_linebreak_filter is not a good place to do the un-ligaturing. But if we move forward (towards the original input of TeX), it is impossible to parse the input and get all occurrences of the words: \documentclass{article} \begin{document} \newcommand\auflauf{Auflauf} \newcommand\form{form} \auflauf\form \end{document} The word is still ”ligatured” but you won’t be able to parse this with the method you want in your question. This leads to my result: it is not possible without hooking into the font subsystem (in this case luaotfload). Tags: ligatures (Prev Q) (Next Q)
775
Q: Ligature suppression algorithm fails if the word in question contains an Umlaut (dieresis) before the ligature Tags: ligatures (Prev Q) (Next Q) This is a follow-up posting prompted by Taco Hoekwater’s recent excellent answer to a question I posed a few months ago. It concerns the use of the ligature suppression algorithm for words (mainly, but not exclusively, Germanlanguage words) that contain Umlaute (diereses). Taking Taco’s MWE as the starting point (not reproduced below because it’s quite long), add the instructions
\suppressligature{lffach}{lf|fach} %% no f-ligature in words containing the string \suppressligature{rflich}{rf|lich} %% ditto for words containing the string "rflic \suppressligature{mpfflug}{mpf|flug} and the following six words (which all contain potential f-ligature glyphs): elffach Ḷwölffach %% ff ligature to be suppressed verwerflich dörflich %% fl ligature to be suppressed KampfflugḶeug DüsenkampfflugḶeug %% ffl ligature to be replaced with f-fl after \begin{document}. This results in the following output:
Notice that the three words which do not contain an Umlaut before the | ligature suppression point are treated correctly, i.e., the ff, fl, and ffl ligatures are broken up in the manner indicated by the applicable \suppressligature commands. In contrast, ligature suppression fails for the second set of three words -- apparently because they contain an Umlaut. This happens with words containing an ä Umlaut as well, by the way. Furthermore, I’ve determined that this problem only appears to happen with words that contain an Umlaut before the ligature suppression point. Words 776
that contain an Umlaut after the ligature suppression point indicated by a corresponding \suppressligature instruction are treated correctly. E.g., when supplying the instruction \suppressligature{uflös}{uf|lös}, the words auflösen and Auflösung are both rendered without the fl ligature. A word about my TeX setup: I mostly run TeXLive2011 and use TeXWorks as my editor program. However, the problem also occurs under MiKTeX2.9, with all the latest updates installed, and with WinEdt7.0 as the editor. Both editors are fully unicode-aware. Question: How does Taco’s code need to be edited/modiied to circumvent the problem(s) described in this posting? Tags: ligatures (Prev Q) (Next Q) User: mico Answer by taco-hoekwater The problem is that string.find returns a byte location, and in this case you want to have a character index when comparing nodes to strings. The solution is to replace table.insert(throwliga,{match,n,k}) with table.insert(throwliga,{prefix_length(f,match),n,k}) where prefix_length is deined like this: local prefix_length = function(word,byte) return unicode.utf8.len(string.sub(word,ḷ,byte)) end Which simply returns the length in characters of the preix of word that ends at byte. Note: This change only ixes the current problem, it does not solve cases where there are unicode characters inside the strings in the noliga table. Please do not ask me to write that as well, there should be some challenge left ;) 777
Tags: ligatures (Prev Q) (Next Q)
Q: How do I customize a LuaLaTeX cmap? Tags: ligatures (Prev Q) (Next Q) I’m working on a system that uses database content to produce PDFs in a variety of languages. I’m currently working on Armenian. What we’ve developed so far uses pdfLaTeX. I made a special encoding to handle Armenian and got it all working, only to discover that the ive ligatures in FreeSerif that had underscores in the glyph names ended up not being copyable or searchable. For example, copying the ligature glyph m_n_armenian ends up with ”mn,” and \pdfglyphtounicode doesn’t seem able to override the default behavior of treating the ASCII letters separated by underscores as being the desired target characters for copying and pasting. I explored using XeLaTeX, but found that colored footnotes spanning multiple pages lose their color on the second page. pdfcolfoot ixes this problem in pdfLaTeX, but the required color stacks aren’t available in XeLaTeX. Having just discovered that LuaLaTeX doesn’t have this limitation, I’m checking to see if it will do what I want it to do. Given that LuaLaTeX seems to be the successor to pdfLaTeX, we should probably move that direction if LuaLaTeX can do everything we need done. \documentclass[14pt]{memoir} \usepackage{fontspec} \setmainfont[Script=Armenian]{Freeserif} \pdfcompresslevel=ḷ \begin{document} \end{document}
778
The irst line of text above contains the ive Armenian ligatures in question, unicode characters FB13 through FB17. The second line are the total of ten characters that make up these ive ligatures, from the range 0500 to 05FF. Compiling this with LuaLaTeX, I end up with two lines of the ive ligatures displayed correctly. But when I copy and paste, I end up with two lines of ive ligatures, not the ten characters. I want to override this default behavior. I want the cmap in the PDF to specify:
instead of: But I can’t igure out how to alter the cmaps at all via LuaLaTeX. I’ve found http://www.luatex.org/svn/branches/0.70.x/source/texk/web2c/luatexdir/ font/tounicode.w but I’m not sure that the functions there are accessible via macros. I think I need to keep the content of the PDFs identical to the content of the database. Otherwise, someone may take content from the database and search for it within a PDF, and never be able to ind it since the ten characters when paired up are replaced by the ligature characters. What should I do? Can the cmaps be tinkered with via LuaLaTeX? I have a much more diicult language to work with next, and I think I’m going to need this level of control over the cmaps. Tags: ligatures (Prev Q) (Next Q) User: pickle Answer by pickle In the preamble, include: \usepackage{luacode}. \end{document}, include the following: 779
Just before
Skip code block
\begin{luacode*} tounicodevalues = { [64275] = "ḷ574ḷ576", [64276] = "ḷ574ḷ565", [64277] = "ḷ574ḷ56B", [64278] = "ḷ57Eḷ576", [64279] = "ḷ574ḷ56D", } for i,f in font.each() do if (string.match(f.name, "FreeSerif") and string.match(f.name, "script=arm for u, v in next, tounicodevalues do f.characters[u].tounicode = v end font.fonts[i] = f end end \end{luacode*} Why before \end{document}? Because you want to do this after LuaLaTeX already knows what all of the fonts are that it will actually be using. Why restrict the routine to certain matching fonts? This avoids the error of trying to change fonts that have already been accessed, such as line10, which is forbidden. This code could be wrapped in a TeX macro and placed in the preamble, and then called just before \end{document}. This example doesn’t use the luacode package: Skip code block \newcommand{\tounicode}[2][]{\directluaḷ{ tounicodevalues = { [64275] = "ḷ574ḷ576", [64276] = "ḷ574ḷ565", [64277] = "ḷ574ḷ56B", [64278] = "ḷ57Eḷ576", [64279] = "ḷ574ḷ56D", } 780
}}
for i,f in font.each() do if (string.match(f.name, "#1") and string.match(f.name, "#2")) then for u, v in next, tounicodevalues do f.characters[u].tounicode = v end font.fonts[i] = f end end
\begin{document} \tounicode[script=armn]{FreeSerif} \end{document} Using fontspec, I added the font feature, HyphenChar={1418}, which changes the hyphenation character to the Armenian hyphen. Doing so results in the altering-already-accessed-font error when using the above function, unless additional matching criteria is added using an optional argument such as ”script=armn.” To ind out what the font names are that you are trying to match, add the following code to the above function. for i,f in font.each() do texio.write_nl("["..i.."] => "..f.name) end Answer by graham-douglas LuaTeX’s mechanism for deining fonts ofers the following route to constructing the /ToUnicode entry. The following text is taken from section 7 Font structure (page 153 of the LuaTeX manual for beta 0.71.0): The usage of tounicode is this: if this font speciies a tounicode=1 at the top level, then LuaTEX will construct a /ToUnicode entry for the pdf font (or font subset) based on the character-level 781
tounicode strings, where they are available. If a character does not have a sensible Unicode equivalent, do not provide a string either (no empty strings). If the font-level tounicode is not set, then LuaTEX will build up /ToUnicode based on the TEX code points you used, and any character-level tounicodes will be ignored. At the moment, the string format is exactly the format that is expected by Adobe CMap iles (utf-16BE in hexadecimal encoding), minus the enclosing angle brackets. This may change in the future. Small example: the tounicode for a i ligature would be 00660069. Tags: ligatures (Prev Q) (Next Q)
Q: LuaTeX does not respect brace groups used for disabling ligatures Tags: ligatures (Prev Q) I noticed the following strange behavior of LuaTeX. I am not sure if it is intentional or not. The minimal example is, fi f{}i f{i} {f}i f\/i \bye (This is the complete document, plain TeX, thus no package or whatsoever to efect the results) Here is the pdfTeX output
782
Which is as expected. And here is the LuaTeX output
Grouping using curly braces appears to have no efect at all, i.e, it does not disable the use of ligatures. The log iles shows that both pdftex and luatex use exactly the same type1 fonts, as expected. So it is not a thing with handling of Opentype, which I initially suspected. Is this a bug (I think it is) or intended behavior of luatex? I am using the versions of pdftex and luatex from up-to-date TeXLive 2016 Tags: ligatures (Prev Q) User: yan-zhou Answer by egreg From the LuaTeX manual (version 0.95)
783
Using a kern is the only way, as far as I can see. Either \/ or \kernḷpt would do. Tags: ligatures (Prev Q)
Errors Skip to questions, Wiki by user martin-scharrer Error messages which mostly show (La)TeX code should be marked as a code block (indent with 4 spaces or the {} button), not as a quotation (>). Error messages which mostly show ile paths and no code, like File not found or similar errors, should be placed between and HTML tags to avoid wrong syntax highlighting. Otherwise in e.g. c:\localtexmf\latex the two directories would be highlighted as macros because of the preceding backslashes \. 784
Questions Q: Tex capacity exceeded compiling only 50 lines latex ile (pdftex), seg. fault (lualatex) Tags: errors (Prev Q) (Next Q), verbatim (Next Q) This is one of the strangest things I’ve seen in Latex (and I have seen many strange things). 50 lines of code, almost all of it is verbatim. Any small change to the verbatim can cause the error to go away. it seems random. I managed to get it to 50 lines verbatim and still show the error. But if I make small change, remove 2-3 lines or delete an empty line, the error could go away or it might stay. it is random. Here is the code: Skip code block \documentclass[11pt]{book}%ext \usepackage[T1]{fontenc} \usepackage{verbatim} \usepackage{amsmath,mathtools} \usepackage[utf8]{inputenc} %DO NOT USE WIT LUALATEX, only with pdflatex \usepackage{graphicx} \usepackage{breqn} %do not use this with tex4ht. added 4/2/16 \begin{document} \section{How to implement Steepest descent for finding minumum of $f(x,y)$ ?} function nma_problem_2() close all; del = ḷ.ḷ5; u1 = ḷ:del:2ḷ; u2 = -1ḷ:del:15; [u1,u2] = meshgrid(u1,u2); plot(ḷ,ḷ); xlim([ḷ 2ḷ]); ylim([-5 15]); 785
hold on; [u(1),u(2)] = ginput(1); t=text(1.ḷ8*u(1),u(2),sprintf('[%2.1f,%2.1f]',u(1),u(2))); t.FontSiḶe=8; t.Color='red'; x = fminsearch(@objectiveFunc, u); %used to find the minumum in order to show %progress towards it hold on; plot(x(1),x(2),'*r') plot(u(1),u(2),'or') MAX_ITER = 5ḷ; REL_TOL = 1ḷ^(-4); stepSiḶe = -1; %optimal [p,levelSets] = steepestDescentPoints(u,MAX_ITER,REL_TOL,stepSiḶe,... @objectiveFunc,@gradientFunc); [C,h] = contour(u1,u2,Ḷ,levelSets); %,'ShowText','on'); if length(p(:,1))>1 for k=1:length(p)-1 line([p(k,1),p(k+1,1)],[p(k,2),p(k+1,2)]); %draw line between each step drawnow; pause(.2); title(sprintf('starting from [%3.3f,%3.3f], f(u)=%3.3f, step = %d',... u(1),u(2),norm(objectiveFunc(u)),k)); end end \end{document} Please make sure not to modify the code before seeing the error, as any small change to the verbatim code, could mask the error away! I also put the above source as in this folder Here is the error Skip code block pwd /media/data/latex/standalone_2 786
pdflatex foo.tex This is pdfTeX, Version 3.14159265-2.6-1.4ḷ.16 (TeX Live 2ḷ15) (preloaded format=p restricted \write18 enabled. entering extended mode (./foo.tex LaTeX2e patch level 2 Babel and hyphenation patterns for 79 languages loaded. (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/book.cls Document Class: book 2ḷ14/ḷ9/29 v1.4h Standard LaTeX document class (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/bk11.clo)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/fontenc.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/t1enc.def)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/fancybox/fancybox.sty Style option: `fancybox' v1.4 (tvḶ) ) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix (tvḶ) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/graphics/keyval.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/mathtools/mathtools.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/tools/calc.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/mathtools/mhsetup.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/inputenc.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/utf8.def (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/t1enc.dfu) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/ot1enc.dfu) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/omsenc.dfu))) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/graphics/graphicx.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/graphics/graphics.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/graphics/trig.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/latexconfig/graphics.cfg) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/pdftex-def/pdftex.def 787
(/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/infwarerr.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/breqn/breqn.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/l3kernel/expl3.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/l3kernel/expl3-code.tex) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/l3kernel/l3pdfmode.def)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/breqn/flexisym.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/breqn/cmbase.sym) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/breqn/mathstyle.sty))) (./foo.aux ) (/usr/local/texlive/2ḷ15/texmf-dist/tex/context/base/supp-pdf.mkii [Loading MPS to PDF converter (version 2ḷḷ6.ḷ9.ḷ2).] ) (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/ifluatex.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/ifpdf.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/oberdiek/grfext.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/oberdiek/kvoptions.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/etexcmds.sty))) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/t1cmtt.fd) Overfull \hbox (75.69456pt too wide) in paragraph at lines 5ḷ--5ḷ []\T1/cmtt/m/n/1ḷ.95 x = fminsearch(@objectiveFunc, u); %used to find the minum um in order to show[] Overfull \hbox (3ḷ.4276pt too wide) in paragraph at lines 5ḷ--5ḷ []\T1/cmtt/m/n/1ḷ.95 [p,levelSets] = steepestDescentPoints(u,MAX_ITER,REL_TOL,s tepSiḶe,...[] Overfull \hbox (41.74434pt too wide) in paragraph at lines 5ḷ--5ḷ []\T1/cmtt/m/n/1ḷ.95 line([p(k,1),p(k+1,1)],[p(k,2),p(k+1,2)]); %draw line betw een each step[] Overfull \hbox (41.74434pt too wide) in paragraph at lines 5ḷ--5ḷ []\T1/cmtt/m/n/1ḷ.95 title(sprintf('starting from [%3.3f,%3.3f], f(u)=%3.3f, tep = %d',...[] 788
s
Underfull \vbox (badness 1ḷḷḷḷ) has occurred while \output is active ! TeX capacity exceeded, sorry [main memory siḶe=8ḷḷḷḷḷḷ]. ,->\leavevmode \kern \Ḷ@ \char `\, l.5ḷ \endverbatim} ! ==> Fatal error occurred, no output PDF file produced! Transcript written on foo.log. standalone_2> This that will go the error to go away: change the line \section{How to implement Steepest descent for finding minumum of $f(x,y)$ ?} to \section{How to implement Steepest descent for finding minumum of f ?} also delete the empty line after verbatim i.e. change \begin{verbatim} function nma_problem_2() to \begin{verbatim} function nma_problem_2() also remove the breqn package will remove the error. And many other little things like this. The error can go away by random. May be it is breqn fault again, I do not know. question is: How to resolve this error? What is causing it? TL 2015 on Linux. Error also shows on windows under miktex. btw, lualatex core dumps on this ile also Skip code block standalone_2>lualatex foo.tex This is LuaTeX, Version beta-ḷ.8ḷ.ḷ.1 (TeX Live 2ḷ15) (rev 5863) restricted \write18 enabled. (./foo.tex 789
LaTeX2e patch level 2 Babel and hyphenation patterns for 79 languages loaded. (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/book.cls Document Class: book 2ḷ14/ḷ9/29 v1.4h Standard LaTeX document class (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/bk11.clo)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/fontenc.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/t1enc.def)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/tools/verbatim.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/mathtools/mathtools.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/tools/calc.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/mathtools/mhsetup.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/inputenc.sty Package inputenc Warning: inputenc package ignored with utf8 based engines. ) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/graphics/graphicx.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/graphics/graphics.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/graphics/trig.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/latexconfig/graphics.cfg) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/pdftex-def/pdftex.def (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/infwarerr.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/ltxcmds.sty)))) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/breqn/breqn.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/l3kernel/expl3.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/l3kernel/expl3-code.tex) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/l3kernel/l3pdfmode.def)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/breqn/flexisym.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/breqn/cmbase.sym) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/breqn/mathstyle.sty))) (./foo.aux ) (/usr/local/texlive/2ḷ15/texmf-dist/tex/context/base/supp-pdf.mkii [Loading MPS to PDF converter (version 2ḷḷ6.ḷ9.ḷ2).] 790
) (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/ifluatex.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/ifpdf.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/luatex-loader.sty (/usr/local/texlive/2ḷ15/texmf-dist/scripts/oberdiek/oberdiek.luatex.lua))) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/oberdiek/grfext.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/oberdiek/kvoptions.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/oberdiek/etexcmds.sty))) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/t1cmtt.fd) Overfull \hbox (75.69456pt too wide) in paragraph at lines 28--28 [][]\T1/cmtt/m/n/1ḷ.95 x = fminsearch(@objectiveFunc, u); %used to find the min umum in order to show[] Overfull \hbox (3ḷ.4276pt too wide) in paragraph at lines 37--37 [][]\T1/cmtt/m/n/1ḷ.95 [p,levelSets] = steepestDescentPoints(u,MAX_ITER,REL_TOL ,stepSiḶe,...[] Overfull \hbox (41.74434pt too wide) in paragraph at lines 43--43 [][]\T1/cmtt/m/n/1ḷ.95 line([p(k,1),p(k+1,1)],[p(k,2),p(k+1,2)]); %draw line be tween each step[] Overfull \hbox (41.74434pt too wide) in paragraph at lines 46--46 [][]\T1/cmtt/m/n/1ḷ.95 title(sprintf('starting from [%3.3f,%3.3f], f(u)=%3.3f, step = %d',...[] Underfull \vbox (badness 1ḷḷḷḷ) has occurred while \output is active ! TeX capacity exceeded, sorry [node memory siḶe=38525875ḷ]. ,->\leavevmode \kern \Ḷ@ \char `\, l.49 end Segmentation fault Tags: errors (Prev Q) (Next Q), verbatim (Next Q) 791
User: nasser Answer by egreg The error is due to breqn, of course. Only one deinition for an active character can be valid at a given time. Since you have a math comma in the section title, this goes in the header and, with that long verbatim, it gets typeset when verbatim is active, which gives a diferent meaning to the active comma. Here’s a minimal example showing the issue. Skip code block \documentclass[11pt]{book} \usepackage{breqn} \setlength{\textheight}{2cm} % to shorten the input \begin{document} \section{$f(x,y)$} \begin{verbatim} x x x x x \endverbatim} \end{document} Here’s a ix to \do@noligs, which is responsible for deining a new meaning for active characters in verbatim. Skip code block \documentclass[11pt]{book} \usepackage{breqn} \makeatletter 792
\def\do@noligs#1{% \catcode`#1\active \begingroup\lccode`\~`#1\relax \lowercase{\endgroup \ifdefined~% \expandafter\def\expandafter~\expandafter{% \expandafter\relax \expandafter\ifmmode ~% in math mode use the meaning given by breqn \else \leavevmode\kern\Ḷ@\char`#1\relax \fi }% \else \def~{\leavevmode\kern\Ḷ@\char`#1}% \fi }% } \makeatother \setlength{\textheight}{2cm} \begin{document} \section{$f(x,y)$} \begin{verbatim} x x x x x \endverbatim} \end{document} Answer by david-carlisle The main problem is the breqn math comma being written to the mark used 793
in headings while verbatim is active. which gives a classic fragile command in moving argument cryptic error. \hbox hides this (a better ix allowing the comma to be used normally may be posted later) The fact that luatex segfaults after the runaway argument is a separate lower level bug (or not a bug). The code uses arbitrary amounts of memory as it is in an ininite loop, so in classic tex it hits a hard limit but luatex just allocates more and more memory until it runs out of memory of your actual hardware. Skip code block \documentclass[11pt]{book}%ext \usepackage[T1]{fontenc} \usepackage{verbatim} \usepackage{amsmath,mathtools} \usepackage[utf8]{inputenc} %DO NOT USE WIT LUALATEX, only with pdflatex \usepackage{graphicx} \usepackage{breqn} %do not use this with tex4ht. added 4/2/16
\begin{document} \section{How to implement Steepest descent for finding minumum of \begin{verbatim} function nma_problem_2() close all; del = ḷ.ḷ5; u1 = ḷ:del:2ḷ; u2 = -1ḷ:del:15; [u1,u2] = meshgrid(u1,u2); plot(ḷ,ḷ); xlim([ḷ 2ḷ]); ylim([-5 15]); hold on; 794
$f(x\hbox{,}y)$
[u(1),u(2)] = ginput(1); t=text(1.ḷ8*u(1),u(2),sprintf('[%2.1f,%2.1f]',u(1),u(2))); t.FontSiḶe=8; t.Color='red'; x = fminsearch(@objectiveFunc, u); %used to find the minumum in order to show %progress towards it hold on; plot(x(1),x(2),'*r') plot(u(1),u(2),'or') MAX_ITER = 5ḷ; REL_TOL = 1ḷ^(-4); stepSiḶe = -1; %optimal [p,levelSets] = steepestDescentPoints(u,MAX_ITER,REL_TOL,stepSiḶe,... @objectiveFunc,@gradientFunc); [C,h] = contour(u1,u2,Ḷ,levelSets); %,'ShowText','on'); if length(p(:,1))>1 for k=1:length(p)-1 line([p(k,1),p(k+1,1)],[p(k,2),p(k+1,2)]); %draw line between each step drawnow; pause(.2); title(sprintf('starting from [%3.3f,%3.3f], f(u)=%3.3f, step = %d',... u(1),u(2),norm(objectiveFunc(u)),k)); end end \endverbatim} \end{document} Tags: errors (Prev Q) (Next Q), verbatim (Next Q)
795
Q: After MiKTeX update when using LuaLaTeX: Package pgf Error: Driver ile “pgfsys-luatex.def” not found Tags: errors (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q), miktex (Prev Q) (Next Q), external-iles (Next Q) I just updated my MiKTeX instance to the latest packages and am using the LuaLaTeX compiler. Whenever a document relies on pgf I get the following error: ! Package pgf Error: Driver file ``pgfsys-luatex.def'' not found.. I found this Bug report, https://sourceforge.net/p/pgf/bugs/384/, where someone provides the missing ile (he simply renamed another driver and did little changes apparently), but this really doesn’t solve my problems. The missing ile error goes away with this driver, but for example setting aspectratio=169 as a beamer option is fully ignored while it worked perfectly ine with LuaLaTeX before the MiKTeX update. A minimal example would be: \documentclass{article} \usepackage{pgf} \begin{document} Compile me with lualatex.exe \end{document} With the driver from the linked bug report and the following MWE: \documentclass[aspectratio=169]{beamer} \begin{document} Foo \end{document} I only get the default Aspect Ratio of 4:3. Before the MiKTeX update I correctly got 16:9, even with LuaLaTeX. I tried purging and reinstalling MiKTeX. It did not help. How can I compile pgf-based documents with LuaLaTeX correctly again? 796
Tags: errors (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q), miktex (Prev Q) (Next Q), external-iles (Next Q) User: foo-bar Answer by engbird As an alternative to \RequirePackage{luatex85} I opted to try out the experimental miktex packages (enabled with the checkbox on the main screen of Update (Admin) for MikTeX as described and illustrated: http://miktex. org/kb/miktex-next). Then in order to ensure everything was successfully registered(?) I went to Settings (Admin) for MikTeX and on the ”General” tab, I clicked RefreshFNDB. Despite using the new experimental package of LuaTeX 0.95 I still had to copy the contents of https://sourceforge.net/p/pgf/bugs/_discuss/thread/ 44f8dcf2/9dc8/attachment/pgfsys-luatex.def to my texmf structure (I placed it in a secondary structure in texmf\tex and re-scanned the roots from Settings (Admin) for MikTeX on the ”Roots” tab. Tags: errors (Prev Q) (Next Q), tikz-pgf (Prev Q) (Next Q), miktex (Prev Q) (Next Q), external-iles (Next Q)
Q: why lualatex gives erorr ”Too many open iles” but pdlatex does not on same latex ile? Tags: errors (Prev Q) (Next Q) Using TL 2015 on Linux. I have a latex ile which includes graphics, all in pdf format. All the images are included using the call
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{rules/file_n There is a total of 1860 such images, all in pdf format.
797
When I compile this ile using lualatex, at some stage, when it gets to image number 1016, it fails with the error Too many open files. Compiling the same ile with pdlatex gives no error ! Is there a limitation on how images one can include in a latex ile when using lualatex or is this a bug? It looks like lualatex includegraphics version is not closing ile handles when loading images and running out of ile handles. This is on Linux mint 7.2. Since the ile is large. I have put the ile and the images it loads using \includegraphics in one zip ile (80 MB). The link is at the bottom of this post. To reproduce, please download the zip ile, unzip it using the command unḶip file.Ḷip and it will create a new folder called lualatex_error/ and inside this folder there is the one ile report.tex and the folder that includes all the images. Then typing lualatex report.tex will give the error lualatex: ./rules/1ḷ16.pdf: Too many open files From the report.log This is LuaTeX, Version beta-ḷ.8ḷ.ḷ (TeX Live 2ḷ15) (rev 5238) (format=lualatex 2ḷ15.7.9) 31 JUL 2ḷ15 12:28 restricted \write18 enabled. lualatex_error>which lualatex /usr/local/texlive/2ḷ15/bin/x86_64-linux/lualatex The zip ile is in this folder (This is a link to the folder where the zip ile is in. Not a direct link to the zip ile). 80 MB size. Any other information I can give please let me know. Tags: errors (Prev Q) (Next Q) User: nasser Answer by cfr 798
I can conirm this behaviour. To test: Create 1860 copies of example-image-1x1.pdf (or other image of your choosing) named 1.pdf, 2.pdf,..., 186ḷ.pdf. If you use bash and you have TeX Live 2015 installed in the standard place, you can use the following commands:
i=ḷ; while [ $i -le 186ḷ ] ; do ((i++)); cp /usr/local/texlive/current/texmf-dist/ Then create the following document: Skip code block
\documentclass{article} \usepackage{graphicx} \usepackage{expl3,xparse} \ExplSyntaxOn \int_new:N \l_nasser_loop_int \tl_new:N \l_nasser_file_tl \NewDocumentCommand \icing { } { \int_set:Nn \l_nasser_loop_int { ḷ } \int_do_while:nNnn { \l_nasser_loop_int } < { 186ḷ } { \int_incr:N \l_nasser_loop_int \tl_set:Nn \l_nasser_file_tl { \int_use:N \l_nasser_loop_int } \includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{\l_nasse } } \ExplSyntaxOff \begin{document} \icing \end{document} This compiles ine with pdflatex. With lualatex, it fails with the following error: lualatex: ./1ḷ24.pdf: Too many open files I will refrain from posting the output pdflatex produces: you will either have to take my word for it or follow the procedure above. 799
Tags: errors (Prev Q) (Next Q)
Q: MiKTeX’s LuaLaTeX and minitoc: ”I can’t write on ile ...mtc” Tags: errors (Prev Q) (Next Q), miktex (Prev Q) (Next Q) When compiling the code below with LuaLaTeX I get the error: ”I can’t write on ile ’test.mtc’”. Any ideas on how to resolve this? (Btw, the ile test.mtc is there and contains the word ”Contents”) Skip code block \documentclass{report} \usepackage{lipsum} \usepackage[tight]{minitoc} \dominitoc[n] \begin{document} \tableofcontents \chapter{Test} \minitoc \lipsum \section{Test} \lipsum \subsection{Test} \lipsum \subsubsection{Test} \lipsum \end{document} Tags: errors (Prev Q) (Next Q), miktex (Prev Q) (Next Q) User: wox 800
Answer by ulrike-ischer There is a lonely \closein\@inputcheck\relax in minitoc.sty which imho belongs in the deinition above it: Skip code block \documentclass{report} \usepackage{lipsum} \usepackage[tight]{minitoc} \makeatletter \def\mtc@CkFile#1{% \@mtc@LItrue\@mtc@FEtrue \if@mtc@checkfiles \IfFileExists{#1}{% \immediate\openin\@inputcheck #1\relax \mtc@While{}{\if@mtc@LI\relax}{\mtc@Body}\mtc@EndWhile % }% {\@mtc@FEtrue}% \else \@mtc@FEfalse% \fi \closein\@inputcheck\relax}%moved in the definition \makeatother \dominitoc[n] \begin{document} \tableofcontents \chapter{Test} \minitoc \lipsum \section{Test} \lipsum \subsection{Test} \lipsum 801
\subsubsection{Test} \lipsum \end{document} Tags: errors (Prev Q) (Next Q), miktex (Prev Q) (Next Q)
Q: How to place a dot below for example: e? Tags: errors (Prev Q) (Next Q), bugs (Next Q) After I updated my TL2016 (Windows) environment (10 minutes ago) compiling documents containing for example \d{e} or \d e throws an error message. The following MWE should demonstrate this: Skip code block \documentclass{book} \usepackage{fontspec} \usepackage[% main=english, ]{babel}% \begin{document} \chapter{How to place a dot below for example: e?} \d e The command throws the error messages:\\ Extra \textbackslash{}else. \textbackslash{}d e\\ Extra \textbackslash{}fi. \textbackslash{}d e \end{document} 802
Tags: errors (Prev Q) (Next Q), bugs (Next Q) User: latexfan Answer by david-carlisle Line 84 of latex/base/tuenc.def is \relax\detokeniḶe{#2}^^aḷ\else#2\fi Please edit to say \if\relax\detokeniḶe{#2}\relax^^aḷ\else#2\fi I’ll get an update to the release this evening, sorry. Tags: errors (Prev Q) (Next Q), bugs (Next Q)
Q: Who’s at fault with this error concerning csquotes and LuaLaTeX? Tags: errors (Prev Q) (Next Q) I ran into this with the package lilyglyphs but I’m not sure whose fault this error is. When I compile the following with lualatex: \documentclass{article} \usepackage{csquotes} \MakeOuterQuote{"} \EnableQuotes \begin{document} \directlua{print("hello")} \end{document} I get an error saying
803
\directlua]:1: unexpected symbol near '\'. l.6 \directlua{print("hello")} Now suppose that I do not directly write \directlua in my document, but I include a package that does it internally. Such as \documentclass{article} \usepackage{fontspec, csquotes, lilyglyphs} \MakeOuterQuote{"} \EnableQuotes \begin{document} \wholeNote \end{document} I have no knowledge why compilation fails, because the error now becomes ! Missing number, treated as Ḷero.
\begingroup l.7 \end {document} From my user point of view I did nothing wrong, because I’m using the public API provided by the packages. The csquotes documentation speciically says: Note that all characters are automatically checked for validity as they are allocated. This package will reject characters which are unsuitable as active quotes... In sum, the following characters will be considered as reserved by this package: A–Z a–Ḷ ḷ–9 . , ; : ! ? ' - # $ % & ^ _ ` ~ \ @ * { } [ ] So my question is whose fault is this error? • My fault, the user’s fault, because I should have known (but how?) that even though the quote is not listed as unsuitable in the csquotes manual, it actually is? • The fault of the implementation or documentation of csquotes for failing to mention " as unsuitable? • The fault of the implementation of the \directlua command because it doesn’t prevent LaTeX catcode changes/active characters from im804
pacting its argument? • A shortcoming of TeX itself because of its global state based architecture? Tags: errors (Prev Q) (Next Q) User: marczellm Answer by ulrike-ischer Your irst example and your second are actually quite diferent errors. The irst is your fault (see Davids answer), but the second is a bug in lilyglyphs lua code. But the problem is not the quote in \directlua. As the command is deined in lilyglyphs the catcode of the ” is frozen there and so not problematic. lilyglyphs uses tex.sprint to print the char, and the argument contains a ". As tex.sprint uses by default the current active catcode regime this explodes. You can tell tex.sprint to use another catcode table. (I’m not quite sure if \CatcodeTableLaTeX I used the best one, but it works): Skip code block \documentclass{article} \usepackage{fontspec, csquotes,lilyglyphs} %copied from lilyglyphs \begin{luacode} documentdata = documentdata or { } local stringformat = string.format local texsprint = tex.sprint local slot_of_name = luaotfload.aux.slot_of_name documentdata.fontchar = function (chr) local chr = slot_of_name(font.current(), chr, false) if chr and type(chr) == "number" then texsprint 805
(\the\CatcodeTableLaTeX, stringformat ([[\char"%X"]], chr)) end end \end{luacode} \MakeOuterQuote{"} \EnableQuotes \begin{document} \wholeNote \end{document} Answer by david-carlisle Sorry but since you ask, I’d say it was your fault:-) Having made a character active you should have known to make it safe before passing to Lua. For example: \documentclass{article} \usepackage{csquotes} \MakeOuterQuote{"} \EnableQuotes \begin{document} \directlua{print(\string"hello\string")} \end{document} See Ulrike’s answer for the second example. Tags: errors (Prev Q) (Next Q)
806
Q: How to raise a LaTeX warning from within Lua code? Tags: errors (Prev Q) (Next Q) I want to raise a warning from within Lua code. With advice from the LuaTeX wiki and LaTeX 2 for class and package writers, I arrived at the following (working) solution: \documentclass{article} \begin{document} Foo \directlua{ myvar = "\noexpand\\PackageWarning{mypackage}{Hello, I am a warning.}" tex.print(myvar) } \end{document} This seems unnecessarily complex, considering that raising an error is as easy as: \directlua{ tex.error("Hi, I'm an error!") } While I’m aware that tex.error is a generic TeX error and the warning I’m producing is a package-speciic warning, I still think for both generic LaTeX warnings (if that exists?) and package-speciic warnings (as well as package-speciic errors, probably), there should be an easier way. Is there one? Tags: errors (Prev Q) (Next Q) User: doncherry Answer by cybersingularity Someone who is more familiar with Lua will almost certainly have better ideas... egreg’s idea from the comments makes things slightly easier: consider using the [[...]] string syntax so you don’t need to escape the string (but 807
there will still be issues if the string itself contains a ]] etc), and use eTeX’s \unexpanded so you don’t need to worry so much about putting \noexpand everywhere. See also some of the suggestions about \directlua on a diferent question. As I previously mentioned in a comment, bypassing/emulating the LaTeX commands for this is probably not a good idea. LaTeX’s commands for this are slightly more complicated than you might irst think, and might get patched/hooked into. Even rewriting LaTeX in Lua (replacing eg \PackageWarning with something that invokes a Lua script/function) wouldn’t necessarily help in the latter situation. I think the best you could do would be to write your own Lua function that invokes LaTeX’s \PackageWarning, taking care to escape parameters etc as appropriate. (Sorry, I’m not proicient enough to attempt that.) Compare the terminal output from the following: Skip code block
\documentclass{article} \PackageWarningNoLine{mypackage}{Hello, I am a warning} \PackageWarning{mypackage}{Hello, I am a warning} \directlua{ texio.write_nl("term and log", [[\unexpanded{Package mypackage Warning: Hello, I a tex.print([[\unexpanded{\PackageWarning{mypackage}{Hello, I am a warning}}]]); } \begin{document} \end{document} I have used "term and log" here because (as egreg explained), LaTeX normally writes to an \@unused stream that is never open, so the output appears both on the terminal and in the log ile. The output is Package mypackage Warning: Hello, I am a warning. Package mypackage Warning: Hello, I am a warning on input line 3. 808
Package mypackage Warning: Hello, I am a warning. Package mypackage Warning: Hello, I am a warning on input line 1. Note also that the line numbers from the Lua version are wrong, even when the real \PackageWarning command is invoked. For reference, some relevant deinitions from latex.ltx: Skip code block \def\set@display@protect{\let\protect\string} \def\@spaces{\space\space\space\space} \ifnum\inputlineno=\m@ne \let\on@line\@empty \else \def\on@line{ on input line \the\inputlineno} \fi \DeclareRobustCommand{\GenericWarning}[2]{% \begingroup \def\MessageBreak{^^J#1}% \set@display@protect \immediate\write\@unused{^^J#2\on@line.^^J}% \endgroup } \def\PackageWarning#1#2{% \GenericWarning{% (#1)\@spaces\@spaces\@spaces\@spaces }{% Package #1 Warning: #2% }% } \def\PackageWarningNoLine#1#2{% \PackageWarning{#1}{#2\@gobble}% } Tags: errors (Prev Q) (Next Q)
809
Q: How to get csquotes, polyglossia with german and hyperref work together? Tags: errors (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q), hyperref (Prev Q) (Next Q) I found a strange problem which seems to be unique to the combination of polyglossia with german language together with csquotes and hyperref. Skip code block % XeLaTeX \documentclass{article} \usepackage{polyglossia} \setmainlanguage{german} \usepackage{csquotes} \MakeOuterQuote{"} \usepackage{hyperref} \begin{document} \section{Section with "quote"} "Quote in Text" \section{Section with \enquote{quote}} \enquote{Quote in Text} \end{document} Both, \enquote and the " shorthand, work ine in normal text but in section headings they cause this error (plus some following errors): ! Argument of " has an extra }.
\par l.16 \section{Section with \enquote{quote}} Theres no problem with \setmainlanguage{english} and with PDFLaTeX (and babel) it works too. 810
My workaround ist to use „quotes“ directly but it takes away the lexibility provided by csquotes. Update The following MWE with also following ile list still reproduces the error. Skip code block % XeLaTeX \documentclass{article} \usepackage{polyglossia} \setmainlanguage{german} \usepackage{csquotes} \MakeOuterQuote{"} \usepackage{hyperref} \begin{document} \section{Section with \enquote{quote}} \enquote{Quote in Text} \end{document} Skip code block *File List* article.cls siḶe1ḷ.clo polyglossia.sty etoolbox.sty etex.sty makecmds.sty xkeyval.sty xkeyval.tex fontspec.sty expl3.sty expl3-code.tex
2ḷḷ7/1ḷ/19 v1.4h Standard LaTeX document class 2ḷḷ7/1ḷ/19 v1.4h Standard LaTeX file (siḶe option) 2ḷ14/ḷ5/21 v1.33.5 Babel replacement for XeLaTeX and LuaTeX 2ḷ11/ḷ1/ḷ3 v2.1 e-TeX tools for LaTeX 1998/ḷ3/26 v2.ḷ eTeX basic definition package (PEB) 2ḷḷ9/ḷ9/ḷ3 v1.ḷa extra command making commands 2ḷ14/ḷ5/25 v2.7 package option processing (HA) 2ḷ14/ḷ5/25 v2.7 key=value parser (HA) 2ḷ14/ḷ6/21 v2.4a Font selection for XeLaTeX and LuaLaTeX 2ḷ14/ḷ9/15 v5423 L3 programming layer (loader) 2ḷ14/ḷ9/15 v5423 L3 programming layer 811
l3unicode-data.def 2ḷ14/ḷ8/12 v5276 L3 Unicode data l3xdvipdfmx.def xparse.sty 2ḷ14/ḷ9/15 v5423 L3 Experimental document command parser fontspec-patches.sty 2ḷ14/ḷ6/21 v2.4a Font selection for XeLaTeX and LuaLaTe X fontspec-xetex.sty 2ḷ14/ḷ6/21 v2.4a Font selection for XeLaTeX and LuaLaTeX fontenc.sty eu1enc.def 2ḷ1ḷ/ḷ5/27 vḷ.1h Experimental Unicode font encodings eu1lmr.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern xunicode.sty 2ḷ11/ḷ9/ḷ9 vḷ.981 provides access to latin accents and many oth er characters in Unicode lower plane eu1lmss.fd 2ḷḷ9/1ḷ/3ḷ v1.6 Font defs for Latin Modern graphicx.sty 2ḷ14/ḷ4/25 v1.ḷg Enhanced LaTeX Graphics (DPC,SPQR) graphics.sty 2ḷḷ9/ḷ2/ḷ5 v1.ḷo Standard LaTeX Graphics (DPC,SPQR) trig.sty 1999/ḷ3/16 v1.ḷ9 sin cos tan (DPC) graphics.cfg 2ḷ1ḷ/ḷ4/23 v1.9 graphics configuration of TeX Live xetex.def 2ḷ14/ḷ7/25 v4.ḷ3 LaTeX color/graphics driver for XeTeX (RRM/JK) fontspec.cfg ifluatex.sty 2ḷ1ḷ/ḷ3/ḷ1 v1.3 Provides the ifluatex switch (HO) ifxetex.sty 2ḷ1ḷ/ḷ9/12 vḷ.6 Provides ifxetex conditional gloss-german.ldf polyglossia: module for german babelsh.def 2ḷ13/ḷ4/3ḷ Babel common definitions for shorthands Taken verbatim from babel.def (2ḷ13/ḷ4/15 v3.9e) csquotes.sty 2ḷ11/1ḷ/22 v5.1d context-sensitive quotations csquotes.def 2ḷ11/1ḷ/22 v5.1d csquotes generic definitions csquotes.cfg hyperref.sty 2ḷ12/11/ḷ6 v6.83m Hypertext links for LaTeX hobsub-hyperref.sty 2ḷ12/ḷ5/28 v1.13 Bundle oberdiek, subset hyperref (HO) hobsub-generic.sty 2ḷ12/ḷ5/28 v1.13 Bundle oberdiek, subset generic (HO) hobsub.sty 2ḷ12/ḷ5/28 v1.13 Construct package bundles (HO) infwarerr.sty 2ḷ1ḷ/ḷ4/ḷ8 v1.3 Providing info/warning/error messages (HO) ltxcmds.sty 2ḷ11/11/ḷ9 v1.22 LaTeX kernel commands for general use (HO) ifvtex.sty 2ḷ1ḷ/ḷ3/ḷ1 v1.5 Detect VTeX and its facilities (HO) intcalc.sty 2ḷḷ7/ḷ9/27 v1.1 Expandable calculations with integers (HO) ifpdf.sty 2ḷ11/ḷ1/3ḷ v2.3 Provides the ifpdf switch (HO) etexcmds.sty 2ḷ11/ḷ2/16 v1.5 Avoid name clashes with e-TeX commands (HO) kvsetkeys.sty 2ḷ12/ḷ4/25 v1.16 Key value parser (HO) 812
kvdefinekeys.sty 2ḷ11/ḷ4/ḷ7 v1.3 Define keys (HO) pdftexcmds.sty 2ḷ11/11/29 vḷ.2ḷ Utility functions of pdfTeX for LuaTeX (HO) pdfescape.sty 2ḷ11/11/25 v1.13 Implements pdfTeX's escape features (HO) bigintcalc.sty 2ḷ12/ḷ4/ḷ8 v1.3 Expandable calculations on big integers (HO) bitset.sty 2ḷ11/ḷ1/3ḷ v1.1 Handle bit-vector datatype (HO) uniquecounter.sty 2ḷ11/ḷ1/3ḷ v1.2 Provide unlimited unique counter (HO) letltxmacro.sty 2ḷ1ḷ/ḷ9/ḷ2 v1.4 Let assignment for LaTeX macros (HO) hopatch.sty 2ḷ12/ḷ5/28 v1.2 Wrapper for package hooks (HO) xcolor-patch.sty 2ḷ11/ḷ1/3ḷ xcolor patch atveryend.sty 2ḷ11/ḷ6/3ḷ v1.8 Hooks at the very end of document (HO) atbegshi.sty 2ḷ11/1ḷ/ḷ5 v1.16 At begin shipout hook (HO) refcount.sty 2ḷ11/1ḷ/16 v3.4 Data extraction from label references (HO) hycolor.sty 2ḷ11/ḷ1/3ḷ v1.7 Color options for hyperref/bookmark (HO) auxhook.sty 2ḷ11/ḷ3/ḷ4 v1.3 Hooks for auxiliary files (HO) kvoptions.sty 2ḷ11/ḷ6/3ḷ v3.11 Key value format for package options (HO) pd1enc.def 2ḷ12/11/ḷ6 v6.83m Hyperref: PDFDocEncoding definition (HO) hyperref.cfg 2ḷḷ2/ḷ6/ḷ6 v1.2 hyperref configuration of TeXLive url.sty 2ḷ13/ḷ9/16 ver 3.4 Verb mode for urls, etc. hxetex.def 2ḷ12/11/ḷ6 v6.83m Hyperref driver for XeTeX puenc.def 2ḷ12/11/ḷ6 v6.83m Hyperref: PDF Unicode definition (HO) stringenc.sty 2ḷ11/12/ḷ2 v1.1ḷ Convert strings between diff. encodings (HO) rerunfilecheck.sty 2ḷ11/ḷ4/15 v1.7 Rerun checks for auxiliary files (HO) t3cmr.fd 2ḷḷ1/12/31 TIPA font definitions nameref.sty 2ḷ12/1ḷ/27 v2.43 Cross-referencing by name of section gettitlestring.sty 2ḷ1ḷ/12/ḷ3 v1.4 Cleanup title references (HO) csquotes-section.out csquotes-section.out se-ascii-print.def 2ḷ11/12/ḷ2 v1.1ḷ stringenc: Printable ASCII characters *********** Tags: errors (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q), hyperref (Prev Q) (Next Q) User: tobi Answer by egreg The quoting mechanism using " conlicts with the Babel shorthands that 813
German polyglossia sets up. This actually happens also with pdflatex and babel, where the " used for quoting simply kills the babel shorthands without warning. So the method can be recommended neither with babel nor with polyglossia. If you really don’t need the shorthands, do \usepackage{polyglossia} \setmainlanguage{german} \shorthandoff{"} \usepackage{csquotes} \MakeOuterQuote{"} Tags: errors (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q), hyperref (Prev Q) (Next Q)
Q: Outputile generated on error Tags: errors (Prev Q) (Next Q) If I run this example: \documentclass{article} \begin{document} Foo \newpage \barbaḶ \end{document} using lualatex --halt-on-error minimal.tex The log yields: !
==> Fatal error occurred, no output PDF file produced!
814
However, a ile minimal.pdf is created (although I cannot open it). This seems to occur due to the irst page being written. This confuses my buildsystem. pdlatex does not create such a ile. How do I switch lualatex to the expected behavior? Is this a bug? Tags: errors (Prev Q) (Next Q) User: choeger Answer by akira-kakuto There was a bug in pdfgen.w, that the condition to remove a broken pdf in the case of a fatal error was wrong. Thus the broken pdf was not removed. As an answer, we have to wait for the next release, or have to build a new binary ourselves by using sources which will be updated soon. Tags: errors (Prev Q) (Next Q)
Q: l3names error in lualatex (\reserveinserts{32}) Tags: errors (Prev Q) I have the following ’test ile’ in which I am working, works without problems when compiling with ’(La/Xe/pdf) TeX’ but throws an error when compiling with ’LuaLaTeX’: Skip code block Package: l3names 2ḷ12/ḷ9/24 v423ḷ L3 Namespace for primitives ) Runaway argument? ! Forbidden control sequence found while scanning use of \next.
\par l.66 \reserveinserts 815
{32} I suspect you have forgotten a `}', causing me to read past where you wanted me to stop. I'll try to recover; but if the error is serious, you'd better type `E' or `X' now and fix your file. the ile is as follows: Skip code block
\documentclass{article} \usepackage{soulutf8} \usepackage[math]{blindtext} \usepackage{xwatermark} %\usepackage[verbose=silent]{microtype} \usepackage{xcolor} \usepackage{ifpdf,ifluatex,ifxetex} \newif\ifxetexorluatex \ifxetex \xetexorluatextrue \else \ifluatex \xetexorluatextrue \else \xetexorluatexfalse \fi \fi \ifxetexorluatex \usepackage[no-math]{fontspec} \setmainfont[Ligatures=TeX,RawFeature=+onum]{Linux Libertine O} \setsansfont[RawFeature=+pnum]{Linux Biolinum O} \newfontfamily{\biolinum}{Linux Biolinum O} \newcommand{\bitext}[1]{\biolinum #1}% \newwatermark[allpages,fontsiḶe=2.ḷcm,align=center,color=gray!45,angle=45,xpos \else \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{fourier} \usepackage[rm]{libertine} 816
\renewcommand{\sfdefault}{LinuxBiolinumO-LF} \newwatermark[allpages,color=gray!45,angle=45,fontfamily=LinuxBiolinumO-OsF,sc
\fi \begin{document} \sodef\textss{}{.3em}{ḷ.6em}{ḷpt} \noindent \begin{center} \textbf{\textss{\large\scshape «Universidad de Concepci\'{o}n»}} \end{center} \Blinddocument \end{document} Use ’TexLive 2012’ in Win32/Linux (updated). Check the documentation of l3names, but it is a ’little’ advanced for my level, any suggestions or help would be appreciated. regards Pablo Tags: errors (Prev Q) User: pablo-gonzález-l Answer by heiko-oberdiek A minimal example would have been: \documentclass{article} \usepackage{xwatermark} \usepackage{fontspec} \begin{document} \end{document} After analysis the example becomes: \RequirePackage{catoptions}% loaded by xwatermark \outer\def\foo{}% outer macro as \reserveinserts \RequirePackage{capt-of}% package does not matter \foo \csname @@end\endcsname % end of job, after the error Or \RequirePackage{catoptions} 817
\outer\def\foo{} \makeatletter \ifnextcharTF[{\typeout{yes}}{\typeout{no}}\foo \@@end After \RequirePackage[options]{package} there is an additional optional argument for a minimal requested release date. These macros are redeined by package catoptions. However the test for an optional [ not only uses the usual \futurelet, but the next token is also read in as macro argument (\cpt@ifn@xtcharacter). That fails if the next token is an outer macro. Workaround: \documentclass{article} \usepackage{xwatermark}% or catoptions \makeatletter \let\org@cpt@ifbrack\cpt@ifbrack \renewcommand*{\cpt@ifbrack}{\@ifnextchar[} \makeatother ... Answer by ahmed-musa Thanks to Heiko. I will upload an update of catoptions to CTAN. In the meantime here is a patch. The problem wasn’t due to a bug: \outer is an odd type that I didn’t foresee could appear. Master Heiko knows why I am rather wary of LaTeX kernel’s \@ifnextchar. Skip code block \documentclass{article} \usepackage{xwatermark} \makeatletter % Copy this to end of catoptions: \edef\if@let@token@isouter{% \unexpanded{\expandafter\if@let@token@isouter@a\meaning\@let@token}% \detokeniḶe{outer macro}:\cpt@nil } \edef\reserved@a{% \def\noexpand\if@let@token@isouter@a##1\detokeniḶe{outer macro}:##2\cpt@nil 818
} \reserved@a{\@nameuse{@\ifblankTF{#2}{second}{first}oftwo}} \def\cpt@ifnextcharacter#1#2#3{% \ifcaseḷ% \ifcat\noexpand\@let@token\bgroup 1\fi \ifcat\noexpand\@let@token\egroup 1\fi \if@let@token@isouter{1}{ḷ}\relax \let\next\cpt@ifn@xtcharacter \else \def\next{\endgroup\cpt@ifnextchar}% \fi \next{#1}{#2}{#3}% } % End of patch. \makeatother \usepackage{soulutf8} \usepackage[math]{blindtext} \usepackage{xcolor} \usepackage{ifpdf,ifluatex,ifxetex} \newif\ifxetexorluatex \ifcaseḷ\ifxetex\else\ifluatex\else 1\fi\fi\relax\xetexorluatextrue\fi \ifboolTF{xetexorluatex}{% \usepackage[no-math]{fontspec} \setmainfont[Ligatures=TeX,RawFeature=+onum]{Linux Libertine O} \setsansfont[RawFeature=+pnum]{Linux Biolinum O} \newfontfamily{\biolinum}{Linux Biolinum O} \newcommand{\bitext}[1]{\biolinum #1}% \newwatermark[allpages,fontsiḶe=2.ḷcm,align=center,color=gray!45, angle=45,xpos=ḷ,ypos=ḷ]{\textbf{\bitext{Preliminar 2ḷ12}}} }{% \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{fourier} % There is a problem with the option 'rm' for libertine: % \usepackage[rm]{libertine} \usepackage{libertine} \renewcommand{\sfdefault}{LinuxBiolinumO-LF} \newwatermark[allpages,color=gray!45,angle=45, 819
}%
fontfamily=LinuxBiolinumO-OsF,scale=2.5,xpos=ḷ,ypos=ḷ]{Preliminar 2ḷ12}
\begin{document} \sodef\textss{}{.3em}{ḷ.6em}{ḷpt} \begin{center} \textbf{\textss{\large\scshape «Universidad de Concepci\'{o}n»}} \end{center} \noindent\Blinddocument \end{document} Here is a fuzz: \outer\def\foo{} \iftrue\ifnextcharTF*\relax\relax\foo\fi \iftrue\ifnextcharTF*\relax\relax\fi \ifnextcharTF*\relax\relax\iftrue\fi Tags: errors (Prev Q)
Microtype Skip to questions, Wiki by user n.n. microtype is a package that provides a LaTeX interface to the microtypographic extensions that were introduced by pdfTeX and have since also propagated to LuaTeX and XeTeX: most prominently, character protrusion and font expansion, furthermore the adjustment of interword spacing and additional kerning, as well as hyphenatable letterspacing (tracking) and the possibility to disable all or selected ligatures.
820
Questions Q: How to set expansion and protrusion for TeX Gyre Pagella using LuaLaTeX? Tags: microtype (Prev Q) (Next Q), protrusion (Prev Q) (Next Q) For my documents, I have often used the mathpaḶo package combined with microtype and have found the result to be really good. Because now I need to create PDFs which contain a variety of diacritics and which should be easy to copy from, I have decided to use LuaTeX with TeX Gyre Pagella. Initially I had diiculty getting microtype to work, but thanks to Alabay’s answer in How to set-up LuaTeX, Microtype, with Minion Pro, Myriad Pro I have made it. Still, I’m struggling with protrusion settings. Given the following code: Skip code block \documentclass[a4paper, 12pt, oneside, article]{memoir} \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \newfontfeature{Microtype}{protrusion=default;expansion=default;} \setmainfont[Microtype,Numbers=OldStyle]{TeX Gyre Pagella} \usepackage{microtype} \usepackage{blindtext} \begin{document} \blindtext \end{document}
821
LuaTeX produces this: I must say I don’t quite like the fact that the punctuation marks protrude so far from the margin. Is there a way I can change the default settings? I have tried to do this in various ways (e.g. by changing factor in microtype), but to no success. Ideally, I would like to get a similar result as when I run pdfTeX with mathpaḶo:
Another (but related) thing is setting expansion for TeX Gyre Pagella. Can 822
I do it, and if so, how? Tags: microtype (Prev Q) (Next Q), protrusion (Prev Q) (Next Q) User: jemp Answer by ulrike-ischer You can change the default factor like this (5 is not a sensible value but shows the efect quite good: Skip code block \documentclass[a4paper, 12pt, oneside, article]{memoir} \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \newfontfeature{Microtype}{protrusion=default;expansion=default;} \directlua{fonts.protrusions.setups.default.factor=5} \setmainfont[Microtype,Numbers=OldStyle]{TeX Gyre Pagella} \usepackage{microtype} \usepackage{blindtext} \begin{document} \blindtext \end{document} For a more ine grained change you should copy the default table from otfl-font-dum.lua (fonts.protrusions.setups['default']). Move it to e.g. prottest.lua, change default to test, adapt the values and then use it like this: \directlua{require("prottest.lua");} \newfontfeature{Microtype}{protrusion=test;expansion=default;} (I didn’t test this recently so I’m not sure if this still works.) Tags: microtype (Prev Q) (Next Q), protrusion (Prev Q) (Next Q)
823
Q: hanging punctuation with microtype and luaLaTeX Tags: microtype (Prev Q) (Next Q)
I want to get this style of hanging punctuation: Quotation marks «...» „...“, brackets (...) [...] {...} and bullets are put beyond the left margin. Quotation marks, brackets, periods, and commas are set outside the right margin. Hyphens (both in compound words and between the syllables of a word that’s divided at the end of a line) should not fall outside the margin full-length, but rather be hung one third or half of their length. I try to achieve this by using the \SetProtrusion command according to the manual (page 12): Skip code block
% !TeX encoding = UTF-8 % !TeX TS-program = lualatex \documentclass[a4paper,14pt]{extarticle} \usepackage[russian]{babel} \usepackage{fontspec} \usepackage{xltxtra} \usepackage{csquotes} \defaultfontfeatures{Renderer=Basic,Mapping=tex-text,Scale=MatchLowercase} \setmainfont{Charis SIL}[Mapping=tex-text,Scale=MatchLowercase] \setromanfont{Charis SIL}[Mapping=tex-text,Scale=MatchLowercase] \setsansfont{PT Sans}[Mapping=tex-text,Scale=MatchLowercase] \setmonofont{PT Mono}[Mapping=tex-text,Scale=MatchLowercase] \usepackage[protrusion=true,expansion=true,final,babel=true,factor=2ḷḷḷ]{microtype \SetProtrusion {encoding = *} 824
{
}
\textquotedblleft = {4ḷḷḷ, }, \textquotedblright = { ,4ḷḷḷ}, . = { , 4ḷḷḷ} « = {4ḷḷḷ, }, » = { ,4ḷḷḷ}, ( = {4ḷḷḷ, }, ) = { ,4ḷḷḷ}
\begin{document} \noindent\enquote{ , ) ( ! . ...) « , , ( ) ( ! . ...) \end{document} But it doesn’t work:
(If it matters, I use LuaLaTeX from MikTeX on Windows 7) Tags: microtype (Prev Q) (Next Q) User: max Answer by robert 825
Your settings are never applied because in the irst argument to \SetProtrusion you only specify the encoding. microtype will always try to load the best matching settings, and since settings for Charis SIL exist, they will be applied instead. Drawing from this answer, you can overwrite settings by irst loading the coniguration ile and then redeining these settings: Skip code block \usepackage[protrusion=true,expansion=true,final,babel=true]{microtype} % default \LoadMicrotypeFile{CharisSIL} \SetProtrusion [ name = Charis-default ] { } { \textquotedblleft = {1ḷḷḷ, }, \textquotedblright = { ,1ḷḷḷ}, \quotedblbase = {1ḷḷḷ, }, % = „ . = { , 1ḷḷḷ}, % there was a comma missing here {,} = { , 1ḷḷḷ}, % this comma needs to be masked « = {1ḷḷḷ, }, » = { ,1ḷḷḷ}, ( = {1ḷḷḷ, }, ) = { ,1ḷḷḷ}, - = { ,5ḷḷ} } For the other shapes, you can then simply load these settings: \SetProtrusion [ name = Charis-it, load = Charis-default ] {}{} \SetProtrusion [ name = Charis-sc, load = Charis-default ] {}{} (I must say that I ind these settings weird, since they are contrary to the idea that microtypographical tweaks should be discreet and not jump out at 826
the reader – as elaborated here) Tags: microtype (Prev Q) (Next Q)
Q: How can I ix a problem where italics prevent line breaking when using microtype? Tags: microtype (Prev Q) (Next Q), protrusion (Prev Q) (Next Q) I wish to use protrusion and expansion from microtype as I like the look you get with them. I use amsthm and typeset theorems in italic as usual (with \theoremstyle{plain}). With microtype enabled, LaTeX fails to break some lines where the last item on the line is something in italic. I get three failures to break nicely with my included example. I have microtype 2.5 and use lualatex with Latin Modern Roman. I have a working example, though it’s not very minimal. If I remove much more the ancillary changes to formatting hide the problem I suspect is a bug. The issue doesn’t seem to be with the fact I’m using hyphenated words like Erdos-Hajnal, since the line break failure also occurs on other lines, and problems even occur in my bibliography where some portions of the reference text are in italics. The problem also occurs for me if I remove the \usepackage{fontspec} line. If I remove that line and compile with pdlatex there are no problems. (Fairly) Minimal Example: Skip code block \documentclass[a4paper,twoside]{scrartcl} \usepackage[UKenglish]{babel} \usepackage{amsmath,amsthm} \usepackage{fontspec,blindtext} \usepackage[babel,protrusion=true,expansion]{microtype} \theoremstyle{plain} 827
\newtheorem{thm}{Theorem}[section] \newtheorem{prop}[thm]{Proposition} \newtheorem{conj}[thm]{Conjecture}
\begin{document} \begin{conj} For all graphs $H$ there is an $\epsilon > ḷ$ such that for all sufficiently large \end{conj} \begin{prop} A short dummy paragraph.
Let $\epsilon_2=\delta\epsilon_1$, where $\deltafor /F "usebackq" %f in (`kpsewhich hyph-de-19ḷ1.lic.txt`) do more "%f" on the command-line. Note the backquotes surrounding the kpsewhich calls! Answer by topskip I’ve got no error when compiling with LuaTeX, but hyphsubst doesn’t seem to work with LuaTeX. You can verify by running the following document with LuaTeX: \RequirePackage[german=ngerman-x-latest]{hyphsubst} \documentclass{minimal} \usepackage[german]{babel} \begin{document} \showhyphens{Meister} \end{document} It should report Meis-ter but reports Mei-ster. With luatex -recorder test.tex you can look into the generated .fls ile and see that only the ile hyph-de-19ḷ1.pat.txt gets loaded. Answer by egreg hyphsubst simply changes the number associated to the control sequence that LaTeX uses when choosing a language.
872
For instance \selectlanguage{ngerman} executes, among other things, \language\l@ngerman and \l@ngerman is deined at format creation to be the number "1E (on my machine, it can vary according to the language.dat ile). The number corresponding to ngerman-x-latest is (on my machine) "4. When one says \RequirePackage[german=ngerman-x-latest]{hyphsubst} the basic action is to change the meaning of \l@ngerman into "4; more precisely, the action is \chardef\l@ngerman=\csname l@ngerman-x-latest\endcsname Of course, if the languages are not preloaded, as it happens with LuaLaTeX, this can’t work (precautions are taken in the package so as a correct assignment is performed even if the meaning of \csname l@ngerman-x-latest\endcsname was \relax). That’s why we end with the patterns for English, I guess. A possible step towards a solution Apparently, LuaLaTeX knows about the correct numbers, so what’s needed is to force loading the correct language. A test: Skip code block \documentclass{article} %% print the numbers \typeout{ngerman: \number\csname l@ngerman\endcsname} \typeout{ngerman-x-latest: \number\csname l@ngerman-x-latest\endcsname} \usepackage{hyphsubst} \usepackage[ngerman]{babel} \begin{document}
873
\typeout{Current language: \number\language} \HyphSubstLet{ngerman}{ngerman-x-latest} \typeout{Current language: \number\language} \end{document} The relevant part of the log ile shows ngerman: 3ḷ ngerman-x-latest: 4 [...] Current language: 3ḷ Current language: 4 so the value of \language seems to be correctly set. However the .fls ile reports only
INPUT /usr/local/texlive/2ḷ11/texmf-dist/tex/generic/hyph-utf8/patterns/txt/hyph-d INPUT /usr/local/texlive/2ḷ11/texmf-dist/tex/generic/hyph-utf8/patterns/txt/hyph-d INPUT /usr/local/texlive/2ḷ11/texmf-dist/tex/generic/hyph-utf8/patterns/txt/hyph-d which seems to mean that the hyphenation patterns for ngerman-x-latest are not loaded. I’ve tried to add something like %% Load the new language \setboxḷ=\vbox{ \everypar{}\begin{hyphenrules}{ngerman-x-latest}abc\end{hyphenrules} } in the preamble or in the document, in order to see if the patterns are loaded, but this doesn’t seem so. Tags: hyphenation (Prev Q) (Next Q)
874
Q: How to avoid a linebreak before a comma in Lua(La)TeX? Tags: hyphenation (Prev Q) (Next Q) This is a (somewhat late) follow up to the question How to avoid a linebreak before a comma? where @MostlyHarmless shows that a line break may be introduced after a word ending with a hyphen even if it is followed by a comma. In the comments section of that question @topskip says: If you use LuaTeX, we could provide you a solution that forbids a line break before a comma. So here I’d like to ind a solution in Lua(La)TeX. The MWE to work with is the same: \documentclass[11pt, a4paper]{scrartcl} \usepackage[ngerman]{babel} \begin{document}
aaDas ist ein AbsatḶ. Das ist ein AbsatḶ. Das ist ein AbsatḶ. Es gibt Ḷeit-, tempe \end{document}
And the output is the same as well: Tags: hyphenation (Prev Q) (Next Q) User: georgd Answer by michal.h21 You can use simple node processing callback to do that. I’ve created simpl package containg such callback, hyphencomma.sty: Skip code block \ProvidesPackage{hyphencomma} 875
\RequirePackage{luacode}
\begin{luacode*} local glyph_id = node.id "glyph" local penalty_id = node.id "penalty" local hyphenc = string.byte "-" local commac = string.byte "," local function prevent_hyphencomma(head) for n in node.traverse_id(glyph_id,head) do if n.char == hyphenc then -- we need to find node after the next node. directly following is automatic local next = n.next.next if next.id == glyph_id and next.char == commac then -- create penalty node local penalty = node.new("penalty") penalty.penalty = 1ḷḷḷḷ -- remove discretionary head = node.remove(head,n.next) -- insert penalty head = node.insert_after(head, n, penalty) end end end return head end
luatexbase.add_to_callback("pre_linebreak_filter", prevent_hyphencomma, "Prevent h \end{luacode*} \endinput The prevent_hypencomma function processes nodes of each paragraph before the linebreak. There are many node types, but most important for are glyph nodes, which contains particular characters. To match nodes of this type, we must know it’s node id, which we can ind with: 876
local glyph_id = node.id "glyph" with node.traverse_id iterator, we process the node list, iltering only nodes with glyph id. Each node has some ields, depending on its type. We can ind glyphs character code with char ield. It is character number, not string, so we must test for hyphen char code, not -. For ASCII characters, we can get the char code with string.byte function. After each hyphen glyph, discretionary node is inserted, so we need to skip it to ind next node and test it whether it is comma glyph. If it is, we must remove the discretionary node and insert penalty to prevent the linebreak. The result:
Tags: hyphenation (Prev Q) (Next Q)
Q: Latin text not hyphenated at all with LuaLaTeX and polyglossia Tags: hyphenation (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q) I recently noticed that there are numerous under- and overfull hboxes in the document I’m working on. Further inspection revealed that such problems almost always arose when there was Latin text involved; seemingly, LaTeX doesn’t see any hyphenation points, so it can’t break lines and paragraphs end up looking ugly. This is a MWE: Skip code block \documentclass{article}
877
\usepackage{polyglossia} \setdefaultlanguage{english} \setotherlanguage[variant=classic]{latin} \begin{document} \showhyphens{\textenglish{amusing}} \showhyphens{\textlatin{instigare}} \end{document} Compiling this code with LuaLaTeX yields a log ile; here are the relevant fragments: [][] \EU2/lmr/m/n/10 amus-ing [][] \EU2/lmr/m/n/10 instigare Omitting the variant option of the Latin language (variant=classic) does not change the result. I have left out some things, such as the font setup, which, from what I have seen in my investigations, is involved in the matter (don’t know why, though). However, I hope the example provided is enough — if it isn’t, please, ask. For the record, this question seems somewhat relevant, although I haven’t been able to extrapolate the results to my case. EDIT: This is another MWE aimed at XeLaTeX, under which -as pointed out by egreg- it seems to work: Skip code block \documentclass{article} \usepackage{polyglossia} \usepackage{xltxtra} \setdefaultlanguage{english} \setotherlanguage[variant=classic]{latin} \begin{document} \showhyphens{\textenglish{amusing}} \showhyphens{\textlatin{instigare}} 878
\end{document} In the corresponding log ile: \EU1/lmr/m/n/10 amus-ing []\EU1/lmr/m/n/10 in-sti-gare Tags: hyphenation (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q) User: kalrish Answer by egreg It’s a bug in gloss-latin.ldf that doesn’t advertise the pattern ile name for LuaLaTeX. Workaround: do it yourself. Skip code block \documentclass{article} \usepackage{polyglossia} \setdefaultlanguage{english} \setotherlanguage[variant=classic]{latin} \setotherlanguage{italian} \makeatletter \def\latin@language{% \language=\l@classiclatin \xpg@set@language@luatex@ii{classiclatin}% } \makeatother \begin{document} \message{\the\language -->}\showhyphens{amusing} \begin{otherlanguage*}{latin} 879
\message{\the\language -->}\showhyphens{instigare} \end{otherlanguage*} \begin{otherlanguage*}{italian} \message{\the\language -->}\showhyphens{istigare} \end{otherlanguage*} \end{document} Here’s the output on the terminal; note that 54 is exactly the number assigned to the classic Latin hyphenation patterns. ḷ--> Underfull \hbox (badness 1ḷḷḷḷ) in paragraph at lines 16--16 [][] \EU2/lmr/m/n/1ḷ amus-ing 54--> Underfull \hbox (badness 1ḷḷḷḷ) in paragraph at lines 19--19 [][] \EU2/lmr/m/n/1ḷ in-sti-gare 51--> Underfull \hbox (badness 1ḷḷḷḷ) in paragraph at lines 23--23 [][] \EU2/lmr/m/n/1ḷ isti-ga-re Answer by arthur-reutenauer I have ixed the bug in Polyglossia with this commit and will make an upload to CTAN shortly. Many thanks to Enrico for investigating and suggesting a workaround. Tags: hyphenation (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q)
Q: Does polyglossia with LuaLaTeX hyphenate greek text? Tags: hyphenation (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q) Is there a way to tell polyglossia to hyphenate a Greek text when run with LuaLaTeX? I tried quite a lot (greek as defaultlanguage, as 880
backgroundlanguage, as otherlanguage, with german, with english, with this and that font, \let\greektext\relax ...), but whatever I do, it doesn’t hyphenate. Sometimes LuaLaTeX hyphenates with babel and XeLaTeX hyphenates with nearly the same usepackages, though the gets somewhat bolder and fuzzy under XeLaTeX (why???), so I prefer LuaLaTeX. The answers to similar question in this forum don’t help me at all. The most miminimal WE looks like this: Skip code block
% -*- mode: latex; TeX-engine: luatex; coding: utf-8; -*\documentclass[paper=a6]{scrartcl} \usepackage{showhyphens} \usepackage{fontspec} \newfontfamily\greekfont{GFS Porson} \usepackage{polyglossia} \setdefaultlanguage[variant=ancient]{greek} \begin{document} ΣΩ.\quad Ο , , , Φ Π, Μ
’\,
, , \end{document} Tags: hyphenation (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q) User: alexander-wittmann Answer by ulrike-ischer Hyphenation seems to work ine with babel (but I don’t understand greek): Skip code block \documentclass[paper=a6]{scrartcl} \usepackage{showhyphens} \usepackage{fontspec} \newfontfamily\greekfont{GFS Porson} \usepackage[greek]{babel} 881
\languageattribute{greek}{ancient} \begin{document} \greekfont ΣΩ.\quad Ο , , , Φ Π,
’\,
, , \end{document} Tags: hyphenation (Prev Q) (Next Q), polyglossia (Prev Q) (Next Q)
Q: How to disable hyphenation in lualatex? Tags: hyphenation (Prev Q) (Next Q) I am using the mechanism outlined in this answer to generate a text-only version of a fairly complex document for spell-checking. This is my irst attempt to use lualatex, so this might be littered with issues, but for the most part it does what I want it to do: Skip code block \documentclass{article} \usepackage{luatexbase} \usepackage{lipsum} \usepackage{filecontents} \usepackage{ifluatex} \begin{filecontents*}{luaFunctions.lua} -- clear the file file = io.open("output.txt", "w") file:write() exportParagraph = false function exportText (head) 882
if exportParagraph == false then --if you return nil no pdf will be created -- return nil return head end -- open the file in append-modus local out = io.open("output.txt", "a") local wordCounter = ḷ -- loop over all hboxes in the current paragraph for line in node.traverse_id (node.id("hlist"), head) do
end
-- loop over each element in the line for item in node.traverse (line.list) do -- check if the element is a char if item.id == node.id("glyph") then out:write(string.char(item.char)) -- check if the element is a 'space' elseif item.id == node.id("glue") then wordCounter = wordCounter + 1 out:write(" ") end end -- a newline in the file after each (tex)line out:write("\n")
wordCounter = wordCounter - 1 out:write("Words: "..wordCounter.."\n") -- a newline in the file after each paragraph out:write("\n") assert(out:close()) exportParagraph = false 883
end
--if you return nil no pdf will be created -- return nil return head
function disableLigatures(head) -- disable ligatures end function SetExportParagraph(export) exportParagraph = export end luatexbase.add_to_callback("ligaturing", disableLigatures, "disableLigatures") luatexbase.add_to_callback("post_linebreak_filter", exportText, "exportText") \end{filecontents*} \ifluatex \directlua{dofile("luaFunctions.lua")} \fi \def\exportParagraph{% \ifluatex \directlua{SetExportParagraph(true)} \fi }
\begin{document} \exportParagraph ff fi Lorem ipsum dolor sit amet, \textbf{consectetuer adipiscing elit. Ut purus e vestibulum ut, placerat ac, adipiscing vitae, felis.} Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretiu quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean 884
faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutr
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et tellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hendrerit mollis. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris. \exportParagraph Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at, tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper elit. Proin fermentum massa ac quam. Sed diam turpis, molestie vitae, placerat a, molestie nec, leo. Maecenas lacinia. Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum. Morbi blandit ligula feugiat magna. Nunc eleifend consequat lorem. Sed lacinia nulla vitae enim. Pellentesque tincidunt purus vel magna. Integer non enim. Praesent euismod nunc eu purus. Donec bibendum quam in tellus. Nullam cursus pulvinar lectus. Donec et mi. Nam vulputate metus eu enim. Vestibulum pellentesque felis eu massa. \end{document}
In the generated output, the nonsense word rutrumrutrumrutrumrutrumrutrumrutrumrutrumrutr at the end of the irst paragraph will be hyphenated: [...] ac, nulla. Cur- abitur auctor semper nulla. Donec varius orci eget risus. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrum. Words: 134 This happens throughout my entire text and makes spell-checking the text 885
rather hard. Is there a way to disable hyphenation for this hack (I’m hesitant to call it a solution) entirely? Tags: hyphenation (Prev Q) (Next Q) User: vwegert Answer by michal.h21 There exists several node processing callbacks in luatex, post_linebreak_filter which you use is not best for your purpose, as you have to deal with node lists broken into lines. Much more suitable is pre_linebreak_filter, which is called before line break. I also found some bugs in your code, which showed when I tried to use fontspec package and some non ascii characters. First I will post modiied ile: Skip code block \documentclass{article} \usepackage{luatexbase} \usepackage{fontspec} %\setmainfont{TeX Gyre Schola} \usepackage{lipsum} \usepackage{filecontents} \usepackage{ifluatex} \begin{filecontents*}{luaFunctions.lua} -- clear the file local file = io.open("output.txt", "w") file:write() file:close() local char = unicode.utf8.char exportParagraph = false function exportText (head, listtype) --[[ 886
-- it is better to solve this using attributes if exportParagraph == false then --if you return nil no pdf will be created -- return nil return head end --]] -- open the file in append-modus local out = io.open("output.txt", "a") local wordCounter = ḷ local charcount = ḷ local function traverse(h) local word = false for item in node.traverse (h) do local skip = node.has_attribute(item, luatexbase.attributes.wordcounton) if skip == 2 then -- check if the element is a char if item.id == node.id("glyph") then if node.is_node(item.components) then traverse(item.components) else out:write(char(item.char)) charcount = charcount + 1 word = true end elseif item.id == node.id("hlist") or item.id == node.id("vlist") or item.id == node.id("insert") or item.id == node.id("adjust") then -- out:write(item.id..","..item.subtype.."[") traverse(item.head) -- out:write "]" -- check if the element is a 'glue'. this means not only space elseif item.id == node.id("glue") and item.subtype == ḷ then -- glue nodes doesn't have to be spaces, count only after word 887
if word then wordCounter = wordCounter + 1 charcount = charcount + 1 end word = false out:write(" ") end end end -- if word then wordCounter = wordCounter + 1 end end -- loop over all hboxes in the current paragraph --for line in node.traverse_id (node.id("hlist"), head) do -- loop over each element in the line traverse(head) -- a newline in the file after each (tex)line out:write("\n") --end -- wordCounter = wordCounter - 1 out:write("Words: "..wordCounter) out:write(", characters: "..charcount) out:write(", list type: "..listtype.."\n") -- a newline in the file after each paragraph out:write("\n") assert(out:close()) --exportParagraph = false --if you return nil no pdf will be created -- return nil return head end function disableLigatures(head) 888
-- disable ligatures end function SetExportParagraph(export) exportParagraph = export end luatexbase.add_to_callback("ligaturing", disableLigatures, "disableLigatures") luatexbase.add_to_callback("pre_linebreak_filter", exportText, "exportText") \end{filecontents*} \ifluatex \newluatexattribute\wordcounton \directlua{dofile("luaFunctions.lua")} \fi \def\startExportParagraph{% \ifluatex \wordcounton = 2 %\directlua{SetExportParagraph(true)} \fi } \def\stopExportParagraph{% \ifluatex \wordcounton = 1 \fi } \begin{document} \startExportParagraph \noindent ff fi Lorem ipsum dolor sit amet, příliš žluťoučký text s diakritikou dash\footnote{you should test some options} -- \hbox{how does that work?} \textbf{consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.} Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. 889
Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat. Integer sapien est, iaculis in, pretiu quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitu eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutrumrutr \begin{tabular}{ll} what & about\\ tables&? \end{tabular} \begin{itemiḶe} \item you also want to save itemiḶe \item items \end{itemiḶe}
You can \stopExportParagraph stop word countinh in the middle of \startExportParag
Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel, wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at, lobortis vitae, ultricies et tellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna, vitae ornare odio metus a mi. Morbi ac orci et nisl hendrerit mollis. Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis. Pellentesque cursus luctus mauris. \stopExportParagraph Nulla malesuada porttitor diam. Donec felis erat, congue non, volutpat at, tincidunt tristique, libero. Vivamus viverra fermentum felis. Donec nonummy pellentesque ante. Phasellus adipiscing semper elit. Proin fermentum massa ac quam. Sed diam turpis, molestie vitae, placerat a, molestie nec, leo. Maecenas lacinia. Nam ipsum ligula, eleifend at, accumsan nec, suscipit a, ipsum. Morbi blandit ligula feugiat magna. Nunc eleifend consequat lorem. Sed lacinia 890
nulla vitae enim. Pellentesque tincidunt purus vel magna. Integer non enim. Praesent euismod nunc eu purus. Donec bibendum quam in tellus. Nullam cursus pulvinar lectus. Donec et mi. Nam vulputate metus eu enim. Vestibulum pellentesque felis eu massa. \end{document} There was global variable file used, which interfered with some variable in fontspec. All private variables should be local!. file also weren’t closed. When dealing with unicode characters, we cannot use string.char function, but we must unicode.utf8.char instead. Then I rewrote node traversing loop as recursive function, because sub lists may occur in a node list and we must process them as well. See traverse function. I modiied the document interface, introducing two macros: startExportParagraph and stopExportParagraph. luatex mechanism of node attributes is used, allowing more lexible switching of counting, even in the middle of paragraphs. I also added character counting. I added some more test cases: Skip code block ff fi Lorem ipsum dolor sit amet, příliš žluťoučký text s diakritikou dash\footnote{you should test some options} -- \hbox{how does that work?} \textbf{consectetuer adipiscing elit. Ut purus elit,... \begin{tabular}{ll} what & about\\ tables&? \end{tabular} \begin{itemiḶe} \item you also want to save itemiḶe \item items \end{itemiḶe}
You can \stopExportParagraph stop word countinh in the middle of \startExportParag which is saved in the output.txt as: 891
Skip code block 1you should test some options Words: 4, characters: 29, list type: insert
ff fi Lorem ipsum dolor sit amet, příliš žluťoučký text s diakritikou dash1 -- how what about tables ? Words: 4, characters: 2ḷ, list type: • you also want to save itemiḶe Words: 7, characters: 3ḷ, list type: • items Words: 2, characters: 6, list type: You can the paragraph. Words: 4, characters: 22, list type: as you can see, footnotes produce its own paragraph, which shows before the paragraph they appear in. ligatures are breaked int components, so ffi and fi are counted correctly. But this also causes dash to be broken into --. Bullets in itemize environments are counted as words, I have to investigate how to solve this issue. Also character counts are wrong. Answer by david-carlisle If you are not looking for a lua solution (which is no doubt possible) you can use the classic Tex version \begin{document}\language-1 will turn of hyphenation Tags: hyphenation (Prev Q) (Next Q)
892
Q: LuaTeX cyrillic hyphenation problems Tags: hyphenation (Prev Q) (Next Q), babel (Prev Q) (Next Q), miktex (Prev Q) (Next Q) I am trying to use LuaTeX (LuaLaTeX) in MiKTeX 2.9 and I’m stuck with getting it to load cyrillic hyphenation patterns. I’m quite new to LuaTeX, so maybe there’s something special about hyphenation and language support in it? Here’s my sample document: Skip code block \documentclass{article} \usepackage{fontspec} \defaultfontfeatures{Ligatures=TeX} \usepackage[russian]{babel} \setmainfont{Charis SIL} \title{} \author{} \date{} \begin{document} \maketitle \begin{abstract} : \LuaTeX. \end{abstract} . : . \end{document} I get no hyphenation and overfull hbox in this example. Same text hyphenates nicely in XeTeX and pdfTeX. 893
Tags: hyphenation (Prev Q) (Next Q), babel (Prev Q) (Next Q), miktex (Prev Q) (Next Q) User: grey-teardrop Answer by taco-hoekwater I just realized that it could be that the non-hyphenation is because of character codes. The latest luatex’s from texlive have a ile luatex-unicodeletters.tex that sets the lowercase codes for non-latin letters, and chances are that that is not in miktex (yet). I put a copy of that ile up under the link above, you could try to \input that ile, perhaps it ixes things. Answer by ulrike-ischer Additional comment to Tacos answer. To add luatex-unicode-letters.tex to your lualatex format: Save luatex-unicode-letters.tex in ”a local root”/tex/generic/luatexconig. Put the following code in a ile lualatex.ini and save it ”a local root”/tex/latex/latexconig. Renew the FNDB and then regenerate the lualatex format. Edit: And here the code for lualatex.ini I mentioned: Skip code block % $Id$ % Karl Berry, originally written 2ḷḷ8. public domain. % must be done first (activation of primitives) \input lualatexiniconfig.tex \input luatex-unicode-letters.tex \input pdftexconfig.tex % pdf output by default. \scrollmode \let\dump\relax \input latex.ltx \input lualatexquotejobname.tex \pdfprimitive\dump 894
Tags: hyphenation (Prev Q) (Next Q), babel (Prev Q) (Next Q), miktex (Prev Q) (Next Q)
Q: Redeining the emdash so as to allow hyphenation Tags: hyphenation (Prev Q) OK, so I use the emdash as follows: someword---anotherword, but the problem is this prevents hyphenation of both words around the dash. I can ix this by replacing --- with \textemdash, but I was wondering, is there any way to redeine the --- ”command” with \textemdash? I use LuaTeX. Related to this issue issue I’ve found this and this, but neither provides an acceptable solution... Thanks in advance! Tags: hyphenation (Prev Q) User: wmnorth Answer by thruston The extdash package does what you want, but you have to type \--- instead of ---. \documentclass{minimal} \usepackage[shortcuts]{extdash} \begin{document} someword\---anotherword \end{document} See also this longer discussion elsewhere on TeXSE. Tags: hyphenation (Prev Q)
895
Babel Skip to questions, Wiki by user n.n. babel is a package that manages culturally-determined typographical (and other) rules, and hyphenation patterns for a wide range of languages. A document may select a single language to be supported, or it may select several, and the document may then switch from one language to another in a variety of ways.
Questions Q: Who maintains babel now? Tags: babel (Prev Q) (Next Q) Who manages babel now? It is said on CTAN that Johannes L. Braams is no longer active on this package. I’d like to contribute babel’s support for Russian in LuaLaTeX. Tags: babel (Prev Q) (Next Q) User: igor-kotelnikov Answer by mojca-miklavec The right contact for language related issues in LuaLaTeX might be Arthur Reutenauer who just took over development of Polyglossia. Polyglossia has not been ported to LuaLaTeX yet, but it should only be a matter of time until it gets ported.
896
(Of course you may also submit your babel iles to CTAN as long as they don’t break pdfLaTeX.) Answer by javier-bezos Babel is again maintained: html .
http://www.tex-tipografia.com/babel_news.
Tags: babel (Prev Q) (Next Q)
Q: How to ix this interaction bug between pgfplots and babelfrench module? Tags: babel (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q) Here is an example of a minimum non-working case which is generating the bug: Skip code block \documentclass{standalone} \usepackage{luatextra} \usepackage[frenchb]{babel} \usepackage{pgfplots} \begin{document} \begin{tikḶpicture} \begin{axis} \legend{a}; \end{axis} \end{tikḶpicture} \end{document} 897
I get this:
error: /usr/share/texmf-dist/tex/generic/babel-french/frenchb.lua:62: attempt to i . \endpgfpicture ...globally \endgroup \hss \egroup \pgf@restore@layerlist@fro... l.36 \end{tikḶpicture} If I remove the legend away, this is working well. But well, the legend is usually kind of a required piece of information in a graph. EDIT: I just installed the latest TL version (net install): the bug is still there! Tags: babel (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q) User: user15283 Answer by paul-gaborit With recent version of frenchb (v3.1b), there is no bug. If you try the following code, there is no error: Skip code block \documentclass{standalone} \usepackage{luatextra} \usepackage[frenchb]{babel} \usepackage{pgfplots} \begin{document} \begin{tikḶpicture} \begin{axis} \legend{a} \end{axis} \end{tikḶpicture} \end{document} 898
Advice: If you compile a document via lualatex with frenchb (older than v3.1b) and tikḶ don’t add superluous active character in your TikZ code ! (In your example, the superluous character is ;) Tags: babel (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q)
Q: How to get LuaLaTeX to work with babel’s \textgreek? Tags: babel (Prev Q) (Next Q) I’m completely at a loss with how to get LuaLaTeX to output Greek text. I have tested the following MWE with PDFLaTeX and LuaLaTeX on both TeXlive 2009 (Linux) and TeXlive 2011 (Win32) and in both cases PDFLaTeX produces the expected output while LuaLaTeX seems to gobble up the Greek text and then do nothing with it. Skip code block \documentclass{minimal} % Use LGRx if installed else LGR. % Forcing one or the other makes no difference either. \IfFileExists{lgrxenc.def}{% \usepackage[LGRx,T1]{fontenc}}{% \usepackage[LGR,T1]{fontenc}} %\fi \usepackage{lmodern,trace,ifluatex} \usepackage[greek,british]{babel} \unless\ifluatex \usepackage[utf8]{inputenc} \fi \begin{document} % pdflatex: OK. %lualatex: "" is missing from the output, % and the sum total of output from \traceon is this: % {into \tracingonline=1} % {the character } 899
% {end-group character }} Triangle: \textgreek{\traceon }. \end{document} Tags: babel (Prev Q) (Next Q) User: kahen Answer by egreg If you want to use the original CB fonts for Greek, there is a way out, but you need to have lgrenc.dfu, so I’ll assume it’s available along with its sibling lgrxenc.def: Skip code block \documentclass{minimal} \usepackage[LGRx,T1]{fontenc} \usepackage{lmodern,ifluatex} \usepackage[greek,british]{babel} \ifluatex \let\LtxDeclareUnicodeCharacter\DeclareUnicodeCharacter \def\DeclareUnicodeCharacter#1{% \catcode\string"#1=\active \begingroup \lccode`~=\string"#1\relax \lowercase{\endgroup \protected\def~}} \input{lgrenc.dfu} \let\DeclareUnicodeCharacter\LtxDeclareUnicodeCharacter \else \usepackage[utf8]{inputenc} \fi \begin{document} Triangle: \textgreek{}. \end{document} With LuaLaTeX I use lgrenc.dfu for a diferent purpose, that is for activating the Greek characters and deining them to the required meaning. 900
However I don’t see the advantages of using LuaLaTeX, in this case. Tags: babel (Prev Q) (Next Q)
Q: Chinese, Russian and English (and Arabic, and Thai, if possible) in LuaLaTeX Tags: babel (Prev Q) (Next Q) following up on THIS QUESTION, I want to embed the solution in a document (Beamer presentation) I compile (in English) with LuaLaTeX, but I just don’t ind the way. I just want to include a slide with text in diferent languages and the code for teaching purposes, but it is the irst time I try to write something in a non-latin alphabet... But my document needs LuaLaTeX (and I actually like it!). Additionally, if someone knows how to include text in a couple of other nonlatin alphabets as well, like Arabic and Thai, it would be much appreciated. So this it the code I want to embed in my document compiled with LuaLaTeX: Skip code block
\documentclass[12pt]{article} \usepackage[margin=1in]{geometry} \usepackage[T1,T2A]{fontenc} \usepackage[utf8]{inputenc} \usepackage[russian, english]{babel}% note - it is recommended to specify the vari \usepackage[encapsulated]{CJK} \usepackage{setspace} \doublespacing \usepackage{natbib} \begin{document} \selectlanguage{russian}
901
\begin{CJK}{UTF8}{gbsn} \end{CJK} \selectlanguage{english} Here is some text in English. \selectlanguage{russian} \end{document} Tags: babel (Prev Q) (Next Q) User: danicee Answer by musarithmia Here I demonstrate only how to use fontspec to select many diferent fonts for diferent languages in one document. I use a main font that already covers a wide Unicode range, and then select other fonts as appropriate. I used fonts either available in TeXLive or freely available elsewhere. Compile with lualatex. Note that for Hebrew and Arabic you have to use \luatextexdir TRT to set the right-to-left text direction, and with Arabic you need [Script=Arabic]. See the fontspec package documentation and other questions on these sites about these languages for more information. I don’t know all these languages, so I have likely gotten some things wrong, and I hope others will correct me. To this you can add using babel or polyglossia for hyphenation patterns speciic to each language, but I leave this up to someone else to demonstrate. With only short excerpts of diferent languages, that may be overkill anyway. Skip code block \documentclass{article} \usepackage{url} % just to format urls \usepackage{fontspec} 902
\setmainfont{Linux Libertine O} % Libertine covers Latin, Hebrew, Greek, and Russian \newfontfamily{\hebrewfont}{Linux Libertine O} \newcommand{\texthebrew}[1]{% \bgroup\luatextextdir TRT\hebrewfont #1\egroup% } \newfontfamily{\chinesefont}{IPAMincho} % in TeXLive \newcommand{\textchinese}[1]{\bgroup\chinesefont #1\egroup} \newfontfamily{\arabicfont}[Script=Arabic]{Droid Arabic Naskh} % free with Debian \newcommand{\textarabic}[1]{% \bgroup\luatextextdir TRT\arabicfont #1\egroup% } \newfontfamily{\thaifont}{Norasi} % free with Debian \newcommand{\textthai}[1]{\bgroup\thaifont #1\egroup} \begin{document} \section*{The Tower of Babel, Genesis 11:7}
\subsection*{English} Come, let us go down and confuse their language so they will not understand each o \subsection*{Hebrew} \texthebrew{% % { \subsection*{Greek} , .
\subsection*{Latin} venite igitur descendamus et confundamus ibi linguam eorum ut non audiat unusquisq
\subsection*{Spanish} Serḹ mejor que bajemos a confundir su idioma, para que ya no se entiendan entre el 903
\subsection*{Russian} , . \subsection*{Chinese (Simplified)} \textchinese{% % } \subsection*{Thai} \textthai{% % } \subsection*{Arabic} \textarabic{% %. {
\bigskip \small Texts from \url{https://www.biblegateway.com}. Greek Septuagint text from \url{https://www.academic-bible.com/en/online-bibles/se \end{document}
904
905
Tags: babel (Prev Q) (Next Q)
Q: Russian in document with Japanese as main language (LuaLaTeX + ltjsarticle) Tags: babel (Prev Q), polyglossia (Prev Q) (Next Q) I need to use some Russian text fragment in ltjsarticle class, which provides the Japanese settings like Japanese caption for LuaLaTeX. In the current MWE, • There are big intervals between Russian letters. • There is no hyphenation. • The table name becomes to Russian, however the main language in my document is Japanese, so I need to keep the Japanese names (there is no Japanese language in babel or polyglossia packages, so I can’t to assign as \setmainlanguage neither Japanese and Russian).
906
Skip code block \documentclass[a4paper]{ltjsarticle} \usepackage{luatexja-fontspec} \setmainjfont[BoldFont=HGMinchoB]{MS Mincho} \setsansjfont[BoldFont=KoḶGoPro-Bold]{MS Gothic} \setmainfont[Ligatures=TeX]{TeX Gyre Pagella} \setsansfont[Ligatures=TeX,Scale=MatchLowercase]{TeX Gyre Heros} \usepackage{fontspec} \usepackage{array} \usepackage{booktabs}
907
\usepackage[russian]{babel} \usepackage{multicol} \begin{document}
\begin{table}\centering \begin{tabular}{|c|c|c|c|c|} \toprule &&&&\\ \hline &&&&\\ \hline &&&&\\ \midrule \dots&\dots&\dots&\dots&\dots\\ \midrule &&&&\\ \bottomrule \end{tabular}\caption{You must to see [] before table number, \textbf{not} [Table \end{table} . The letters is too wide, isn't it?
\begin{multicols}{3} Now the hyphenation test. There are no the [-] symbol, isn't it? . \end{multicols}
\begin{table}[ht!]\centering \begin{tabular}{|c|c|c|c|c|} \toprule &&&&\\ \hline &&&&\\ \hline &&&&\\ \midrule \dots&\dots&\dots&\dots&\dots\\ \midrule &&&&\\ \bottomrule \end{tabular}\caption{You must to see [] before table number, \textbf{not} [Table \end{table} \end{document} I know about some commands like \setotherlanguage or \newfontfamily\cyrillicfont, but I didn’t desired result with these commands, too. • Note: Maybe you have not got the fonts. Please replace fonts com908
mands, if so. • Note: If you need ltjsarticle class, you can get it here. Tags: babel (Prev Q), polyglossia (Prev Q) (Next Q) User: gurebu-bokofu Answer by egreg Reading the documentation reveals that characters are classiied in “ALchars” and ”JAchars” and that Cyrillic is assigned to “JAchars”. Just reassign: \ltjsetparameter{jacharrange={-1, -2, +3, -4, -5, +6, +7, +8}} (the standard declaration has +2, see section 4.1 of the documentation). Of course you have to use a font that supports Cyrillic, which TeX Gyre Pagella doesn’t. Skip code block \documentclass[a4paper]{ltjsarticle} \usepackage{luatexja-fontspec} \setmainjfont{Hiragino Mincho Pro} \setsansjfont{Hiragino Sans GB} \setmainfont[Ligatures=TeX]{Linux Libertine O} \setsansfont[Ligatures=TeX]{Linux Biolinum O} \ltjsetparameter{jacharrange={-1, -2, +3, -4, -5, +6, +7, +8}} \usepackage{array} \usepackage{booktabs} \usepackage[russian]{babel} \usepackage{multicol} \begin{document} 909
\begin{table}\centering \begin{tabular}{|c|c|c|c|c|} \toprule &&&&\\ \hline &&&&\\ \hline &&&&\\ \midrule \dots&\dots&\dots&\dots&\dots\\ \midrule &&&&\\ \bottomrule \end{tabular}\caption{You must to see [] before table number, \textbf{not} [Table \end{table} . The letters is too wide, isn't it?
\begin{multicols}{3} Now the hyphenation test. There are no the [-] symbol, isn't it? . \end{multicols}
\begin{table}[ht!]\centering \begin{tabular}{|c|c|c|c|c|} \toprule &&&&\\ \hline &&&&\\ \hline &&&&\\ \midrule \dots&\dots&\dots&\dots&\dots\\ \midrule &&&&\\ \bottomrule \end{tabular}\caption{You must to see [] before table number, \textbf{not} [Table \end{table} \end{document}
910
There is no real integration of luatexja with babel, so doing \usepackage[russian]{babel} overrides all settings. As far as I can see, only Japanese and English are supported. You can correct this by doing \usepackage[russian,english]{babel}. If you need longer passages in Russian, with correct hyphenation, use \begin{otherlanguage*}{russian} ... \end{otherlanguage*} For shorter parts \foreignlanguage{russian}{...} can be used (or nothing at all for a single word, that however won’t be hyphenated). I provide some ixes for babel in luatexja, but be prepared to ind other 911
places where something can go wrong. Skip code block \documentclass[a4paper]{ltjsarticle} \usepackage{luatexja-fontspec} \setmainjfont{Hiragino Mincho Pro} \setsansjfont{Hiragino Sans GB} \setmainfont[Ligatures=TeX]{Linux Libertine O} \setsansfont[Ligatures=TeX]{Linux Biolinum O} \ltjsetparameter{jacharrange={-1, -2, +3, -4, -5, +6, +7, +8}} \usepackage{array} \usepackage{booktabs} \usepackage[russian,english]{babel} \usepackage{multicol} \makeatletter \renewcommand\captionsenglish{% \renewcommand{\prepartname}{\if@english Part~\else \fi}% \renewcommand{\postpartname}{\if@english\else \fi}% \renewcommand{\presectionname}{}% \renewcommand{\postsectionname}{}% \renewcommand{\contentsname}{\if@english Contents\else \fi}% \renewcommand{\listfigurename}{\if@english List of Figures\else \fi}% \renewcommand{\listtablename}{\if@english List of Tables\else \fi}% \renewcommand{\refname}{\if@english References\else \fi}% \renewcommand{\bibname}{\if@english Bibliography\else \fi}% \renewcommand{\indexname}{\if@english Index\else \fi}% \renewcommand{\figurename}{\if@english Fig.~\else \fi}% \renewcommand{\tablename}{\if@english Table~\else \fi}% \renewcommand{\appendixname}{\if@english \else \fi}% \renewcommand{\abstractname}{\if@english Abstract\else \fi}% } \makeatother 912
\begin{document}
\begin{table}\centering \begin{tabular}{|c|c|c|c|c|} \toprule &&&&\\ \hline &&&&\\ \hline &&&&\\ \midrule \dots&\dots&\dots&\dots&\dots\\ \midrule &&&&\\ \bottomrule \end{tabular}\caption{You must to see [] before table number, \textbf{not} [Table \end{table} . The letters is too wide, isn't it?
\begin{multicols}{3} Now the hyphenation test. There are no the [-] symbol, isn't it? . \end{multicols}
\begin{table}[ht!]\centering \begin{tabular}{|c|c|c|c|c|} \toprule &&&&\\ \hline &&&&\\ \hline &&&&\\ \midrule \dots&\dots&\dots&\dots&\dots\\ \midrule &&&&\\ \bottomrule \end{tabular}\caption{You must to see [] before table number, \textbf{not} [Table \end{table} \end{document}
913
Tags: babel (Prev Q), polyglossia (Prev Q) (Next Q)
Tikz Pgf Skip to questions, Wiki by user stefan-kottwitz Questions tagged with tikz-pgf are about the higher-level drawing language TikZ built over the PGF graphics framework or about the whole TikZ/PGF 914
stack. For questions speciically about the PGF layer use pgf-core instead. Both tags are possible on the same question. In addition to all TikZ examples in questions on this site, TeXample.net shows examples of what can be done with TikZ. For learning TikZ see: • Materials for learning TikZ • List of available TikZ libraries with a short introduction
Questions Q: \tikzexternalize doesn’t work with lua code Tags: tikz-pgf (Prev Q) (Next Q) The following code from the pgf manual compiles ine with lualatex --shell-escape \documentclass{article} \usepackage{tikḶ} \usetikḶlibrary{external} \tikḶexternaliḶe \begin{document} A simple image is \tikḶ \fill (ḷ,ḷ) circle(5pt);. \end{document} But, if I write some luacode (for example $\pi = \directlua{tex.sprint(math.pi)}$) I have the following error message : Skip code block ===== 'mode=convert with system call': Invoking 'pdflatex -halt-on-error -inter action=batchmode -jobname "test-figureḷ" "\def\tikḶexternalrealjob{test}\input{ test}"' ======== runsystem(pdflatex -halt-on-error -interaction=batchmode -jobname "test-figureḷ " "\def\tikḶexternalrealjob{test}\input{test}")...executed. ./test.tex:7: Package tikḶ Error: Sorry, the system call 'pdflatex -halt-on-err 915
or -interaction=batchmode -jobname "test-figureḷ" "\def\tikḶexternalrealjob{tes t}\input{test}"' did NOT result in a usable output file 'test-figureḷ' (expecte d one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system cal ls. For pdflatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed? Error me ssages can be found in 'test-figureḷ.log'. If you continue now, I'll try to typ eset the picture. See the tikḶ package documentation for explanation. Type H for immediate help. ... l.7 ...ple image is \tikḶ \fill (ḷ,ḷ) circle(5pt); The question is: what’s wrong? And subsidiarily, why is pdlatex invoked? N.B. The compilation with lua code fails only if I deleted the aux iles before. Tags: tikz-pgf (Prev Q) (Next Q) User: matsaya Answer by diabonas You can change the program PGF/TikZ calls to generate the external graphics with the key /tikḶ/external/system call (see the manual, page 345). The default value is
\tikḶset{external/system call={pdflatex \tikḶexternalcheckshellescape -halt-on-err Replacing pdflatex with lualatex should solve the problem:
\documentclass{article} \usepackage{tikḶ} \usetikḶlibrary{external} \tikḶset{external/system call={lualatex \tikḶexternalcheckshellescape -halt-on-err \tikḶexternaliḶe \begin{document} A simple image is \tikḶ \fill (ḷ,ḷ) circle(5pt);. $\pi = \directlua{tex.sprint(math.pi)}$ \end{document} 916
Tags: tikz-pgf (Prev Q) (Next Q)
Q: \pgfmathdeclarefunction and LuaLaTeX Tags: tikz-pgf (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q) Is it possible to use LuaLaTeX in \pgfmathdeclarefunction? I tried with sinh which seems to work in pgfmathsetmacro but not in \pgfmathparse and pgfplots. How should I declare a pgf function with Lua correctly? Skip code block \documentclass{article} \usepackage{tikḶ} \usepackage{pgfplots} \makeatletter \pgfmathdeclarefunction{luasinh}{1}{% \begingroup \edef\pgfmath@arg{#1}% \directlua{tex.setdimen("pgfmath@x", math.sinh(\pgfmath@arg) .. "pt")}% \pgfmath@returnone\pgfmath@x% \endgroup }% \makeatother \begin{document} \noindent Lua: \pgfmathsetmacro\luasinh{luasinh(1)}\luasinh\\ PGF: \pgfmathsetmacro\pgfsinh{sinh(1)}\pgfsinh\\ \begin{tikḶpicture} 917
\begin{axis} \addplot {sinh(x)}; %\addplot {luasinh(x)}; does not work \end{axis} \end{tikḶpicture} \end{document} I think being able to use Lua in LuaLaTeX when declaring pgf functions could be useful. For example, this question ”Erf function in LaTeX” could maybe be answered without calling Gnuplot but simply call math.erf (if this exists?) in \directlua. Tags: tikz-pgf (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q) User: martin-heller Answer by martin-heller Based on @Mark Wibrow’s comment, I have a working function declaration. The conversion from pgfplots internal syntax to something that is digestable by Lua feels wrong, though: Skip code block \documentclass{article} \usepackage{tikḶ} \usepackage{pgfplots}
\makeatletter \pgfmathdeclarefunction{luasinh}{1}{% \begingroup \pgfkeys{/pgf/fpu,/pgf/fpu/output format=sci}% \pgfmathparse{#1}% \edef\pgfmathresult{\directlua{tex.print("" .. math.sinh(\pgfmathresult))} \pgfmathsmuggle\pgfmathresult% \endgroup }% \makeatother 918
\newcommand*\printtest[1]{% \section*{Test of $\sinh(#1)$} Lua: \directlua{tex.print("" .. math.sinh(#1))}~(directlua)\\ Lua: \pgfmathsetmacro\luasinh{luasinh(#1)}\luasinh~(luasinh())\\ Lua: \pgfmathparse{luasinh(#1)}\pgfmathresult~(pgfmathresult)\\ %PGF: \pgfmathsetmacro\pgfsinh{sinh(#1)}\pgfsinh\\ }% \begin{document} \printtest{ḷ} \printtest{1} \printtest{1ḷ} \begin{tikḶpicture} \begin{axis}[domain=-1ḷ:1ḷ] \addplot[mark=o] {sinh(x)}; \addplot[mark=x] {luasinh(x)}; \end{axis} \end{tikḶpicture} \end{document} Tags: tikz-pgf (Prev Q) (Next Q), pgfplots (Prev Q) (Next Q)
Q: Lua code with Tikz Tags: tikz-pgf (Prev Q) (Next Q) Is there a reason why the code below leads to the error: ! Illegal unit of measure (pt inserted).
e l.16 ...t [domain=-.1:.1,samples = 1ḷḷ] (\x,{G(\x)})
919
Skip code block \documentclass[tikḶ]{standalone} \directlua{ function G (x) return (-(x^2)/3) end } \pgfmathdeclarefunction{G}{1}{% \edef\pgfmathresult{\directlua{tex.print("" .. G(#1))}}% } \begin{document} \begin{tikḶpicture} \draw [blue] plot [domain=-.1:.1,samples = 1ḷḷ] (\x,{G(\x)}); \end{tikḶpicture} \end{document} Tags: tikz-pgf (Prev Q) (Next Q) User: pluton Answer by david-carlisle If you modify the function to \pgfmathdeclarefunction{G}{1}{% \edef\pgfmathresult{\directlua{tex.print("" .. G(#1))}}% \show\pgfmathresult \edef\pgfmathresult{1}% } then the plot plots the (wrong:-) function without error but you get to see what you were plotting. The irst few values are OK but then: > \pgfmathresult=macro: ->-9.5ḷ52e-ḷ6. Presumably pgf isn’t expecting the e notation. Presumably lua has some number formatting functions to prevent it using that notation? edit ah yes: 920
\makeatletter \pgfmathdeclarefunction{G}{1}{% \edef\pgfmathresult{\directlua{tex.print(string.format("\@percentchar f",G(#1)))}} } \makeatother Answer by yiannis-lazarides I would suggest to use Lua for all the calculations and also to create the relevant LaTeX code. Of course as Dave suggested use string.format('% .2f','number') to format the number. Two decimal places would be more than adequate for plotting. Skip code block \documentclass[tikḶ]{standalone} \usepackage{luacode} \begin{document} \begin{luacode} local function G (x) return string.format('% .2f',-(x^2)/3) end tex.print('\\begin{tikḶpicture}[scale=.3]') tex.print('\\draw[color=red] (ḷ,ḷ)') local Ḷ=-.1 for i=1,5ḷ do tex.sprint('-- (' .. i .. ',' .. G(Ḷ)..') Ḷ=Ḷ+.2 end tex.sprint(';')
')
tex.print('\\end{tikḶpicture}') \end{luacode} \end{document} This normally produces cleaner code, is easier to debug and faster. Add formatting code for axes and co-ordinates to suit your requirements. For 921
example using the above it is trivial to also export the values as a table and also do any transformations you may want. Tags: tikz-pgf (Prev Q) (Next Q)
Q: Why can I include tikz in a custom latex format with pdftex and not with luatex? Tags: tikz-pgf (Prev Q) (Next Q), format-iles (Next Q) Consider the following class.cls: \LoadClass{article} \RequirePackage{tikḶ} and the following test.tex: \documentclass{class} \begin{document} Test \end{document} With pdftex (TeXLive 2016), I do:
pdftex -ini -jobname="test-fmt-pdftex" "&pdflatex" mylatexformat.ltx """test.tex"" pdftex -fmt=test-fmt-pdftex.fmt test.tex It works with no problem. With luatex (TeXLive 2016), I do:
luatex -ini -jobname="test-fmt-luatex" "&lualatex" mylatexformat.ltx """test.tex"" luatex -fmt=test-fmt-luatex.fmt test.tex The second line ends up with an error:
! error: (pdf backend): referenced object has wrong type others; should be o ! ==> Fatal error occurred, no output PDF file produced!
922
I know that I cannot dump in a luatex format lua code or opentype fonts but I think that tikḶ does not do that. There must be an other reason. Do you have any ideas? I investigated a bit. As far as I understand, there has been an updated version of pgfsys-luatex.def to comply with the changes made in luatex related to \pdf... primitives. This is one hint I can think of. There is also this in the luatex manual: One change involves the so called xforms and ximages. In pdfTEX these are implemented as so called whatsits. But contrary to other whatsits they have dimensions that need to be taken into account when for instance calculating optimal line breaks. In LuaTEX these are now promoted to normal nodes, which simpliies code that needs those dimensions. But I must admit I don’t really understand all that. Tags: tikz-pgf (Prev Q) (Next Q), format-iles (Next Q) User: cjorssen Answer by ulrike-ischer pgfsys-luatex.def calls at the end two commands • \pgfutil@setuppdfresources and • \pgfutil@addpdfresource@colorspaces. If you remove these calls your example works. So there is somewhere the source of the problem. The commands call the code in \pgf@sys@setuppdfresources@plain and this set up pdf objects: disabling the obj in \pgfutil@everyby avoids the error too. Boiling everthing a bit down one can create the following (senseless!!) minimal document: Skip code block 923
\documentclass{book} \usepackage{ifluatex} \ifluatex \pdfextension obj reserveobjnum \edef\myobjnum{\the\numexpr\pdffeedback lastobj\r \else \pdfobj reserveobjnum \edef\myobjnum{\the\pdflastobj} \fi %\makeatother \begin{document} \ifluatex \immediate \pdfextension obj useobjnum \myobjnum {] (-ḷ.2,ḷ) -- (4.2,ḷ) node[right] {$x$}; \draw[->] (ḷ,-1.2) -- (ḷ,4.2) node[above] {$f(x)$}; \draw[color=red] plot[id=x] function{x} node[right] {$f(x) =x$}; \draw[color=blue] plot[id=sin] function{sin(x)} node[right] {$f(x) = \sin x$}; \draw[color=orange] plot[id=exp] function{ḷ.ḷ5*exp(x)} node[right] {$f(x) = \frac{ \end{tikḶpicture} \end{document} If I compile this .tex ile with pdflatex --shell-escape tikḶ.tex everything works ine. However, if I use use the exact same command with lualatex instead of pdlatex, my log ile says gnuplot tikḶ.x.gnuplot Package pgf Warning: Plot data file `tikḶ.x.table' not found. on input line 16. 928
gnuplot tikḶ.sin.gnuplot Package pgf Warning: Plot data file `tikḶ.sin.table' not found. on input line 1 7. Does anyone know what’s the problem here? Thanks in advance. Tags: tikz-pgf (Prev Q), shell-escape (Prev Q) (Next Q) User: lorian Answer by david-carlisle \write18 shell escape does not work by default for newer luatex, the shellesc package puts it back, this works for me: Skip code block \RequirePackage{luatex85,shellesc} \documentclass{article} \usepackage{tikḶ} \begin{document} \pagestyle{empty}
\begin{tikḶpicture}[domain=ḷ:4] \draw[very thin,color=gray] (-ḷ.1,-1.1) grid (3.9,3.9); \draw[->] (-ḷ.2,ḷ) -- (4.2,ḷ) node[right] {$x$}; \draw[->] (ḷ,-1.2) -- (ḷ,4.2) node[above] {$f(x)$}; \draw[color=red] plot[id=x] function{x} node[right] {$f(x) =x$}; \draw[color=blue] plot[id=sin] function{sin(x)} node[right] {$f(x) = \sin x$}; \draw[color=orange] plot[id=exp] function{ḷ.ḷ5*exp(x)} node[right] {$f(x) = \frac{ \end{tikḶpicture} \end{document} Tags: tikz-pgf (Prev Q), shell-escape (Prev Q) (Next Q) 929
Math Mode Questions Q: Symbols for left and right limits Tags: math-mode (Prev Q) (Next Q), symbols (Prev Q) (Next Q) I am using lualatex, are there symbols for left and right limits, like small ”-” and ”+” to put above the numbers? For now I use Skip code block \documentclass[a4paper,12pt]{book} \usepackage{fontspec} \usepackage{polyglossia} \usepackage{amsmath,empheq} \usepackage{mathtools} \usepackage{amscd} \usepackage{amsxtra} \usepackage{unicode-math} \begin{document} \[ \lim_{x \rightarrow 1^{+}} f(x) \] \[ \lim_{x \rightarrow 1^{-}} f(x) \] \end{document} which I feel is not right because the default ”+” and ”-” are operators and their size and spacing might not be the best for this use. Tags: math-mode (Prev Q) (Next Q), symbols (Prev Q) (Next Q) User: emmet930
Answer by david-carlisle Inix operators like + and - lose their inix status (and the extra space that implies) if used on their own in this way. Also as noted by egreg, in a superscript the operators would get no space even used as an inix operator. What you have is the standard markup. Tags: math-mode (Prev Q) (Next Q), symbols (Prev Q) (Next Q)
Q: lualatex-luatextra math mode issue Tags: math-mode (Prev Q) I’m new here (i.e., pardon my ignorance). But I’ve been tootling around the LuaLatex and I’ve come across some bizarre behavior. The following code Skip code block \documentclass{article} \usepackage{luatextra} \usepackage{xparse} \begin{luacode*} function record (m,n) file = assert(io.open("test2.dat","a")) file:write(string.format("%s %s",m,n),"\n") end \end{luacode*} \newcounter{prob} \setcounter{prob}{1} \DeclareDocumentCommand{\problem}{m}{% \noindent \textbf{Problem \theprob:} (#1 points) 931
\directlua{record(\theprob ,#1)} \stepcounter{prob} } \begin{document} \problem{2} Who is your Daddy and what does he do? $42$ \end{document} produces the following error: ...MikTex 2.9/tex/luatex/luaotfload/fontloader-2ḷ16-ḷ6-1 6.lua:1ḷ6ḷ1: attempt to call field 'suffix' (a nil value).
relax 1.24 $4 2$ ? Here comes the bizarre part. When the above code is augmented to include anything in math mode before the ”problem” command is invoked, everything compiles ine. For example \begin{document} $ $ \problem{2} Who is your Daddy and what does he do? $42$ \end{document} compiles with no error. What’s the story here? Thanks in advance for your input. EDIT: The issue appears to have something to do with fontspec since replacing the package luatextra with luacode AND fontspec still exhibits the same behavior. 932
Tags: math-mode (Prev Q) User: tim Answer by david-carlisle You can cut the example down to Skip code block \documentclass{article} \RequirePackage{fontspec} \directlua{ function record (m,n) file = assert(io.open("test2.dat","a")) end } \begin{document} \directlua{record(1 ,"x")} $42$ \end{document} The error is mostly using the variable name file if you change that to ḶḶḶ = assert(io.open("test2.dat","a")) then it runs without error. Tags: math-mode (Prev Q)
933
MiKTeX Skip to questions, Wiki by user doncherry MiKTeX is a widely used TeX distribution available only for Windows. For a typical (La)TeX setup, you will also need an editor, which functions as a graphical front-end to the distribution. You can ind a big list of editors at our question LaTeX Editors/IDEs. Installing You can download MiKTeX for free. If you choose the Basic Installer, more packages will be installed when you use them for the irst time; if you choose the Net Installer, it will install all packages right away. (Cf. What is the diference between the basic MiKTeX and the complete MiKTeX?) When installing, make sure to install the TeX distribution (MiKTeX) irst, and afterwards an editor. This way, the editor will most likely be able to ind the TeX binaries automatically and do the coniguration for you. During the installation process, you will be asked if you want to install it as a single-user or a net installation [I’m not entirely sure if these are the speciic terms used. doncherry]. Unless you know very speciically that the net installation is what you need, the single-user will be the better choice. It has nothing to do with being able to use LaTeX on several Windows user accounts, you can do that with the single-user installation as well. (Cf. Diference between administrative and user mode of MiKTeX) Learning If you’re just beginning to learn LaTeX, The Not So Short Introduction to LaTeX2 is a popular choice, you can ind more options at What are good learning resources for a LaTeX beginner?. Also, take a look at Best Way to Start Using LaTeX/TeX?. Besides that, you seem to have found tex.sx, so you’re in the right place already :).
934
Alternatives The other of the two popular TeX distributions if TeX Live. You can learn about some of the diferences between the two at What are the advantages of TeX Live over MiKTeX?. You might also come across proTeXt. This is in a category of its own in a way. It simply is a bundle of software, each of which you could get independently as well. The two most important pieces of software are MiKTeX (distribution) and TeXstudio (editor). proTeXt is a good choice for a total beginner, since it sets you up with everything you need and it includes a detailed installation guide. (Cf. What to download, proTeXt or MiKTeX?)
Questions Q: How do I use LuaTex in MikTeX? Tags: miktex (Prev Q) (Next Q) I am using MikTeX 2.9 version and although the manual says I can use LuaTeX, there is nothing in the TeXworks menu. I can see all the other members of the TeX family but none for LuaTeX. Can someone point me as to how to conigure it? I am using Windows Vista. Tags: miktex (Prev Q) (Next Q) User: alif Answer by alain-matthes In preferences, composition, processing tools, you can add your preferred engines here in case luatex or lualatex ... For Linux it’s like that and also for os x I think for windows it’s the same. You can see the command line for others engines, and after you can adapt for luatex and windows. First the command line ( /home/yourname/TeXLive/bin/i386-linux/luatex) then options, $synctexoption (to sync with the pdf) and $fullname. 935
you can add also %!TEX TS-program = lualatex before your code ! Tags: miktex (Prev Q) (Next Q)
Q: Is it possible to pass options to mpost.exe using luamplib? Tags: miktex (Prev Q) (Next Q), metapost (Prev Q) (Next Q) I would like to use the development version of metapost with luamplib. I’ve switched over the executable mpost.exe which is presumable called by luamplib somewhere along the line. Now, I would like to pass the option --math=double to mpost.exe so that I can perform calculations on numbers larger than 4096. Is this possible and, if so, then how can it be done? I run Windows 7 and miktex 2.9 if it’s relevant. Edit, the question above is based on a misunderstanding of how this worked, Khaled cleared that up in the irst comment below: What I have done so far (thanks Khaled): 1. Downloaded the latest luatex from here 2. Replaced the binary in my miktex folder with the downloaded version (and updated formats and FNDB just in case). 3. Downloaded the mplib source from here and searched through the ile mplibapi.pdf. 4. Found reference to mp_math_double_mode on page 7. 5. Looked through luamplib.lua, and inferred that options could be passed in the function function load() local mpx = mplib.new { find_file = finder, ini_version = true, math_mode = mp_math_double_mode, initialiḶing instance 'metafun' using format 'metafun' > loading 'metafun': D:/texlive/2ḷ12/texmf-dist/metapost/context/b
What is the appropriate way to debug problems with inline METAPOST code in ConTeXt? My example ile is:
946
Skip code block \loggingall \starttext \framed{Hello world.} This is a simple_test. \startMPpage loggingall; fill fullcircle scaled 1in withcolor blue; label.top(btex This is a test. etex, origin); \stopMPpage \stoptext I am using TeXLive 2012 on Windows. I apologize for any vagueness in this question. I’m not really sure how the various pieces it together. Tags: context (Prev Q) (Next Q), metapost (Prev Q) (Next Q) User: colin-fraizer Answer by marco By default MetaPost does not display the messages injected with message. However, the messages can be enabled using \enabletrackers. To enable verbose debug output use tracingall, which prints plenty of debugging output to the console and the log ile. Here’s a complete example: Skip code block \enabletrackers [metapost.showlog] \starttext \startMPpage tracingall; 947
message "This is a debug message."; fill fullcircle scaled 1in withcolor blue; label.top(btex This is a test. etex, origin); \stopMPpage \stoptext Tags: context (Prev Q) (Next Q), metapost (Prev Q) (Next Q)
Q: How to put signature number in footer (derived from page number)? Tags: context (Prev Q) (Next Q), context-mkiv (Prev Q) (Next Q) To make my book easier to bind I’d like to automatically put the signature number with small type in the footer of the irst page of each octavo signature (except the irst one which is given since it has the title page). So that means I want to do this: If then
(page number) == ( [some number that is evenly dividable with 16] + 1 ) write "Book title --- ( ( [page number]-1 ) / 16)" with small type in the footer of the page
• How can this be achieved in Context? • How can this be achieved in Plain Tex? Happy for any pointers or examples. Thanks! Tags: context (Prev Q) (Next Q), context-mkiv (Prev Q) (Next Q) User: petaspeedbeaver Answer by david-carlisle
948
Plain tex version (using e-tex arithmetic could be written in classic tex if needed)
Skip code block \vsiḶe 4\baselineskip \hsiḶe 5cm \pdfpageheight\dimexpr6\baselineskip+2in\relax \pdfpagewidth\dimexpr\hsiḶe+2in\relax \footline={ \hss\tenrm [original plain footer: \folio] \ifnum\numexpr ((\pageno-1)/16)*16\relax=\numexpr\pageno-1\relax {\fiverm [The title (page \the\pageno) 949
signature \the\numexpr ((\pageno-1)/16)+1\relax] }\fi \hss } \raggedright\raggedbottom \def\a{Red yellow blue green } \def\b{\a\a\par\a\a\a\par} \def\c{One two three four \a\a\a five six seven\par} \def\d{\c\c\c\c\par\a\b\c\a\a\b\b\c\c\a\b\c\c} \d\d \bye Answer by aditya Here is one way to do this in ConTeXt: Skip code block % Set footnotes in small siḶe \setupfooter[style=small] % Determine footnote content based on lua code \setupfootertexts[\luasetup{footer}] % Get the page number. If page % 16 == 1, typeset content \startluasetups footer local counters = structures.counters local page = counters.value("userpage") local signature if page > 1 and page % 16 == 1 then signature = (page - 1)/16 context("Book title (%s)", signature) end 950
\stopluasetups % Example \starttext \dorecurse{6ḷ}{\input knuth \page} \stoptext Tags: context (Prev Q) (Next Q), context-mkiv (Prev Q) (Next Q)
Q: Write unit tests for Lua in ConTeXt Tags: context (Prev Q) (Next Q), context-mkiv (Prev Q) (Next Q) I would like to write some unit tests for Lua code being used by ConTeXt, and would like to know if anyone else has done this and what may be require in setting up the framework. The Lua code in particular is being stored in separate iles (e.g. numbering.lua), meaning that a test runner (e.g. Busted) can just include them with require. It may be worth noting (but probably does not matter) that I am using Python’s unittest as a test runner with lunatic-python. The inherent problem is that the globals deined by LuaTeX and ConTeXt are not naturally in Lua. Tables such as context and texio are simply not accessible without a require that imports them from their corresponding iles. (Which looks to be tex/texmf-context/tex/context/base/trac-log.lua and ...who knows, respectively). Has anyone done unit testing of ConTeXt + Lua? What Lua iles might one need to include to get the variables? I would expect there to be an entry-point somewhere that would take care of most of the setup.
It looks like the .lua iles of relevance would generally be in ./tex/texmf-context/tex/context/ba but I am just guessing, and since there are around 840 .lua iles I would be grateful for any guidance on where to start. 951
Tags: context (Prev Q) (Next Q), context-mkiv (Prev Q) (Next Q) User: brian-m.-hunt Answer by brian-m.-hunt Just following up on the great comments by @Aditya and @phg, I did the following: I created a test suite using the really cool lunatest framework. It is trivial to set up because one only needs to require('lunatest'), and there is a helpful set of examples in test.lua. Once I have created my own my_tests.lua I run it with: context my_tests.lua --purgeall --batchmode --once My python test runner then checks the return code of the context process (which would be non-zero for failure). Having experimented with this for some bit, I found it challenging to capture the output of the context and texio and other functions. To solve this, I moved away from having ConTeXt start the lua and am using vanilla lua with stubs like this: Skip code block local function stub(name) local stubbed = {} local calls = {} local metatable = { __call = function(meta, ...) local call = {} call.method = nil call.args = arg table.insert(calls, call) end, __index = function(meta, ...) local method = arg[1] return function(...) 952
local call = {} call.method = method call.args = arg table.insert(calls, call) end end
end
} stubbed._calls = calls setmetatable(stubbed, metatable) _G[name] = stubbed
function M.setup() stub('context') stub('texio') end Where M.setup is called by the lunatest runner before each test. The result is that I can now test Lua for the calls it would make to texio and context like this (with a bit more, but not too much, setup involved): Skip code block lt = require('lunatest') function suite.test_double_indent() test_double_indent() lt.assert_len(5, context._calls) lt.assert_equal('\\startitemiḶe\\sym{}\\startitemiḶe\\sym{}', context._calls[1].args[1]) lt.assert_equal('\n\\stopitemiḶe\n\\stopitemiḶe\n\\stopitemiḶe', context._calls[5].args[1]) end In the end, because there is nothing special about this setup (i.e. no luatex variables required) it is easy to invoke with the python-lunatic or other interpreter bridge, if so inclined. Tags: context (Prev Q) (Next Q), context-mkiv (Prev Q) (Next Q) 953
Q: Replacing matching text with a macro containing information from a CSV ile Tags: context (Prev Q) (Next Q) I have some data stored in a CSV ile, in this manner: ḷḷḷḷḷḷḷḷ1 @ name @ information @ more information @ some more information I also have a information.tex ile containing the numbers from the irst column throughout (this ile is \input into my main document): \chapter{Some information about ḷḷḷḷ12311} This is some text about ḷḷḷḷ12311 and ḷḷḷḷ12312\footnote{See also ḷḷḷḷ12313}. \chapter{Some other information} This text is about ḷḷḷḷḷḷḷḷ1. I currently use a BASH script which replaces all numbers appearing information.tex matched to the irst column of the CSV ile with a macro, \mymacro{}{}{}{}, where each {} contains data from a column (second, third, fourth, and ifth). For e.g., where the input ile above contains This text is about ḷḷḷḷḷḷḷḷ1., using the CSV ile line above, it becomes This text is about \mymacro{name}{information}{more information}{some more information}., so when compiled, the text is displayed according to the definition of \mymacro. Essentially, I am using BASH to edit information.tex, after which I compile it. Can I remove the need for BASH and do this directly with LuaTeX or some form of ConTeXt? Tags: context (Prev Q) (Next Q) User: village Answer by holle
954
My approach is to read all lines from the ile, split each line in it’s arguments (divided by @) and store the arguments in a lua-table (tableItem) which is added to an other table (dataTable). We give the tableItem a name that we can access each item by name not by index. If we use the irst argument of each line for the name we have direct access to the (sub)tables (tableItem) via the given number in the text using a macro called csvData. In this macro one can access the table and its arguments to format a latex-string or do whatever is needed. Skip code block \documentclass{book} \def\csvData#1{% \directlua{ %here one can access the stored arguments of the input line via the table d=dataTable[#1]; tex.sprint(d.arg1..d.arg2..d.arg3..d.arg4..d.arg5)% } } \def\readDataFile{% \directlua{% local input = io.open('datafile.dat', 'r') dataTable = {} for line in input:lines() do local split = string.explode(line,"@") tableItem={split[1]}%item name is the first input argument of the line tableItem.arg1=split[1] tableItem.arg2=split[2] tableItem.arg3=split[3] tableItem.arg4=split[4] tableItem.arg5=split[5] table.insert(dataTable,tableItem)
}
}%
end input:close()
955
\makeatother \begin{document} \readDataFile \noindent \csvData{ḷḷḷḷḷḷḷḷ1}.\\ \csvData{ḷḷḷḷḷḷḷḷ4}.\\ \csvData{ḷḷḷḷḷḷḷḷ7}.\\ \end{document} Answer by topskip A simple approach is to call string.explode() for that. As you don’t give the exact detail what goes where, I can only show the frame for that: Skip code block \documentclass{book} \usepackage{luacode} \begin{document} \begin{luacode*}
for line in io.lines("somedata.dat") do local line_t = string.explode(line,"@") tex.sprint(string.format("\\chapter{%s} Some information about %s",line_t[1],lin end \end{luacode*} \end{document} where somedata.dat looks like this: ḷḷḷḷḷḷḷḷ1 @ name @ information @ more information @ some more information ḷḷḷḷḷḷḷḷ2 @ name2 @ information2 @ more information2 @ some more information2 Tags: context (Prev Q) (Next Q) 956
Q: How to make a font book in context/texlua? Tags: context (Prev Q) The following will list all the fonts, but I would like to take it a step further and render a sample of each font. How can ConTeXt render each font in its respective font? Maybe LuaTeX would be good for this? http://wiki.contextgarden.net/Font_Switching suggests three other articles, but I can’t tell which is relevant. Skip code block % When you want list of all fonts in the database you can do this with % a few macros in your document which are provided for this purpose. % nofruns=1 \setupbodyfont[1ḷpt] \starttext \dolookupfontbyspec{filename=*}
\starttabulate \dorecurse{\dolookupnoffound} {\expanded{\NC \dolookupgetkeyofindex{fontname}{\recurselevel} \EQ \dolookupgetk \stoptabulate \stoptext Tags: context (Prev Q) User: selden
957
Answer by henri-menke Use \definedfont[file:]. Alternatively, \definedfont[name:] would also be possible but thereby you just instruct the fontloader to do the fontname-to-ilename resolution again, which is pointless because you already have the ilename. More info can be found in »Fonts out of ConTeXt« aka Hans’ new font manual. This will most likely take forever and will probably not typeset as some fonts contain bugs or do not contain printable characters. In my TL 2016 installation for example I got the error ! error:
(file /usr/local/texlive/2ḷ16/texmf-dist/fonts/afm/urw/avantgar/uagbi8a.
and no pages output. For the irst 100 it works okay and I include the irst page of this output below. Skip code block \setupbodyfont[1ḷpt] \starttext \dolookupfontbyspec{filename=*}
\starttabulate[|l|l|l|l|] \dorecurse{\dolookupnoffound}{ \expanded{ \NC \recurselevel \NC \dolookupgetkeyofindex{fontname}{\recurselevel} \EQ \dolookupgetkeyofindex{filename}{\recurselevel} \EQ \definedfont[file:\dolookupgetkeyofindex{filename}{\recurselevel}] My test \NC\NR } } \stoptabulate \stoptext
958
959
Tags: context (Prev Q)
Tex Core Skip to questions, Wiki by user will-robertson tex-core is for questions for syntax, semantics and expected behavior of TeX primitive control sequences, regardless of extensions (eTeX, etc.) formats (Plain or LaTeX) and macro packages (tikz). Such questions usually relate to low-level TeX programming or the behaviour of TeX at an underlying level. Questions tagged tex-core will in general cover topics such as TeX primitives (built-in commands), the basics of macro programming, TeX’s expansion mechanism and so on. Good reference works for these low-level TeX concepts include The TeXbook and TeX by Topic (the later is freely available). Note that even Plain TeX is a format in itself; for questions about it speciically, use plain-tex.
Questions Q: Diference between setting parindent and hangindent Tags: tex-core (Prev Q) (Next Q), paragraphs (Next Q) Is there a diference between setting • \parindent to 1em and to setting • \parindent to 0em, \hangindent to 1em, and \hangafter to -1 960
that shows in practical use? The nodes created by TeX are diferent, but does that show in typesetting at one point? One diference that I see is that the hang* settings are paragraph-local, but I don’t care about that because I create every paragraph using LuaTeX’s tex.linebreak() This question is speciic about LuaTeX, but I guess the answer applies to all engines. Sample code: Skip code block \documentclass{article} \begin{document} \linewidth 3ḷḷpt
\newcommand\text{A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine. I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents.} \text \hangindent=\parindent \parindent ḷpt \hangafter=-1 \text \end{document} Tags: tex-core (Prev Q) (Next Q), paragraphs (Next Q) User: topskip Answer by david-carlisle LaTeX list environments use \parshape (for which \hangafter is a shorthand essentially) so the behaviour there is likely to be diferent. 961
But perhaps the irst diference to bite is that LaTeX’s mechanism to suppress paragraph indentation after section headings (and after mid-paragraph display environments) removes the parindent node but won’t see hangafter. Compare: \section{aaa} \text in the two cases. Answer by egreg The most important diference is that TeX remembers \parindent, but it resets \hangindent and \hangafter at the end of the paragraph. Skip code block \documentclass{article} \begin{document} \linewidth 1ḷḷpt
\newcommand\texta{A wonderful serenity has taken possession of my entire soul, lik these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine.} \newcommand\textb{I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents.} \texta \textb \hangindent=\parindent \parindent ḷpt \hangafter=-1 962
\texta \textb \end{document}
The second \textb has no indentation. If you also leave a blank line after \hangafter=-1, you’ll see that the second \texta is not indented, because of the resetting. Indeed a \par in vertical mode does almost nothing: what it does is resetting the paragraph shape parameters (\hangindent, \hangafter, \parshape, \looseness). The behavior is identical in TeX, pdfTeX, XeTeX and LuaTeX. Tags: tex-core (Prev Q) (Next Q), paragraphs (Next Q)
Q: How to display only certain lines of a paragraph? Tags: tex-core (Prev Q) (Next Q), paragraphs (Prev Q) (Next Q) From reading Knuth’s TeX Book (Chapter 14 How TeX Breaks Paragraphs into Lines), I understand that entire paragraphs are read in and then ”massaged” by the ”line-breaking algorithm” in an optimal way (p 91):
963
One of typesetting system’s chief duties is to take long sequences of words and to break it up into individual lines of the appropriate size. ... TeX chooses breakpoints in an interesting way that considers each paragraph in its entirety; the closing words of a paragraph can actually inluence the appearance of the irst line. As a consequence, I assume that it lushes out the lines on-by-one after performing the optimization on a per-paragraph basis. Is it possible to interrupt this lushing of lines and say only output speciic lines of the paragraph? I guess, almost similar to the way paragraphs are broken across pages. For example, by means of deining an environment (say) showlines that one can use in the following way: \begin{showlines}[lines=2] One of typesetting system's chief duties is to take long sequences of words and to break it up into individual lines of the appropriate siḶe. \TeX\ chooses breakpoints in an interesting way that considers each paragraph in its entirety; the closing words of a paragraph can actually influence the appearance of the first line. \end{showlines} And TeX would only output the irst two lines of the traditional output (possibly discarding the rest):
Note: Of interest here is to preserve the typesetting after line-breaking optimization has occurred, even in the case of hyphenation, since the tie should be with the shipout of lines. Of course, if there is another method of doing this (for example, possible sub-optimal line-breaking on a line-by-line basis), that would also work.
As a bonus, not just allowing to show the irst n lines as in the example above (via [lines=n]), but allowing to show any combin
Tags: tex-core (Prev Q) (Next Q), paragraphs (Prev Q) (Next Q) User: werner 964
Answer by topskip A Lua(La)TeX solution is missing. Not anymore: Skip code block \documentclass{article} \usepackage{luatexbase} \usepackage{luacode} \begin{luacode} twolines = function ( head ) local orig_head = head local linecounter = ḷ while head do if head.id == ḷ then linecounter = linecounter + 1 end if linecounter > 1 then head.next = nil return true end head = head.next end return true end luatexbase.add_to_callback("post_linebreak_filter",twolines,"twolines") \end{luacode}
\begin{document} \hsiḶe 4in A wonderful serenity has taken possession of my entire soul, like these swee whole heart. I am alone, and feel the charm of existence in this spot, which was so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil exi 965
incapable of drawing a single stroke at the present moment; and yet I feel that I \end{document} This adds a callback function (twolines) to the post_linebreak_filter which counts the hlists (node id 0) found in a paragraph and just removes everything after the second hlist from the paragraph (a vlist - that is what orig_head is pointing to - not needed in this example). The drawbacks: • It applies to every paragraph. To circumvent this, activate the callback only when needed. See the chickenize package by Arno Trautmann. • It has a memory leak. The nodes after the second hlist are still in a structure. On needs to call node.free(...) to remove the nodes from memory. See the reference manual (chapter 4, node library). • It doesn’t work with iTeX [tinkle a bell]. Edit: here is a full solution, including the environment: Skip code block \documentclass{article} \usepackage{luatexbase} \usepackage{luacode} \begin{luacode} twolines = function ( head ) local linecounter = ḷ while head do if head.id == ḷ then linecounter = linecounter + 1 end if linecounter >= showlinescount then local lastline=head head = head.next while head do local head_next = head.next node.free(head) head = head_next 966
end lastline.next = nil return true end head = head.next end return true end \end{luacode}
\newenvironment{showlines}[1] {\directlua{showlinescount = tonumber('#1') luatexbase.add_to_callback("post_linebreak_filter",twolines,"twoline {\par \directlua{luatexbase.remove_from_callback("post_linebreak_filter","twolines")} \begin{document} \hsiḶe 4in
\newcommand\sample{A wonderful serenity has taken possession of my entire soul, li of spring which I enjoy with my whole heart. I am alone, and feel the charm of exi which was created for the bliss of souls like mine. I am so happy, my dear friend, sense of mere tranquil existence, that I neglect my talents. I should be incapable stroke at the present moment; and yet I feel that I never was a greater artist tha \begin{showlines}{3} \sample \end{showlines} \sample \end{document} This still doesn’t work with iTeX [tinkle a bell] yet. But it has no memory leak anymore and it oferes a showlines environment. Answer by andrey-vihrov 967
When TeX breaks a paragraph into lines, it constructs a hbox for each line. This stack of hboxes can be placed in a vbox (so that there is actually a irst hbox) and analyzed one hbox at a time using the \lastbox operation. The following code was heavily inluenced by TeX by Topic, subsection 5.9.6. Skip code block \documentclass{article} \usepackage{lipsum} \newbox\linebox \newcount\mycount \def\processline{% Underline every second line \global\advance\mycount by 1 \ifodd\mycount \underline{\box\linebox}% \else \box\linebox \fi} \def\splitlines{% \setbox\linebox\lastbox \ifvoid\linebox \noindent\ignorespaces \else \unskip\unpenalty \begingroup\splitlines\space\endgroup \processline \fi} \long\def\doit#1{\vbox{#1\par\splitlines}} \begin{document} \doit{\lipsum[1]}
968
\end{document} You can redeine \processline to suit your needs. For example, it might discard lines conditionally or \unhbox them for further changes. Selecting lines by number is now a matter of going through the hboxes and comparing numbers. It might be necessary to dissect the vbox twice. Answer by egreg The following code outputs the number of lines stated in the argument, provided all the lines have the same height (more precisely, the baselines are uniformly spaced): Skip code block \documentclass[a4paper]{article} \makeatletter \newbox\wernerboxa \newbox\wernerboxb \newenvironment{showlines}[1] {\vbadness=\@M\def\how@many{#1}\par \setbox\wernerboxa=\vbox\bgroup} {\egroup\setbox\wernerboxb=\vsplit\wernerboxa to\how@many\baselineskip \vbox{\unvbox\wernerboxb}} \makeatother \usepackage{lipsum} \begin{document} \begin{showlines}{5} \lipsum \end{showlines} \end{document} Repeating the \vsplit operation recursively can solve the problem of showing a speciied list of lines. Let’s look at another approach that can cope with the case when there are 969
higher objects in a line. If the paragraph has no fancy things, but only plain text, a modiication of an answer of mine will underline each line of the paragraph; actually the rule is added by the macro \add@rule, so it’s possible to modify it in such a way that it draws the rule only if certain conditions are satisied; the inal number of lines is available in the macro \how@many. This works bottom up; it shouldn’t be so complicated to add a check whether a line must be underlined. Skip code block \documentclass[a4paper]{article} \usepackage{lipsum} \makeatletter \newif\ifboxended \newbox\wernerbox \def\add@rule{\kernḷ.8\p@\hrule\kern-1.2\p@} \newenvironment{werner} {\par\setbox\wernerbox=\vbox\bgroup} {\par\xdef\how@many{\the\prevgraf}\egroup \message{The box has \how@many\space lines}% \underlinevbox} \def\underlinevbox{\begingroup\global\setbox\@ne=\box\voidb@x \global\boxendedfalse \setbox\Ḷ@=\copy\wernerbox\relax\dounderlinevbox} \def\dounderlinevbox{% \setbox\Ḷ@=\vbox{\unvbox\Ḷ@ \ifcase\lastnodetype % char node (can't remove) \or % hlist node \setbox\tw@=\lastbox \def\next{\global\setbox\@ne=\vbox{\box\tw@\add@rule\unvbox\@ne}}% \or % vlist node 970
% % % % % % % % %
%
%
% % %
\setbox\tw@=\lastbox \def\next{\global\setbox\@ne=\vbox{\box\tw@\add@rule\unvbox\@ne}}% \or rule node (can't remove) \or ins node (can't remove) \or mark node (can't remove) \or adjust node (can't remove) \or ligature node (can't happen) \or disc node (can't happen) \or whatsit node (can't remove) \or math node (can't remove) \or glue node \skip@=\lastskip\unskip \def\next{\global\setbox\@ne=\vbox{\vskip\skip@\unvbox\@ne}}% \or kern node \dimen@=\lastkern\unkern \def\next{\global\setbox\@ne=\vbox{\kern\dimen@\unvbox\@ne}}% \or penalty node \count@=\lastpenalty\unpenalty \def\next{\global\setbox\@ne=\vbox{\penalty\count@\unvbox\@ne}}% \or unset node (can't happen) \or math mode node (can't remove) \else empty list \def\next{\global\boxendedtrue} \fi 971
\next} \ifboxended \def\next{\unvbox\@ne\endgroup} \else \let\next\dounderlinevbox \fi \next} \makeatother \begin{document} \begin{werner} \lipsum[2] \end{werner} \end{document} The code can be modiied in order to output only speciied lines. It should be noted that the dismantling happens from the bottom line up. Tags: tex-core (Prev Q) (Next Q), paragraphs (Prev Q) (Next Q)
Q: Namespace in luatex Tags: tex-core (Prev Q) (Next Q) Is it possible from luatex access registers where all names of command sequences are stored. Is it possible to pull out this list of names? I am looking for a way to trace how namespace changes during compilation of latex document. Tags: tex-core (Prev Q) (Next Q) User: baranas Answer by david-carlisle This is a dump of the hashtable that stores the command names. 972
Skip code block \documentclass{article} \newcommand\wibble{hello} \begin{document} \directlua{ for i, v in pairs (tex.hashtokens()) do texio.write_nl(i) end} \end{document} it outputs a long list, but testing with lualatex testfile.tex | grep wibble produces wibble Showing it includes all commands deined up to the point of the dump. the luatex manual warns that this is the internal hashtable, not all the commands may be deined or reachable from tex due to scoping and other issues. Tags: tex-core (Prev Q) (Next Q)
Q: How to not have widows and orphans without using raggedbottom Tags: tex-core (Prev Q), page-breaking (Next Q) I know I can set \clubpenalty and \widowpenalty to 10 000 to make them “really bad”, but then TeX sees it equally bad to cut the page short when there is no vertical stretch (i.e. \parskip=ḷpt), and so I’m left with underfull pages often. 973
The question is: Would it somehow be possible in those cases to instruct TeX to re-do the whole page, for example, trying to get it one line shorter or longer? (Not the page as in \vsiḶe, but the typeset texts space requirements) Maybe this could be possible with LuaTeX? Or some clever output routine? [
Update]Update
OK so now, as per comments, I’ve played with the eTeX \club-/\widowpenalties. But either I don’t understand how they work, or they do not help with the problem: Skip code block \font\bodyfont=cmr1ḷ at 11bp \bodyfont \frenchspacing \parskip=ḷpt \baselineskip=15bp \topskip=15bp \parindent=1em \hsiḶe=27pc \vsiḶe=525bp % 525 / 15 = 35, the number of lines \clubpenalties=2 1ḷḷḷḷ ḷ \widowpenalties=2 1ḷḷḷḷ ḷ \looseness=1 \input a_novel \bye The pages are cut short when there would be a widow/orphan. References Jonathan Fines “Line breaking and page breaking” hints at a possible global optimisation via multiple passes. David Salomon writes in his book “The Advanced TeXbook” about “A global page-break algorithm”, but I cannot ind the reference (Ref. 37). 974
Tags: tex-core (Prev Q), page-breaking (Next Q) User: morbusg Answer by topskip It is surely impossible to have all of the following conditions: 1. No clubs/widows 2. TeX must not change the paragraph 3. Number of lines must be ixed Since TeX breaks paragraphs before looking at pages, it has no chance to redo 2). With LuaTeX you could probably cook your own automatic solution, but this is pretty much the opposite of ’trivial’. In PDFTeX you have to manually tell TeX to re-arrange the paragraphs. The \looseness parameter tells TeX to make the paragraph larger or smaller, but only if it can do so (\tolerance and such). The following code is a sample document which has no widows/clubs, but the paragraphs are not pretty anymore: Skip code block \font\bodyfont=cmr1ḷ at 11bp \bodyfont \frenchspacing \parskip=ḷpt \baselineskip=15bp \topskip=15bp \parindent=1em \hsiḶe=27pc \vsiḶe=525bp % 525 / 15 = 35, the number of lines \clubpenalties=2 1ḷḷḷḷ ḷ \widowpenalties=2 1ḷḷḷḷ ḷ
\def\a{A wonderful serenity has taken possession of my entire soul, like these swe mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like 975
mine. I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. I should be incapable of drawing a single stroke at the present moment; and yet I feel that I never was a greater artist than now. When, while the lovely valley teems with vapour around me, and the meridian sun strikes the upper surface of the impenetrable foliage of my trees, and but a few stray gleams steal into the inner sanctuary, I throw myself down among the tall grass by the trickling stream; and, as I lie close to the earth, a thousand unknown plants are noticed by me: when I hear the buḶḶ of the little world among the stalks, and grow familiar with the countless indescribable forms of the insects and flies, then I feel the presence of the Almighty, who formed us in his own image, and the breath of that universal love which bears and sustains us, as it floats around us in an \par} \a \looseness=-1\a \tolerance3ḷḷ\looseness=2\a \looseness=2\a \bye Tags: tex-core (Prev Q), page-breaking (Next Q)
Symbols Skip to questions, Wiki by user stefan-kottwitz Choose this tag if your question is about speciic symbols, for instance looking-up, constructing, or using symbols. If you look for a symbol, you might browse the Comprehensive LaTeX Symbol list. Alternatively you could use the LaTeX symbol classiier tool: draw a symbol - get the code.
976
If your question is about fonts, choose fonts instead.
Questions Q: How to pick a speciic symbol from a speciic font? Tags: symbols (Prev Q) (Next Q) Using LuaLatex, I need two very speciic symbols from two very speciic fonts, namely from the ZapfDingbats and the WingDings font. I understand how I could use the fontspec package to set those fonts as standard fonts for my document. But for obvious reasons, I don’t want that. How do I pick a speciic symbol from a speciic font (with LuaLatex)? While still using PDFLatex, I used the pifont package to get the Dingbats character: \documentclass{article} \usepackage{pifont} \begin{document} \ding{113} \end{document} Doesn’t work for WingDings, though, which is why I switched to LuaLatex. However, not only did I understand that using such ”font packages” is deprecated with LuaLatex, but I also don’t have a clue how I’d go about picking a speciic symbol from the WingDings font... Tags: symbols (Prev Q) (Next Q) User: devsolar Answer by leo-liu Skip code block
977
\documentclass{article} \usepackage{fontspec} \newfontfamily\wingdingsfont{Wingdings} \newcommand\wingdings[1]{{\wingdingsfont\symbol{#1}}} \usepackage{fonttable} \begin{document} \wingdings{4ḷ} 123-4567-89ḷḷ \fonttable{Wingdings} \end{document} Tags: symbols (Prev Q) (Next Q)
Q: Printing backslash from a luacode* environment Tags: symbols (Prev Q) My irst attempt with LuaLaTex gave me some headache, trying to generate LaTex code from within LuaLaTex. This required me to print the backslash (to get a LaTeX control sequence).. I think I have found a solution now, but maybe this could also be of interest to others, so I try to post it here as question anyway.. (See also the following questions Printing LaTeX code in LuaTeX and How does one insert a backslash or a tilde into LaTeX?) From the luacode package documentation, page 2 it says: The variant luacode* goes further and makes even backslash a normal character Consider the following code: \documentclass{article} \usepackage{luacode} \begin{document} 978
\begin{luacode*} tex.sprint("\"); \end{luacode*} \end{document} Compiling this with lualatex gives the error ! LuaTeX error :1: unfinished string near '"");'. \luacode@dbg@exec ...code@maybe@printdbg {#1} #1 } Then I thought I just have to add another backslash to escape the irst: tex.sprint("\\"); But now I get the error: ! Undefined control sequence. l.1 Tags: symbols (Prev Q) User: håkon-hægland Answer by håkon-hægland The problem is that there are 3 interpretation stages involved. • First macro expansion (this is avoided in my example due to the luacode* environment) • Then Lua interprets the resulting string, where a backslash is an escape character • At last LaTex again interprets what Lua has printed.. I had forgotten the last stage.. So the solution is: tex.sprint("$\\backslash$"); or tex.sprint("\\textbackslash"); Tags: symbols (Prev Q) 979
Polyglossia Skip to questions, Wiki by user alan-munn If you are using XeLaTeX, you should load polyglossia instead of babel. The package does the following automatically: • Loading the appropriate hyphenation patterns. • Setting the script and language tags of the current font (if possible and available), via the package fontspec. • Switching to a font assigned by the user to a particular script or language. - Adjusting some typographical conventions according to the current language (such as afterindent, frenchindent, spaces before or after punctuation marks, etc.). • Redeining all document strings (like “chapter”, “igure”, “bibliography”). - Adapting the formatting of dates (for non-Gregorian calendars via external packages bundled with polyglossia: currently the Hebrew, Islamic and Farsi calendars are supported). • For languages that have their own numbering system, modifying the formatting of numbers appropriately (this also includes redeining the alphabetic sequence for non-Latin alphabets). • Ensuring proper directionality if the document contains languages that are written from right to left (via the package bidi, available separately). (Polyglossia documentation, p.2) Don’t be alarmed if your log ile mentions babel hyphenation patterns when you are using polyglossia. This is normal, and is due to how hyphenation patterns are loaded; it does not mean that the babel package has been loaded. 980
The homepage of polyglossia is at github.
Questions Q: Changing language back and forth with polyglossia Tags: polyglossia (Prev Q) (Next Q) I’m using polyglossia and lualatex to compile my source, and I am switching languages back and forth inside my document. It looks like polyglossia (or myself), is not doing what it is supposed to do: Skip code block \documentclass[12pt]{book} \usepackage{polyglossia} \setdefaultlanguage{english} \setotherlanguage{french} \begin{document} \textsc{url:} www. \\ \begin{french} \textsc{url:} www. \\ \end{french} \textsc{url:} www. \\ \end{document} First line prints ”url: www.” in English: OK. Second line prints ”url : www.” in French: OK. Third line prints ”url : www.” in English: not OK (there should not be a space before the colon). Am I doing something wrong ? Thank you. Tags: polyglossia (Prev Q) (Next Q) User: bigdawg Answer by ulrike-ischer 981
You can reset the ”nonfrench”-spacing with a \directlua-call. But it will afect the whole paragraph: Skip code block \documentclass[12pt]{book} \usepackage{polyglossia} \setdefaultlanguage{english} \setotherlanguage{french} \begin{document} \textsc{url:} www. \begin{french} \textsc{url:} www. \end{french} \directlua{polyglossia.desactivate_frpt()} \textsc{url:} www. \begin{french} \textsc{url:} www. \end{french} %affects the preceding french too: \directlua{polyglossia.desactivate_frpt()} \textsc{url:} www. \end{document} Answer by herbert Use babel instead: Skip code block \documentclass[12pt]{book} \usepackage[french,english]{babel} \begin{document} \textsc{url:} www.
982
\begin{otherlanguage}{french} \textsc{url:} www. \end{otherlanguage} \textsc{url:} www. \end{document} Tags: polyglossia (Prev Q) (Next Q)
Q: Macro deinition not working when using LuaLaTeX and polyglossia (with ‘\setmainlanguage{german}‘) Tags: polyglossia (Prev Q) I’m compiling the following MWE with LuaLaTeX in an updated TexLive 2017 installation on Ubuntu: Skip code block % !TeX program=lualatex \documentclass[a4paper,12pt,twoside=semi,openright]{scrbook} \usepackage{polyglossia} \setmainlanguage{german} \setotherlanguage{english} \usepackage{fontspec} \usepackage{subfig} \usepackage{amsmath} \usepackage{amssymb} \usepackage{bm} \renewcommand{\vec}[1]{\bm{#1}} \begin{document} 983
\begin{align} \vec{x} = 1 \end{align} \end{document} Here’s what I get:
The desired output would of course be x=1. Note that this fails only when using \setmainlanguage{german}. It also works ine using pdfLaTeX and babel. Skip code block *File List* scrbook.cls 2ḷ17/ḷ9/ḷ7 v3.24 KOMA-Script document class (book) scrkbase.sty 2ḷ17/ḷ9/ḷ7 v3.24 KOMA-Script package (KOMA-Script-dependent basi cs and keyval usage) scrbase.sty 2ḷ17/ḷ9/ḷ7 v3.24 KOMA-Script package (KOMA-Script-independent ba sics and keyval usage) keyval.sty 2ḷ14/1ḷ/28 v1.15 key=value parser (DPC) scrlfile.sty 2ḷ17/ḷ9/ḷ7 v3.24 KOMA-Script package (loading files) tocbasic.sty 2ḷ17/ḷ9/ḷ7 v3.24 KOMA-Script package (handling toc-files) scrsiḶe12pt.clo 2ḷ17/ḷ9/ḷ7 v3.24 KOMA-Script font siḶe class option (12pt) typearea.sty 2ḷ17/ḷ9/ḷ7 v3.24 KOMA-Script package (type area) polyglossia.sty 2ḷ15/ḷ3/25 v1.42.4 Alternative to Babel for XeLaTeX and LuaLa TeX etoolbox.sty 2ḷ17/ḷ1/ḷ2 v2.4 e-TeX tools for LaTeX (JAW) makecmds.sty 2ḷḷ9/ḷ9/ḷ3 v1.ḷa extra command making commands xkeyval.sty 2ḷ14/12/ḷ3 v2.7a package option processing (HA) xkeyval.tex 2ḷ14/12/ḷ3 v2.7a key=value parser (HA) fontspec.sty 2ḷ17/11/ḷ9 v2.6g Font selection for XeLaTeX and LuaLaTeX 984
xparse.sty 2ḷ17/11/14 L3 Experimental document command parser expl3.sty 2ḷ17/11/14 L3 programming layer (loader) expl3-code.tex 2ḷ17/11/14 L3 programming layer l3pdfmode.def 2ḷ17/ḷ3/18 v L3 Experimental driver: PDF mode fontspec-luatex.sty 2ḷ17/11/ḷ9 v2.6g Font selection for XeLaTeX and LuaLaTeX fontenc.sty tuenc.def 2ḷ17/ḷ4/ḷ5 v2.ḷi Standard LaTeX file fontspec.cfg ifluatex.sty 2ḷ16/ḷ5/16 v1.4 Provides the ifluatex switch (HO) ifxetex.sty 2ḷ1ḷ/ḷ9/12 vḷ.6 Provides ifxetex conditional luatexbase.sty 2ḷ15/1ḷ/ḷ4 v1.3 luatexbase interface to LuaTeX ctablestack.sty 2ḷ15/1ḷ/ḷ1 v1.ḷ Catcode table stable support gloss-german.ldf polyglossia: module for german babelsh.def 2ḷ13/ḷ4/3ḷ Babel common definitions for shorthands Taken verbatim from babel.def (2ḷ13/ḷ4/15 v3.9e) gloss-english.ldf polyglossia: module for english subfig.sty 2ḷḷ5/ḷ6/28 ver: 1.3 subfig package caption.sty 2ḷ16/ḷ2/21 v3.3-144 CustomiḶing captions (AR) caption3.sty 2ḷ16/ḷ5/22 v1.7-166 caption3 kernel (AR) amsmath.sty 2ḷ17/ḷ9/ḷ2 v2.17a AMS math features amstext.sty 2ḷḷḷ/ḷ6/29 v2.ḷ1 AMS text amsgen.sty 1999/11/3ḷ v2.ḷ generic functions amsbsy.sty 1999/11/29 v1.2d Bold Symbols amsopn.sty 2ḷ16/ḷ3/ḷ8 v2.ḷ2 operator names amssymb.sty 2ḷ13/ḷ1/14 v3.ḷ1 AMS font symbols amsfonts.sty 2ḷ13/ḷ1/14 v3.ḷ1 Basic AMSFonts support bm.sty 2ḷ17/ḷ1/16 v1.2c Bold Symbol Support (DPC/FMi) umsa.fd 2ḷ13/ḷ1/14 v3.ḷ1 AMS symbols A umsb.fd 2ḷ13/ḷ1/14 v3.ḷ1 AMS symbols B *********** Tags: polyglossia (Prev Q) User: christoph90 Answer by mico Under LuaLaTeX, the packages amsmath, amssymb, and bm should always be 985
loaded before both fontspec and polyglossia. (It also used to be standard to advise to load fontspec after any packages that modify math-related macros -- such as, of course, amsmath, amssymb, and bm. However, at some point in the recent past, an update to fontspec has occurred which no longer makes this recommendation a necessity.) If, for some reason, you simply must load polyglossia irst, then at least defer the instructions \setmainlanguage{...} and \setotherlanguage{...} to a point later on in the preamble, i.e., after amsmath, amssymb, bm and fontspec have been loaded. Do note that I deliberately started the answer with ”Under LuaLaTeX, ...”: I’m afraid I have no experience with package loading orderings under XeLaTeX. The following, modiied version of your MWE compiles ine: Skip code block % !TeX program=lualatex \documentclass[a4paper,12pt,twoside=semi,openright]{scrbook} \usepackage{amsmath,amssymb,bm} \usepackage{fontspec} \usepackage{polyglossia} % load it *after* amsmath, amssymb, bm, and fontspec \setmainlanguage{german} \setotherlanguage{english} \usepackage{subfig} % it doesn't seem to matter when this package is loaded \renewcommand{\vec}[1]{\bm{#1}} \begin{document} \[ \vec{x} = 1 \] \end{document} Answer by egreg The problem is that \setmainlanguage{german} sets " to a shorthand char986
acter and loading bm after that declaration completely breaks the deinitions made by the package when LuaLaTeX is used. The bizarre string you get is essentially random. Without loading subfig you get nothing (but no x either). Loading amsmath and bm before or after polyglossia is irrelevant, as long as the language declarations are made after package loading. Skip code block \documentclass{article} \usepackage{polyglossia} \usepackage{amsmath} \usepackage{amssymb} \usepackage{bm} \usepackage{subfig} \setmainlanguage{german} \renewcommand{\vec}[1]{\bm{#1}} \begin{document} $\vec{x}$ \end{document} Try moving \usepackage{bm} after \setmainlanguage{german} and the issue will appear again. Tags: polyglossia (Prev Q)
987
Shell Escape Skip to questions, Wiki by user user13907 If enabled, {shell-escape} mode allows the use of a list of commands which can be speciied using \write18{commandlist} in a .tex document. The command \write is a TeX primitive used to write to diferent streams. The use of stream 18 means that TeX is asking the operating system to do something. The use of \write18{} is usually disabled for security reasons. It must be enabled explicitly using latex --shell-escape texfile.
Questions Q: How should I have found out that LuaTeX removed \write18? Tags: shell-escape (Prev Q) (Next Q) I’m trying very hard not to make this sound like a rant, but I’m very angry right now. I was trying to use the TikZ externalization to create a scatter plot for my thesis. There were too many data points for TeX’s memory so I switched to LuaTeX. The externalization didn’t work. (MWE like: \documentclass{article} \usepackage{tikḶ} \usetikḶlibrary{external} \tikḶexternaliḶe \begin{document} \tikḶ\node{Hello}; \end{document} )
988
I had past experience with MiKTeX that suggested that changing -shell-escape to -enable-write18 can make a diference, as well as -enable-write18 vs --enable-write18. I spent literally half a day (remember, LuaTeX compilation times are still orders of magnitude slower on MiKTeX) trying to make it work and igure out why it doesn’t, changing the command line around as well as the value of tikḶ/external/shell escape. Nothing worked. Today I do a Google search and I ind the answer at https://github.com/ gpoore/minted/issues/112: There is no more \write18 in LuaTeX. You have to \usepackage{shellesc} which adds it back again. My question is, I’m trying to be a good user here and always RTFM. Where is TFM I should have read to ind out that this functionality was removed and how to add it back? To avoid spending half a day thinking I’m doing something wrong? Surely it’s not the Github issue of a completely unrelated package? Tags: shell-escape (Prev Q) (Next Q) User: marczellm Answer by egreg It’s a bit unfortunate that Christian Schenk deploys in MiKTeX new versions of the binaries (luatex in this case) as soon as they are available. TeX Live only changes (core) binaries with the yearly release and doesn’t modify them during the year (except for very serious bugs, but these are usually caught during the pretest phase). When LuaTeX 0.87 was released, many changes were made, in particular the one about \write18. If you look at LaTeX News 24, released February 2016, you’ll see
989
and also
Answer by ulrike-ischer The manual of luatex mentions the change: Also, we no longer support write18 because os.execute can do the 990
same. But I doubt very much that even if you had read this that you would have understand the implications and that it could afect tikzexternalize. The change happened last year and if you search this site for shellesc you will ind a number of questions (also involving texlive, it is not a miktex speciic problem, Cannot run tikz externalize with lualatex but it used to work). But again: even if you saw one of this questions during the year I wouldn’t expect from you to remember them and realize that they applicate to your current problem. So what could you do? Some tipps: • Changes happen, even more with new software like luatex. Accept this. • Not every change is obvious and can be learned by reading the manual. • Don’t try to solve your problems for hours alone. Search a bit and if you have the impression that you don’t make any progress then better spent your time to make a sensible minimal example and then ask. Answer by david-carlisle If using a beta release of software it’s best to follow its development channels as breaking changes are expected in beta releases. This was discussed on the luatex list before the change was made. (Not true of all breaking changes in luatex:-). For example this thread from November 2015 http://tug.org/ pipermail/luatex/2015-November/005499.html Without following the mailing list, this change was lagged in ltnews and also in the luatex manual. That said, in an ideal world an end user would not need to know this at all, we did search ctan for every use of \write18 that we could ind and try to reach out to package developers to update packages before the changed luatex was distributed in major distributions. The minted github issue that you referenced being one example of that. That there are still packages that require the end user to use shellesc (or luatex85) packages is a bit unfortunate but a possibly unavoidable result of the distributed nature of LaTeX package development. Packages are updated as and when the developers have time or inclination to publish an update. 991
Tags: shell-escape (Prev Q) (Next Q)
Q: gnuplottex and lualatex Tags: shell-escape (Prev Q) (Next Q) EDIT: This question covers a bug in gnuplottex which will be ixed in TeXLive 2013.If you still want to have the bug ixed, download the latest upstream version from CTAN and compile it yourself. Let gnu.tex Skip code block \documentclass[border=3mm]{standalone} \usepackage{gnuplottex} % use gnuplot \usepackage{epstopdf} % convert resulting eps to pdf \begin{document} \begin{gnuplot}[terminal=epslatex,terminaloptions=color] set xlabel '$x$' set ylabel '$y$' plot sin(x) title '$\sin x$' \end{gnuplot} \end{document} I am now trying to compile with lualatex; unfortuantely this doesn’t work. I called lualatex in the manner $ lualatex --shell-escape gnu.tex The log ile reads ... \write18 enabled. 992
... Package gnuplottex Warning: Shell escape not enabled. (gnuplottex) You'll need to convert the graphs yourself.. ... If I compile with pdflatex and the command line $ pdflatex --shell-escape gnu.tex it works just ine. Summary: Is gnuplottex incompatible with lualatex? Tags: shell-escape (Prev Q) (Next Q) User: henri-menke Answer by egreg I’d consider this a bug in gnuplottex.sty: the package tests shell escape by writing a ile in /tmp and assigning it a name without extension. TeX implementations may difer in the treatment of missing extensions in ile names, but should do the same thing when an extension is found. So if the test is Skip code block %% test if shell escape really works \ifShellEscape \def\tmpfile{/tmp/w18-test-\the\year\the\month\the\day\the\time.tex} \ifmiktex \def\tmpfile{w18-test-\the\year\the\month\the\day\the\time.tex} \immediate\write18{echo t > "\tmpfile"} \else \immediate\write18{touch \tmpfile} \fi \IfFileExists{\tmpfile}{\ShellEscapetrue}{\ShellEscapefalse} \ifmiktex \immediate\write18{del "\tmpfile"} \else \immediate\write18{rm -f \tmpfile} 993
\fi \fi all will work (I’ve added an explicit .tex extension). You can work around this bug by adding your own test: Skip code block \documentclass[border=3mm]{standalone} \usepackage{gnuplottex} % use gnuplot \usepackage{pdftexcmds,ifluatex} \makeatletter \ifluatex \ifnum\pdf@shellescape=\@ne \ShellEscapetrue \fi \fi \makeatother \usepackage{epstopdf} % convert resulting eps to pdf \begin{document} \begin{gnuplot}[terminal=epslatex,terminaloptions=color] set xlabel '$x$' set ylabel '$y$' plot sin(x) title '$\sin x$' \end{gnuplot} \end{document} You’ll still get the message, but the document will compile correctly when -shell-escape is given in the command line. You need LuaTeX version >0.67 for this workaround, though. Tags: shell-escape (Prev Q) (Next Q)
994
Q: Using macros in \DeclareGraphicsRule statement using shell command Tags: shell-escape (Prev Q) I am currently working on a document which i am compiling under both linux and windows. As one of the images I use is a tif image, I’d like to have lualatex converting it on-runtime to a format it understands. Therefore, I managed to do this under linux using \DeclareGraphicsRule{.tif}{png}{.png}% {% `convert #1 `dirname #1`/`basename #1 .tif`-tif-converted-to.png % } \AppendGraphicsExtensions{.tif} This however is not portable to windows because of the dirname and basename commands (as installing ImageMagick makes convert available). Therefore, I would like to use the ile parsing from latex to do this, but I could not ind my way around it. The code I am currently trying to use is : \makeatletter \newrobustcmd*\dirname[1]{\filename@parse{#1}\filename@area}% \newrobustcmd*\basename[1]{\filename@parse{#1}\filename@base}% \DeclareGraphicsRule{.tif}{png}{.png}% {% `convert #1 \dirname{#1}/\basename{#1}-tif-converted-to.png % }% \makeatother \AppendGraphicsExtensions{.tif} However, \DeclareGraphicsRule seems to just ignore I have used macros in my command. So my question is the following : • What am I doing wrong ? • Is there a way around it ? EDIT : Slightly changing the working command 995
Tags: shell-escape (Prev Q) User: samuel-albert Answer by heiko-oberdiek The conversion via shell escape is added by package epstopdf. In TeX Live it is automatically loaded, if pdfTeX/LuaTeX is detected in PDF mode and 1. LaTeX is running (plain TeX users are on their own), 2. and shell escape (\write18) is enabled (possibly restricted), 3. and \DoNotLoadEpstopdf either does not exist or is not \relax. For convenience the package epstopdf provides a macro to deine a graphics rule with conversion program (1.5.3 Conversion program): \epstopdfDeclareGraphicsRule{.tif}{png}{.png}{% convert #1 \OutputFile } Also the backtick notation with \DeclareGraphicsRule can be used: \DeclareGraphicsRule{.tif}{png}{.png}{% \noexpand\epstopdfcall{convert #1 \noexpand\OutputFile}% } • \noexpand is needd, because \DeclareGraphicsRule expands the argument. • \epstopdfcall deals with packages like pst2pdf. The name of the output ile \OutputFile is controlled by options. Since version 2009/07/12 v2.0 the default for option suffix is suffix=-\SourceExt-converted-to The suix is inserted after the base name and the new ile extension. foo.tif becomes foo-tif-converted-to.png. Answer by egreg Macros deined with \newrobustcmd (from etoolbox) are not expanded in \write operations. However \filename@parse relies on assignments which 996
aren’t performed in those operations. I suggest to deine
\def\eattif#1.tif{#1} \DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 \eattif#1-tif-converted-to.png } \AppendGraphicsExtensions{.tif} so that the extension will be swallowed (in an expandable fashion). Tags: shell-escape (Prev Q)
Pgfplots Questions Q: LuaLaTeX:PGFplots can’t read data passed by Lua Tags: pgfplots (Prev Q) (Next Q) I wanted to give a LuaLaTeX answer to this question Here it is the listing I wrote: Skip code block % !TEX encoding = UTF-8 % !TEX program = LuaLaTeX % !TEX spellcheck = en_GB \documentclass{standalone} \usepackage{pgfplots} \usepackage{luacode} \begin{luacode*} -- Code taken by 997
-- http://rosettacode.org/wiki/Gamma_function#Lua function recigamma(Ḷ) local gamma = ḷ.5772156649ḷ1 local coeff = -ḷ.655878ḷ7152ḷ56 local quad = -ḷ.ḷ42ḷḷ2635ḷ33944 local qui = ḷ.16653861138228 local set = -ḷ.ḷ42197734555571 return Ḷ+gamma*Ḷ^2+coeff*Ḷ^3+quad*Ḷ^4+qui*Ḷ^5+set*Ḷ^6 end function gamma(Ḷ) if Ḷ == 1 then return 1 elseif math.abs(Ḷ) ḷ then tex.print([[Result of mplib execute is unsuccessfull.]]) else if result.fig then tex.sprint('Converted something: \\vrule\\vbox{\\hrule') local converted=luamplib.convert(result) tex.sprint('\\hrule}\\vrule') else tex.print([[No figure output.]]) tex.print([[Log:]]) tex.print(l) end end mpx:finish() end I will try to improve (=shorten) it more. E.g., I believe that there is a way to use inder function from luamplib. Any comments are welcome. Tags: metapost (Prev Q), graphics (Prev Q) (Next Q) User: misha Answer by taco-hoekwater The ile mplibapi.pdf from the metapost source distrobution documents the low-level interface. Still, it is probably wise to read the luamplib code as 1019
well, because the conversion from mplib’s return table (containing images) to PDF literal code is not quite trivial. http://www.tug.org/metapost/src/ manual/mplibapi.pdf Tags: metapost (Prev Q), graphics (Prev Q) (Next Q)
Paragraphs Questions Q: Replacement(s) for TeX’s paragraph builder using LuaTeX Tags: paragraphs (Prev Q) (Next Q) The LuaTeX engine provides a callback that allows you to replace the built-in paragraph builder by your own algorithm. My question is twofold: • does there exist a lua implementation that fully (or partially) reimplements the normal algorithm that can be used as a basis for paragraph breaking experiences? • if not (or even if yes) are there any other known uses of this callback? Update Given that my irst part of the question was answered in the comments below, i.e., that Taco (I guess) has reimplemented the paragraph builder from TeX (with additions from pdfTeX and Omega/Aleph) in Lua). Can somebody perhaps show how to use this lua script in a simple plain TeX scenario? In other words how is this applied so that
i.prevgraf and iM1.prevgraf < i.prevgraf then -- Both +1 and -1 looseness would work LastLineColor = color_pm1 elseif iP1s.prevgraf > i.prevgraf and iM1.prevgraf < i.prevgraf then -- Both +1 and -1 looseness would work, but +1 only with emergency stretch LastLineColor = color_pm1s elseif iP1.prevgraf > i.prevgraf then -- Only +1 looseness would work LastLineColor = color_p1 1037
elseif iP1s.prevgraf > i.prevgraf then -- Only +1 looseness would work and only thanks to the emergency stretch LastLineColor = color_p1s elseif iM1.prevgraf < i.prevgraf then -- Only -1 looseness would work LastLineColor = color_m1 else LastLineColor = nil end end
return true
-- Callback to coloriḶe the last line of the paragraph when ColorLastLine is true local post_linebreak_color_last_line = function (head, groupcode) if LastLineColor then color_last_line(head) end return true end
-- Register callbacks luatexbase.add_to_callback("pre_linebreak_filter", pre_linebreak_test_looseness, " luatexbase.add_to_callback("post_linebreak_filter", post_linebreak_color_last_line Usage is then as follows: \documentclass{article} \usepackage{lipsum} \usepackage{luatexbase} \directlua{dofile("widow-assist.lua")} \begin{document} \lipsum[1-5] \end{document} Tags: paragraphs (Prev Q) (Next Q), page-breaking (Prev Q) (Next Q)
1038
Q: In LuaTeX, what is the “identity” linebreak_ilter? (Or: how can we use ‘tex.linebreak‘ to match the default line-breaking algorithm?) Tags: paragraphs (Prev Q) Consider the following LaTeX document (to be compiled with lualatex): Skip code block
\documentclass{article} \usepackage{lipsum} \begin{document} \directlua{ function shouldbenoop(head, isDisplay) return tex.linebreak(head) end } % \directlua{luatexbase.add_to_callback('linebreak_filter', shouldbenoop, 'This sh \lipsum \end{document} Whether or not the add_to_callback line is commented out, the output appears to be the same, that is our overridden linebreak ilter, which calls tex.linebreak, appears to do the same thing that TeX does by default. However, when we try the same with plain TeX (to be compiled with luatex): Skip code block
\input ltluatex % For luatexbase.add_to_callback \input plipsum \directlua{ function shouldbenoop(head, isDisplay) return tex.linebreak(head) end } % \directlua{luatexbase.add_to_callback('linebreak_filter', shouldbenoop, 'This sh \lipsum{1-2ḷ} 1039
\bye and use the linebreak ilter (uncomment the commented line above), the result looks bad, between paragraphs:
The paragraphs appear to overlap almost, and we need to set a higher \parskip to get “proper” results (of course they’re not proper in the sense that they difer from the result without using the linebreak ilter). The issue is not with loading ltluatex in plain, as the result is the same with this: Skip code block \input plipsum \directlua{ function shouldbenoop(head, isDisplay) return tex.linebreak(head) end } \directlua{callback.register('linebreak_filter', shouldbenoop)} \lipsum{1-2ḷ} \bye 1040
It also doesn’t have anything to do with plipsum, as it is reproducible by simply typing out paragraphs without loading the package. What is going on? And more importantly, what can we write as a linebreak_filter in plain TeX, that will perfectly reproduce the effect of the default line-breaking (that is, be identical to not having a linebreak_filter)? Tags: paragraphs (Prev Q) User: shreevatsar Answer by david-carlisle You need to reset (at least) \prevdepth something like this, otherwise \prevdepth gets the ”start of list” value of -1000pt and the following paragraph is set with no space before it. Skip code block \directlua{ function shouldbenoop(head, isDisplay) h,t =tex.linebreak(head) tex.prevdepth= t.prevdepth return h end } \directlua{callback.register('linebreak_filter', shouldbenoop)} \hsiḶe3cm \parindentḷpt g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g \showthe\prevdepth g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g g a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a 1041
a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a \bye Tags: paragraphs (Prev Q)
Texlive 2016 Skip to questions, Wiki by user martin-schröder The 2016 release of texlive introduced a number of incompatible changes, especially in luatex. Use this tag to track questions with these problems; if your problem is not speciic to changes in this release, use texlive instead.
Questions Q: LuaLaTeX, TeXLive 2016, standalone: undeined control sequence Tags: texlive-2016 (Prev Q) (Next Q) Since I installed TeXLive 2016 I cannot build documents with the standalone document class any more using LuaLaTeX (PDFLaTeX works ine). For example: \documentclass{standalone} \begin{document} hi \end{document} 1042
Gives me: ! Undefined control sequence. \sa@placebox ->\newpage \global \pdfpagewidth
=\wd \sa@box \global \pdfpageh...
l.4 \end{document} How to ix that? Tags: texlive-2016 (Prev Q) (Next Q) User: keelan Answer by egreg The ix is easy: add \RequirePackage{luatex85} as the very irst line, a temporary workaround until standalone is updated. It should do no harm even after the update. \RequirePackage{luatex85} \documentclass{standalone} \begin{document} hi \end{document} Answer by yan-zhou The easiest way is to load luatex85 package. You probably will need to load it before documentclass, using RequirePackage The longer story is that luatex now no longer deines many primitives with pdf preix. The luatex85 package deines aliases of primitives which have the same names as in pdftex and earlier versions of luatex. Tags: texlive-2016 (Prev Q) (Next Q)
1043
Q: datetime package does not work with lualatex in TL 2016 Tags: texlive-2016 (Prev Q) (Next Q) I am getting error compiling using lualatex under TL 2016 installed today when I use package datetime. This MWE works ok under TL 2015. How to resolve this error? It looks like the API to the datetime package has changed. \documentclass[11pt]{scrbook}%ext \usepackage{luatex85} %needed else gets an error with lualatex in 2ḷ16 \usepackage[us,12hr]{datetime} \begin{document} \currenttime \end{document} error is Skip code block lualatex foo.tex This is LuaTeX, Version ḷ.95.ḷ (TeX Live 2ḷ16) restricted system commands enabled. (./foo.tex LaTeX2e Babel and hyphenation patterns for 1 language(s) loaded. (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/koma-script/scrbook.cls Document Class: scrbook 2ḷ16/ḷ5/1ḷ v3.2ḷ KOMA-Script document class (book) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/koma-script/scrkbase.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/koma-script/scrbase.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/koma-script/scrlfile.sty Package scrlfile, 2ḷ16/ḷ5/1ḷ v3.2ḷ KOMA-Script package (loading files) Copyright (C) Markus Kohm ))) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/koma-script/tocbasic.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/koma-script/scrsiḶe11pt.clo) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/koma-script/typearea.sty Package typearea, 2ḷ16/ḷ5/1ḷ v3.2ḷ KOMA-Script package (type area) Copyright (C) Frank Neukam, 1992-1994 1044
Copyright (C) Markus Kohm, 1994)) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/luatex85/luatex85.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/datetime/datetime.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/etoolbox/etoolbox.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/fmtcount/fmtcount.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/ifthen.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/xkeyval/xkeyval.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/xkeyval/xkeyval.tex (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/xkeyval/xkvutils.tex))) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/fmtcount/fcprefix.sty (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/fmtcount/fcnumparser.sty)) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/ifxetex/ifxetex.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/amsmath/amsgen.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/fmtcount/fc-english.def)) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/datetime/datetime-defaults.sty) ! Use of \@dt@getdate doesn't match its definition. \pdfcreationdate ->\pdffeedback creationdate l.233 } ? Compiles ok with pdlatex in TL 2016 and compiles OK with lualatex in 2015: \documentclass[11pt]{scrbook}%ext \usepackage[us,12hr]{datetime} \begin{document} \currenttime \end{document} No error: Skip code block lualatex foo.tex This is LuaTeX, Version beta-ḷ.8ḷ.ḷ.1 (TeX Live 2ḷ15) (rev 5863) restricted \write18 enabled. (./foo.tex 1045
LaTeX2e patch level 2 Babel and hyphenation patterns for 79 languages loaded. (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/koma-script/scrbook.cls Document Class: scrbook 2ḷ15/1ḷ/ḷ3 v3.19a KOMA-Script document class (book) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/koma-script/scrkbase.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/koma-script/scrbase.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/koma-script/scrlfile.sty Package scrlfile, 2ḷ15/1ḷ/ḷ3 v3.19a KOMA-Script package (loading files) Copyright (C) Markus Kohm ))) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/koma-script/tocbasic.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/koma-script/scrsiḶe11pt.clo) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/koma-script/typearea.sty Package typearea, 2ḷ15/1ḷ/ḷ3 v3.19a KOMA-Script package (type area) Copyright (C) Frank Neukam, 1992-1994 Copyright (C) Markus Kohm, 1994)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/datetime/datetime.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/etoolbox/etoolbox.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/fmtcount/fmtcount.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/base/ifthen.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/xkeyval/xkeyval.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/xkeyval/xkeyval.tex (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/xkeyval/xkvutils.tex))) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/fmtcount/fcprefix.sty (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/fmtcount/fcnumparser.sty)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/generic/ifxetex/ifxetex.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/amsmath/amsgen.sty) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/fmtcount/fc-english.def)) (/usr/local/texlive/2ḷ15/texmf-dist/tex/latex/datetime/datetime-defaults.sty)) No file foo.aux. [1{/usr/local/texlive/2ḷ15/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./foo.aux)) 275 words of node memory still in use: 2 hlist, 1 vlist, 1 rule, 2 glue, 43 glue_spec, 1 write nodes avail lists: 1:3,2:26,3:2,4:25,5:3,6:32,7:2,9:12,1ḷ:3 which latex /usr/local/texlive/2ḷ16/bin/x86_64-linux/latex >which make4ht /usr/local/texlive/2ḷ16/texmf-dist/scripts/make4ht/make4ht The irst ile I tried to compile gives error. I’d like to ask what does a user need to change or add to make tex4ht work under TL 2016. I use lua as option in all my builds using make4ht. Here is a MWE \documentclass[11pt]{article}% \usepackage[utf8]{inputenc} \begin{document} test \end{document} Error is Skip code block make4ht --lua foo.tex Output dir: Compiler: dvilualatex Latex options: -jobname=foo tex4ht.sty : xhtml, tex4ht build_file foo.mk4 Cannot open config file foo.mk4 setting param correct_exit setting param correct_exit setting param correct_exit 1048
setting param ext Adding: ext dvi LaTeX call: dvilualatex -jobname=foo '\makeatletter\def\HCode{\futurelet\HCode\H This is LuaTeX, Version ḷ.95.ḷ (TeX Live 2ḷ16) restricted system commands enabled. LaTeX2e Babel and hyphenation patterns for 1 language(s) loaded. (./foo.tex (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/article.cls Document Class: article 2ḷ14/ḷ9/29 v1.4h Standard LaTeX document class (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/siḶe11.clo)) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/tex4ht.sty) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/usepackage.4ht) (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/inputenc.sty Package inputenc Warning: inputenc package ignored with utf8 based engines. ) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/tex4ht.4ht :::::::::::::::::::::::::::::::::::::::::: TeX4ht info is available in the log file :::::::::::::::::::::::::::::::::::::::::: ) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/tex4ht.sty --- needs --- tex4ht foo --(./foo.tmp) (./foo.xref) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/latex.4ht (/usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/html4.4ht ! String contains an invalid utf-8 sequence. l.1267 \Configure{tableofcontents} ? It works if remove --lua option. But I need to use this option and it works in TL 2015. The above error also shows up if I remove \usepackage[utf8]{inputenc} File compiles OK with lualatex 2016 1049
Skip code block lualatex foo.tex This is LuaTeX, Version ḷ.95.ḷ (TeX Live 2ḷ16) restricted system commands enabled. (./foo.tex LaTeX2e Babel and hyphenation patterns for 1 language(s) loaded. (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/article.cls Document Class: article 2ḷ14/ḷ9/29 v1.4h Standard LaTeX document class (/usr/local/texlive/2ḷ16/texmf-dist/tex/latex/base/siḶe11.clo)) (./foo.aux) [1{/usr/local/texlive/2ḷ16/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] (./foo.aux)) 346 words of node memory still in use: 2 hlist, 1 vlist, 1 rule, 7 glue, 39 glue_spec, 1 write nodes avail lists: 1:1,2:12,3:2,4:1,5:1ḷ,6:6,7:22,8:1,9:6
Output written on foo.pdf (1 page, 1ḷ4ḷḷ bytes). Transcript written on foo.log. File also compiled OK with make4ht --lua under TL 2015: Skip code block
make4ht --lua foo.tex Output dir: Compiler: dvilualatex Latex options: -jobname=foo tex4ht.sty : xhtml, tex4ht build_file foo.mk4 Cannot open config file foo.mk4 setting param correct_exit setting param correct_exit setting param correct_exit setting param ext Adding: ext dvi LaTeX call: dvilualatex -jobname=foo '\makeatletter\def\HCode{\futurelet\HCode\H This is LuaTeX, Version beta-ḷ.8ḷ.ḷ.1 (TeX Live 2ḷ15) (rev 5863) restricted \write18 enabled. 1050
LaTeX2e patch level 2 ...... parse_lg process file: foo.css outdir: parse_lg process file: foo.tmp tmp file Tags: texlive-2016 (Prev Q) (Next Q), tex4ht (Next Q) User: nasser Answer by egreg The ile /usr/local/texlive/2ḷ16/texmf-dist/tex/generic/tex4ht/html4.4ht contains a spurious character in line 1267 1265 \let\sv:etoc\e:tableofcontents 1266 % 1267 \Configure{tableofcontents} 1268 {\IgnorePar\EndP\HCode{}\IgnorePar} The output was obtained with LESSCHARSET=ascii less -N $(kpsewhich html4.4ht) Make a local copy, edit the ile placing the cursor at the backslash in \Configure and remove the preceding character. If the edited copy is in the working directory, compilation succeeds. Tags: texlive-2016 (Prev Q) (Next Q), tex4ht (Next Q)
Q: lualatex texlive 2016 tcolorbox Tags: texlive-2016 (Prev Q) (Next Q), tcolorbox (Prev Q) (Next Q) If you compile with tl2016 lualatex this MWE
1051
Skip code block \documentclass[1ḷpt, xcolor=svgnames, x11names,
t]{beamer}
\usepackage{etoolbox} \usepackage{ifluatex} \ifluatex \usepackage[no-math]{fontspec} \usepackage[EU2]{fontenc} \usepackage{lualatex-math} \else \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \fi \usepackage{mathtools} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{bm} \ifluatex \setsansfont[Ligatures=TeX, ItalicFont={MyriadPro-SemiCnIt.otf}, BoldFont={MyriadPro-BoldSemiCn.otf}, BoldItalicFont={MyriadPro-BoldSemiCnIt.otf}, SmallCapsFont={Delicious-SmallCaps.otf} ]{MyriadPro-SemiCn.otf} \else \usefonttheme{professionalfonts} \usepackage[condensed, scale]{tgheros} \fi \normalfont \usepackage[listings,theorems,skins, raster, breakable]{tcolorbox} \ifluatex \newtcblisting{mydocument}{% 1052
left skip=-4.2pt,width=1.ḷ1\linewidth, sharp corners,% beforeafter skip=ḷ.5\baselineskip,% leftlower=ḷpt,rightlower=ḷpt,% lower separated=false,middle=ḷpt,% colframe=blue, enhanced, % interior style={top color=yellow!5!white,bottom color=yellow!5!white},% righthand width=4cm,halign=left,% pdf comment,% listing side comment,% compilable listing,% run lualatex} \else \newtcblisting{mydocument}{% left skip=-4.2pt,width=1.ḷ1\linewidth, sharp corners,% beforeafter skip=ḷ.5\baselineskip,% leftlower=ḷpt,rightlower=ḷpt,% lower separated=false,middle=ḷpt,% colframe=blue, enhanced, % interior style={top color=yellow!5!white,bottom color=yellow!5!white},% righthand width=4cm,halign=left,% pdf comment,% listing side comment,% compilable listing,% run pdflatex} \fi \begin{document} \begin{frame}[fragile]{TCB} \begin{mydocument} \documentclass[border=1ḷpt]{standalone} \begin{document} Hello% world. Hello world. \end{document} 1053
\end{mydocument} \end{frame} \end{document} you have this error: Package tcolorbox Error: PDF file `mwebeamersans-listin g-1.pdf' not found. The ile name is mewbeamersans.tex. With pdlatex the compilation is ok. With TL2015 and lualatex also the compilation is ok. Any help? Tags: texlive-2016 (Prev Q) (Next Q), tcolorbox (Prev Q) (Next Q) User: jpayansomet Answer by egreg It’s better to minimize the example. The error appears also with Skip code block \documentclass[1ḷpt, xcolor=svgnames, x11names,
t]{beamer}
\usepackage{fontspec} \usepackage[listings,theorems,skins, raster, breakable]{tcolorbox} \newtcblisting{mydocument}{% left skip=-4.2pt,width=1.ḷ1\linewidth, sharp corners,% beforeafter skip=ḷ.5\baselineskip,% leftlower=ḷpt,rightlower=ḷpt,% lower separated=false,middle=ḷpt,% colframe=blue, enhanced, % interior style={top color=yellow!5!white,bottom color=yellow!5!white},% righthand width=4cm,halign=left,% pdf comment,% listing side comment,% compilable listing,% 1054
run lualatex} \begin{document} \begin{frame}[fragile]{TCB} \begin{mydocument} \documentclass[border=1ḷpt]{standalone} \begin{document} Hello% world. Hello world. \end{document} \end{mydocument} \end{frame} \end{document} if compiled with lualatex -shell-escape. You need to add \usepackage{shellesc}, but you also need some adjustment for standalone, because it has not been updated to take into consideration that \pdfpagewidth and \pdfpageheight have been renamed to \pagewidth and \pageheight. This can be solved by using a ile named standalone.cfg in the same directory as your main ile containing \ifdefined\pdfpagewidth \else \let\pdfpagewidth\pagewidth \let\pdfpageheight\pageheight \fi You can produce it automatically if you use filecontents: Skip code block \begin{filecontents}{standalone.cfg} \ifdefined\pdfpagewidth \else \let\pdfpagewidth\pagewidth \let\pdfpageheight\pageheight \fi 1055
\end{filecontents} \documentclass[1ḷpt, xcolor=svgnames, x11names,
t]{beamer}
\usepackage{shellesc} \usepackage{fontspec} \usepackage[listings,theorems,skins, raster, breakable]{tcolorbox} \newtcblisting{mydocument}{% left skip=-4.2pt,width=1.ḷ1\linewidth, sharp corners,% beforeafter skip=ḷ.5\baselineskip,% leftlower=ḷpt,rightlower=ḷpt,% lower separated=false,middle=ḷpt,% colframe=blue, enhanced, % interior style={top color=yellow!5!white,bottom color=yellow!5!white},% righthand width=4cm,halign=left,% pdf comment,% listing side comment,% compilable listing,% run lualatex} \begin{document} \begin{frame}[fragile]{TCB} \begin{mydocument} \documentclass[border=1ḷpt]{standalone} \begin{document} Hello% world. Hello world. \end{document} \end{mydocument} \end{frame} \end{document}
1056
An alternative to writing standalone.cfg is to add \RequirePackage{luatex85} to the document you want to compile Skip code block \begin{mydocument} \RequirePackage{luatex85} \documentclass[border=1ḷpt]{standalone} \begin{document} Hello% world. Hello world. \end{document} \end{mydocument} 1057
Tags: texlive-2016 (Prev Q) (Next Q), tcolorbox (Prev Q) (Next Q)
Q: Error using pdfpages and lualatex Tags: texlive-2016 (Prev Q) After upgrading to Tex Live 2016/Debian i get errors when using the package pdfpages and compiling with Lualatex. If i try to compile \documentclass[a4paper,portrait]{article} \usepackage{pdfpages} \usepackage{pgffor} \includepdf{document.pdf} i get the errors Skip code block ! Undefined control sequence. \AtBegShi@horigin ->\pdfhorigin ! Missing number, treated as Ḷero.
\relax ! Illegal unit of measure (pt inserted).
\relax ! Undefined control sequence. \AtBegShi@vorigin ->\pdfvorigin (these are not the complete error messages, just the parts i think are important) I get no errors compiling with pdlatex. The versions i’m using are
1058
Package: pdfpages 2ḷ16/ḷ4/19 vḷ.5f pdfTeX, Version 3.14159265-2.6-1.4ḷ.17 LuaTeX, Version ḷ.95.ḷ Is this some sort of bug, or has something changed in the way pdfpages should be used? Tags: texlive-2016 (Prev Q) User: joão-gândara Answer by daleif LuaTeX has changed quite a lot this year. Among other things the LuaTeX developers removed a lot of known (pdf)primitives from pdfTeX. Thus several packages that make use of these primitives need to be updated. Alternatively you can add the luatex85 package, which will reintroduce thise ”missing” primitives. Tags: texlive-2016 (Prev Q)
Beamer Skip to questions, Wiki by user stefan-kottwitz This tag deals with the beamer class, which is used for creating presentations and slides. For questions about presentations or slides in general, independent of the document class, use presentations. For more information about beamer, see the project page on github.
1059
Questions Q: pdfx, beamer and lua(la)tex: is it possible? Tags: beamer (Prev Q) MWE: Skip code block \documentclass{beamer} %\usepackage[x-1a]{pdfx} \begin{document} \section{Présentation} \begin{frame}{First Frame} Hello, world! \end{frame} \section{Techniques} \begin{frame}{First Frame} Hello, world! \end{frame} \section{Mise en œuvre} \begin{frame}{First Frame} Hello, world! \end{frame} \section{Démonstration} \begin{frame}{First Frame} Hello, world! \end{frame} \section{Conclusions} \begin{frame}{First Frame} Hello, world! \end{frame} \end{document} This example compiles successfully (albeit with the annoyances associated with using non-ASCII characters). However, when I enable pdfx, I am 1060
plagued by these errors: ! LaTeX Error: Option clash for package xcolor. See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ... l.730 \else or (in this case using a-1b): ! Package kvsetkeys Error: Undeined key ‘pdftex,pdfa,pdfversion=1.4’. See the kvsetkeys package documentation for explanation. Type H for immediate help. ... l.806 } % Is it possible to use pdfx with the beamer class? Tags: beamer (Prev Q) User: amyspark Answer by egreg The error for xcolor can be cured by \documentclass[xcolor={cmyk,hyperref}]{beamer} The main error about the minor version is cured by \usepackage[pdf15,x-1a]{pdfx} More diicult is to ix the kvsetkeys error, which is due to bad programming in pdfx.sty. I copied the ile and changed all occurrences of \hypersetup{\pdfx@...} (where ... is variable text) with \expandafter\hypersetup\expandafter{\pdfx@...} because \hypersetup doesn’t expand its argument. There are nine replacements to do. Since this is not wrapped in a macro, but is code executed during loading of the package, there’s no other way than ixing the package. 1061
File a bug report, the code is wrong to begin with. Disclaimer. Whether this makes a valid PDF/X ile I don’t know. Tags: beamer (Prev Q)
Programming Questions Q: LaTeX3 versus pure Lua Tags: programming (Prev Q) (Next Q), latex3 (Prev Q) (Next Q) Reading this site for the last nearly two years I’ve learned a lot about LaTeX3 (which I had previously understood to be a defunct pipe dream) and LuaTeX (of which I was previously totally unaware). As I have said before, TeX itself is a bad programming language, though a good typesetting engine, but even as a typesetting engine, it is hobbled by its limitations as a language. What I mean by both of these, in short, is that it does not provide an easy way to manipulate its own representations of data. Others have also had this problem, and sometimes it can be solved with LuaTeX, which opens up a lot of the internals to the programming environment. Now, as I understand it, LaTeX3 also provides a lot of programming tools within TeX, with the aim of making package creation and maintenance more robust. Joseph Wright has explained this in at least one place (and therefore probably many more). These are ”algorithmic” tools, while the direction of LuaTeX development appears to be ”data structure” tools. Of course, Lua is also a general-purpose programming language and as such provides perfectly good algorithmic tools as well. My question: Why use LaTeX3 programming over Lua, when LuaTex is available? 1062
I understand that LuaTeX is very much experimental now, but then, so is LaTeX3. I also understand that as a result, LuaTeX is not necessarily used by anyone ”ordinary”, but then, it is intended as the ultimate successor to pdfTeX, which is now the default engine in the major TeX distributions. For all the reasons that TeX is a terrible programming language, LaTeX3 will still sufer from irritating expansion issues, lack of arithmetic capabilities, poor (or at least poor man’s) variables, and so on. However, Knuth himself has written that he would have used a better language if one had been available. Now that ”we” are inserting Lua into the TeX executable it appears that this alternative has been identiied (ironically, that link is about PyTeX, based on Python). Now that \directlua is feasible, I don’t see why it is not better in every way simply to make all ”function” macros (those that do not directly store text) hook into that one primitive and then do all their programming in Lua. Loops, variables, recursion, and so on can all be done in a comprehensible way. A lot of efort in the development of LaTeX3 appears to be in managing the programming language and its use. So, I ask again: Why use LaTeX3 to program at all? Why not turn its development into the development of a LaTeX-style document design library for LuaTeX, written in Lua? This suggests a related question to me: Is the separation of LuaTeX and LaTeX3 a result (or at least an artifact) of the non-communication among developers that Ahmed Musa described in his comment to this answer? What kind of cooperation is there between these two projects to reduce duplication of efort? (An even more fantastical notion is to implement every primitive, except \directlua itself, in terms of Lua and various internal typesetting parameters, thus completely divorcing the programming side of TeX from the typesetting side. Then TeX itself would be a ”macro package” on top of LuaTeX and one would not be bound to its strange design choices. An answer to why that should or should not be done might be too long for me to request, however.) I don’t personally think that this is too bloggy for this site, and I hope others agree. At least, given the conluence of expertise here, it seems to be the best 1063
place to ask the question. I have accepted Frank Mittelbach’s answer, though all the answers are extremely informative, because I think it hits all the main points most directly. One thing that neither it nor Joseph Wright’s answer quite manages to come out and say directly is that ConTeXt does do the Lua-programming thing at least to some extent, and it does not solve all algorithmic problems because LuaTeX does not actually rewrite the underpinnings of TeX so much as stitch in a Lua layer that can interact with them. I guess the one-line answer to my question is that my expectations of LuaTeX are much more grand than its reality, much like my ”fantastical” idea. Tags: programming (Prev Q) (Next Q), latex3 (Prev Q) (Next Q) User: ryan-reich Answer by frank-mittelbach (I guess I could be called a member of one of the teams ;-) this is my view) I thought of staying out of this debate, but perhaps some words of clariication or, let’s say, some thoughts are in order after all. LaTeX3 versus pure Lua First of all this is the wrong question imho: LaTeX3 has diferent goals to LuaTeX and those goals may well be still a defunct pipe dream, but if so they are unlikely to be resolved by pure Lua either. So if one wants to develop an argument along those lines then it should be more like ”Why does LaTeX3 use an underlying programming language based on eTeX and not on LuaTeX where a lot of functionality would be available in a ”simpler” way?” But LaTeX3 is really about three to four diferent levels • • • •
underlying engine programming level typesetting element layer designer interface foundation layer 1064
• document representation layer See for example my talk at TUG 2011: http://www.latex-project.org/ papers/ Here is a sketch of the architecture structure:
The chosen underlying engine (at the moment is any TeX engine with eTeX extension). The programming level is what we call ”expl3” and that is what I guess you are referring to if you say ”LaTeX3” (and I sometimes do that too). However, it is only the bottom box in the above diagram. The more interesting parts are those that are above the programming level (and largely a pipe dream but moving nicely along now that the foundation on the programming level is stable). And for this part there is no comparison against Lua. Why use LaTeX3 programming over Lua, when LuaTeX is avail1065
able? To build the upper layers it is extremely important to have a stable underlying base. As @egreg mentioned in chat: compare the package situation in 2.09 to the package situation in 2e. The moment there were standard protocols to build and interface packages the productivity increased a lot. However, the underlying programming level in 2e was and is still a mess which made a lot of things very complicated and often impossible to do in a reliable manner. Thus the need for a better underlying programming layer. However, that programming layer is build on eTeX not because eTeX is the superior engine (it is compared to TeX but not with respect to other extensions, be it Lua or some other engine) but because it is a stable base available everywhere. So eTeX + expl3 is a programming layer that the LaTeX3 team can rely on of not being further developed and changed (other than by us). It is also a base that is immediately available to everybody in the TeX world with the same level of functionality as all engines in use are implementing eTeX extensions. Any larger level of modiications/improvements in the underlying engine is a hindrance to build the upper layers. True, some things may not work and some things may be more complicated to solve but the tasks we are looking at (well I am) the majority are very much independent of that layer anyway. To make a few examples: • good algorithms for automatically doing complex page layout aren’t there (as algorithms) so Lua will not help you here unless somebody comes up with such algorithms irst. • something like ”coins”, is thinking about approaching ”design” and the importance here is how to think about it now how to implement it (that comes second) -- see Is there no easier way to loat objects and set margins? or LaTeX3 and pauper’s coins for examples Having said that, the moment LuaTeX would be stable similar to eTeX (or a subset of LuaTeX at least) there might well good reasons for replacing the underlying engine and the program layer implementation. But it is not the focus (for now). 1066
Why use LaTeX3 to program at all? Why not turn its development into the development of a LaTeX-style document design library for LuaTeX, written in Lua? Could happen. But only if that ”LuaTeX” would no longer be a moving target (because LaTeX3 on top would be moving target enough). Side remark: @PatrickGundlach in his answer speculated that this answer that the LaTeX3 goal is backwards compatibility. Wrong. The same people that are coming down on you very strong about compatibility for LaTeX2e have a diferent mindset here. We do not believe that the interesting open questions that couldn’t get resolved for 2e could be resolved in any form or shape with LaTeX3 in a document-compatible manner. Input compatible: probably. But output compatibility for old documents, no chance if you want to get anything right. But in any case, this is not an argument for or against implementing the ideas we are working on one day with a LuaTeX engine. Is the separation of LuaTeX and LaTeX3 a result (or at least an artifact) of the non-communication among developers that Ahmed Musa described in his comment to this answer? What kind of cooperation is there between these two projects to reduce duplication of efort? As I tried to explain, there is not much overlap in the irst place. There is much more overlap in conceptual ideas on the level ConTeXt viz. LaTeX. An even more fantastical notion is to implement every primitive, except \directlua itself, in terms of Lua and various internal typesetting parameters, thus completely divorcing the programming side of TeX from the typesetting side. That brings us to a completely diferent level of discussion, namely is based on LuaTeX, or anything else for that matter, a completely diferent approach to a typesetting engine possible? That is a very interesting thought, but as @Patrick explained it isn’t done with leaving TeX to do the typesetting and do everything else in a diferent language. So far such concepts have failed whether it was NTS or anything else because fundamentally (in my believe) we haven’t yet grasped how to come up with a successful and diferent model for the TeX macro approach (as ugly as it might look in places). 1067
Answer by joseph-wright Both Patrick and Frank have provided good answers: I’d like to add a few complementary points which seem too long for comments. One aspect of expl3 that is important is that it can be used now to program LaTeX2e packages (the ’l3in2e’ approach). That is seen for example in my own siunitx package, which I would not want to make LuaTeX-only. A particularly important aspect to this is xparse, which is proving to be popular with a reasonable number of users who probably don’t care about the programming internals. This use of LaTeX3 code is dependent on being usable with a good range of the currently-available engines. A second aspect is that LuaTeX does not mean you need no TeX programming at all. TeX is still there doing the typesetting, but also things like argument grabbing. (On the later, I asked the ConTeXt people about this once as I wondered about the old verbatim-in-arguments issue.) So improved TeX programming is still a good idea, even if you decided to go LuaTeX-only. Now, the nature of the structures you need would doubtless be diferent in that case, but again you can’t simply ignore it. Finally, there are practical considerations. A lot of the work on expl3 was done well before LuaTeX began, or certainly before it started reaching a more stable state. So to move from expl3 to Lua now would not really cut down on the work we need to do today, which as Frank says is mainly about higherlevel issues. A lot of what needs to be done seems to me to be relatively insensitive to the choice of language: it seems unlikely that a switch to Lua would suddenly accelerate development. Answer by topskip (I am not a member of either team, this is my view.) LaTeX3 is not only about providing a better output routine, but also about providing programming tools such as the famous quicksort algorithm (see l3prg.sty). This is obviously nicer to write in Lua (for most of us). Or consider string manipulation / regular expressions. This could be handled in Lua as well. But strictly speaking, one doesn’t need Lua for that. 1068
Why use LaTeX3 to program at all? Why not turn its development into the development of a LaTeX-style document design library for LuaTeX, written in Lua? As I understand LaTeX3, one of its major goals is keeping backwards compatibility. While other documentation approaches are surely much appreciated in todays world (XML typesetting with CSS formatting for example), they would break existing documents. This is not what the LaTeX3 team wants. What kind of cooperation is there between these two projects to reduce duplication of efort? I can’t see much communication between the two projects. LaTeX3 is aimed at ”working with all engines that have the eTeX extensions”. This implies that no engine speciic code must be used (that is: functionality that behaves diferently under diferent engines). Therefore there is no obvious need for LuaTeX speciic code. An even more fantastical notion is to implement every primitive, except \directlua itself, in terms of Lua and various internal typesetting parameters, thus completely divorcing the programming side of TeX from the typesetting side. Lua does not do any macro expansion / replacement, you need TeX for that. It is not possible to delegate all work to Lua, you will need the TeX part of LuaTeX. On the other hand, both LaTeX and Lua ofer control structures such as loops or if/then/else clauses (LaTeX3 even more). Therefore you don’t need Lua at all. If you mix control structures from Lua and TeX, the programming can get ugly, because you need to switch back and forth between TeX and Lua. Currently this is only possible with coroutines but may be easier in the future. LuaTeX’s great power in LaTeX lies in the manipulation of the (pre) typeset material. Tags: programming (Prev Q) (Next Q), latex3 (Prev Q) (Next Q)
1069
Q: How to access the last line of a paragraph with LuaTeX Tags: programming (Prev Q) (Next Q) Consider the following code, using traditional TeX programming that through a series of boxing and unboxing, grabs the last line of a paragraph and centers it. Skip code block \documentclass{article} \usepackage{lipsum} \begin{document} \def\centerlastline#1{% \bgroup \setboxḷ=\vbox{\bfseries\noindent #1}% \setbox1=\vbox{% \unvboxḷ \setbox2=\lastbox \hbox to \linewidth{\hfill\unhbox2 \hfill}% }% \unvbox1 \egroup }% \centerlastline{\lipsum[3]} \end{document} How can achieve the same using LuaTeX’s access to the paragraph builder and its nodes? Tags: programming (Prev Q) (Next Q) User: yiannis-lazarides Answer by michal.h21 After too many hours of failed attempts I got a working solution. The problem was in setting correct values to glue nodes. Documentation on this is unfortunately lacking, so I spent too much time hacking node dumps, but this lead to nowhere. 1070
Skip code block \documentclass{article} \usepackage{lipsum} \usepackage{luatexbase} % we will use node attributes to start/stop processing of paragraphs. % This is the most flexible way to support multiple paragraphs at once \newluatexattribute\centerattr \directlua{% luatexbase.add_to_callback("post_linebreak_filter", function(head) local first_glyph = function(h) for i in node.traverse_id(37,h) do return i end end local get_last = function(head, id) local x = node.count(id, head) for n in node.traverse_id(id,head) do x = x - 1 if x == ḷ then return n end end return false end % get last line local n = get_last(head,ḷ) local attr_num = luatexbase.attributes.centerattr local attr_val = node.has_attribute(n, attr_num) or ḷ if attr_val < 1 then return head end % make hfill glue local make_hfill = function() local hfill = node.new("glue") hfill.spec = node.new("glue_spec") hfill.spec.stretch = 2^15 % set stretch_order to glue_order value of parent hlist hfill.spec.stretch_order = n.glue_order %3 return hfill end
1071
local hfill = make_hfill() local hfill2 = make_hfill() % add first hfill at the beginning hfill.next = n.head local last_glyph = get_last(hfill, 1ḷ) hfill2.next = last_glyph.next % and second hfill at the end last_glyph.next= hfill2 n.head = hfill return head end, "center last line")
} \begin{document} \def\luacenterlastline#1{% \bgroup \centerattr=1 \bfseries\noindent #1% \egroup } \luacenterlastline{\lipsum[3]} \lipsum[3] \noindent hello world \centerattr=1 \noindent hello world \end{document}
I decided to use diferent approach than was used in Yannis’s example with box processing. Node processing callbacks are used, as it enables much more lexibility. We can have process multiple paragraphs at once, or even whole document. To direct processing, node attributes are used. This is new concept in LuaTeX, we can declare the attribute and assign a value to it and all following nodes will have attribute set to this value. Using luatexbase package, we can declare new attribute and assign a value with 1072
\newluatexattribute\centerattr \centerattr=1 on the Lua side, we can get attribute number and value with: local attr_num = luatexbase.attributes.centerattr local attr_val = node.has_attribute(n, attr_num) or ḷ attributes are numbers, so we irst have to get attribute number from name used on LaTeX side, and then get value of the attribute with this number of node n. if
attr_val < 1 then return head end
with this condition we return node list unchanged if attribute is unset or when we set it to 0 manually. Now we must decide which node callback we shall use. for processing paragraphs after linebreak, post_linebreak_filter is used. Structure of node list we can access in this callback is following: hlist glue hlist ... hlist is a horizontal box, with child nodes accessible in head ield. glue here is from \baselineskip. It is quite easy to get the last line using this function: local get_last = function(head, id) local x = node.count(id, head) for n in node.traverse_id(id,head) do x = x - 1 if x == ḷ then return n end end return false end head is node list to be processed and id is node type to be processed. So we can get last hlist with local n = get_last(head,ḷ) 1073
Now the hard thing, which I don’t still ready understand and which I found after lot of experimenting. hfill type of glue: local make_hfill = function() local hfill = node.new("glue") hfill.spec = node.new("glue_spec") hfill.spec.stretch = 2^15 % set stretch_order to glue_order value of parent hlist hfill.spec.stretch_order = n.glue_order %3 return hfill end With this function, two glue nodes are created, one is added at the beginning of the node list, second at the end, so the contents will be centered. Now I will explain problems that I had before I found this solution: when I inspected nodes inserted with \hfill command, they had these values of spec: stretch = 2^16 stretch_order = 3 when I added glue nodes with these values to the node list, nothing happened. later I found that value of stretch_order must be the same as value of glue_order of parent hlist. hlist which contained explicit \hfill had value of glue_order equal to 3, but normal hlists had glue_order set to 2, so no shrinking was applied. I don’t really know why, some experts on TeX internals will hopefully explain that. So I changed value of stretch_order to be the same as glue_order. But now the lines were lush right, ignoring second hfill node. Then I played with stretch value and found that value of 2^15 works. I don’t know why doesn’t work 2^16, when nodes inserted by \hfill have this value. After realizing correct values for hill glue, rest of the work is quite easy, just setting next pointers between nodes.
1074
Old answer I will post partial solution, because I am stuck with some problem and maybe someone will know a solution. Skip code block \documentclass{article} \usepackage{lipsum} \begin{document} \def\luacenterlastline#1{% \bgroup \setboxḷ=\vbox{\bfseries\noindent #1}% \directlua{% local char =unicode.utf8.char 1075
% get contents of box ḷ local head = tex.box[ḷ].head % get last hlist -- this means line local x = node.count(ḷ,head) for n in node.traverse_id(ḷ, head) do x = x - 1 % if x is ḷ then we are in the last line if x == ḷ then % make hfill node local hfill = node.new("glue") hfill.spec = node.new("glue_spec") hfill.spec.stretch = 2^16 hfill.spec.stretch_order = 3 % make testing node, because node inserting doesn't work local pok = node.new(37) pok.char = 64 pok.next = n.head % print all glyphs on a line % note the @ at the beginning. our test node is printed for c in node.traverse_id(37,pok) do print(char(c.char)) end n.head = pok % this doesn't work neither %n.head = node.insert_before(n.head,n.head,pok) end end tex.box[ḷ].head = head
} \unvboxḷ \egroup
} \luacenterlastline{\lipsum[3]} \end{document} Contents of boxes is accessible with tex.box function. Node list is in head ield. In this case, there are several nodes with id ḷ, which are hlist, nodes broken into lines. We cound these nodes and loop over them, processing is 1076
activated only in the last hlist. New node of type glue is created, with stretch and stretch_order ields set to maximal stretchability. Then I tried to insert this node at the beginning of the current hlist and this is where I am stuck, because it doesn’t show in the document. I am sure that this is some stupid problem on my side, but I was unable to solve it. For test, I added another node of glyph type, which should add @ char into the hlist and it doesn’t work either. Strangely, if I print contents of the hlist, @ character is printed on the terminal, so this glyph is part of new hlist, but it doesn’t ind its way to the node lists used in the inal document. I am sure that this is just some stupid mistake, but I should go sleep now, so maybe I will igure that tommorow. Tags: programming (Prev Q) (Next Q)
Q: Can luaLaTeX convert xlsx tables into LaTeX code? Tags: programming (Prev Q) (Next Q) Inspired by this question: Using external tables in TikZ, I would like to know whether it is technically possible to use a xlsx (Oice Open XML) ile directly with luaLaTeX, i.e. can luaLaTeX call some external unzip program and then parse the extracted XML ile? Or is that pushing the envelope too hard? Tags: programming (Prev Q) (Next Q) User: count-zero Answer by topskip This is of course possible, as ”LuaTeX is the new Mac Gyver”. You can use the built-in luazip to unzip the contents of the xlsx ile and then use an Lua-XML parser (see https://github.com/pgundlach/LuaTeX/tree/xmlreader for an XML enabled LuaTeX).
1077
Tags: programming (Prev Q) (Next Q)
Q: How can one get a list of the available functions in Lua(La)TeX Tags: programming (Prev Q) Is there a list or method to determine a list of the lua functions available/installed? Sofar I could only ind the lua source iles. Maybe I should write something that search through all the installed lua iles for lines starting with ”function”. Then I will have a list, but it would still not give me the rest of detail of the functions. Any better ideas or suggestions? Tags: programming (Prev Q) User: louis Answer by topskip You know the LuaTeX functions short reference? That together with the Lua reference should cover all available functions if I am correct. Answer by taco-hoekwater This is hard to answer, as you are asking the lua equivalent of ’what are the names of all deined macros?’. The answer is: it depends. The core luatex functions are documented in the reference manual, as Patrick wrote in his answer. Everything else is loaded from lua source iles on your hard-disk, but only if you (possibly indirectly) asked for it, just as would be the case for macros/packages.
1078
If you are only interested in a list of deined lua functions in your current luatex source ile, you can try this inside a lua code block: Skip code block function dump (prefix, a) for i,v in pairs (a) do if type(v) == "table" then dump(prefix .. '.' .. i,v) elseif type(v) == "function" then print (prefix .. '.' .. i .. '()') end end end dump('_G',_G) but there are two caveats: • you only get to know function names, not their calling conventions. This is about as useful as only knowing macro names (meaning: not very useful at all) • circular references to tables will confuse this bit of lua code, it needs to be made smarter to allow for that Tags: programming (Prev Q)
LaTeX3 Skip to questions, Wiki by user joseph-wright latex3 is about the new material being developed by the LaTeX3 Project. LaTeX3 is currently a series of packages used with LaTeX2e, and so questions in this category will almost all be about using LaTeX3 concepts with
1079
LaTeX2e. This includes the expl3 programming language along with higherlevel concepts such as xparse and xtemplate. Please do not use this tag for general LaTeX questions.
Questions Q: Why do I need Lua or LaTeX3 in a plain old technical document? Tags: latex3 (Prev Q) (Next Q) I wrote and maintain a couple hundred page computer related technical spec in XeLaTeX. I use tables, igures, bitields, algorithms and other typical trappings. I’m intrigued by LuaTeX and LaTeX3, but honestly, I don’t know what beneit these will bring to a document like mine. Am I going to do more with less? Replace inelegant documentation strategies? Does anyone have examples of LaTeX3 beneits to a plain-Jane technical document? I already know and respect Lua from past programming work. It’s the dayto-day applicability to documentation that I’m missing. Tags: latex3 (Prev Q) (Next Q) User: srking Answer by joseph-wright Developments in Lua and LaTeX3 are separate, but there is some convergence in the sense that both address issues for LaTeX programmers. It’s also the case that the beneits you will see from these developments depend on the nature of your documents. LuaTeX adds to TeX functionality which is not available any other way, but also makes general programming a lot easier. The general programming stuf helps package authors. For example, Lua is used by fontspec when loaded in LuaLaTeX to ind fonts system. Some of the new abilities show up in particular areas, where TeX ’runs out of steam’. One that stands out is in 1080
Arabic typesetting, which is very context-dependent and which TeX does not do so well at. LuaTeX-based approaches can address this type of issue. LaTeX3 developments are also focussed at the programming end the moment making it easier to maintain packages. For example, XeLaTeX users tend to use fontspec, and fontspec is written in the LaTeX3 programming system. In the longer term, the aim is to address a number of underlying issues with LaTeX in an eventual LaTeX3 format. This should wrap up a lot of package functionality kernel, and also allow us to address some long-standing awkward issues (for example, that adding vertical space can have odd efects due to the way TeX handles the main vertical list). A richer set of kernel tools should also cut down on multiple-package compatibilities. Now, it’s possible that this will have very little impact on your documents, other than perhaps giving you shorter preambles. Tags: latex3 (Prev Q) (Next Q)
Q: Will LaTeX3 have proper support for hooks? Does LuaTeX? Tags: latex3 (Prev Q) Tex has powerful support for extensions triggered by events happen in generating output, by running one of six token lists appropriately: \everycr \everydisplay \everyhbox \everymath \everypar \everyvbox They’re used with efect in such places as Latex classes, but they are much less useful than they could be, because the \everyfoo={\t\o ks} assignment simply wipes the current value, making it rather tricky to use them by authors of packages and documents. Emacs’ Elisp has a widely understood technology for registering and deregistering code to run at events, namely hooks. The LaTeX3 Project’s expl3 library ofers supports for managing token lists, and LuaTeX augments TeX’s event handling mechanism with a set of Lua callbacks. Are these the beginning of proper support for event-driven TeX code, as usable as hooks? Is this a priority for developers on these projects? 1081
Tags: latex3 (Prev Q) User: charles-stewart Answer by topskip LuaTeX does not ofer these hooks out of the box, but you can make them yourself. The LuaLaTeX people do this (thanks!). See http://github.com/ mpg/luatexbase (and there: luatexbase-mcb.dtx). Answer by will-robertson Sure, it would be great if LaTeX3 provided hooks for this sort of thing— not using the primitives directly, but rather providing an interface to a reliable way to use these token registers. Unfortunately, ripping out the current LaTeX2e machinery for, say, giving a good way to access \everypar simply isn’t possible without breaking backwards compatibility with lots and lots of current packages. Experimental LaTeX3 packages such as galley are written to start thinking about these ideas, but we’re quite a way away from anything that can be used for general purposes. Answer by joseph-wright Expanding on the LaTeX3 side of things, I guess this is a place where I’d expect to provide a diferent input syntax to LaTeX2e. As the question points out, the current implementation uses the token register syntax \everyfoo{tokens} which overwrites whatever was in \everyfoo unless you do \everyfoo\expandafter{\the\everyfoo tokens} which is not exactly obvious. So a better approach would be something like the current \AtBeginDocument, something like: \AtEveryFoo{tokens} 1082
where this is additive. The implementation of such an approach would be easy enough. Proof of concept A short piece of concept code that might be an approach for LaTeX3. The idea here is that the TeX primitive is only used by the kernel, with two separate hooks provided. First, settings that the kernel needs are applied, then ones from programmers and inally those from the user. In the demo I’ve only considered the \everymath concept. I’ve provided an interface for the user to both add to and clear the list, plus an alias to the LaTeX2e \everymath interface. (In a pure LaTeX3 approach I’d drop this TeX-like interface, or at least mark it depreciated.) Skip code block \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \makeatletter \tl_new:N \l_every_math_programmers_tl \tl_new:N \l_every_math_users_tl \toks_set:Nn \tex_everymath:D { \check@mathfonts % LaTeX2e's requirement \tl_use:N \l_every_math_programmers_tl \tl_use:N \l_every_math_users_tl } \NewDocumentCommand \InsertForEvery { m +m } { \tl_put_right:cn { l_every_ #1 _users_tl } {#2} } \NewDocumentCommand \ClearForEvery { m } { \tl_clear:c { l_every_ #1 _users_tl } } \RenewDocumentCommand \everymath { +m } { \InsertForEvery { math } {#1} } \ExplSyntaxOff \begin{document} \InsertForEvery{math}{\mathrm{Look!\,}} \( y = mx + c \) \ClearForEvery{math} 1083
\( y = mx +
c \)
\end{document} I should add that a real implementation would need error-checking and so on. Tags: latex3 (Prev Q)
Hyperref Skip to questions, Wiki by user stefan-kottwitz hyperref is a package capable of producing hypertext links in documents. If your question is about cross-referencing in general, choose cross-referencing. If it’s speciically about PDF features, consider to choose pdf. In addition to the capability of producing hypertext links hyperref can be used to add meta data to PDF iles.
Questions Q: hyperref, lualatex and unicode bookmarks issue (garbled page numbers in AR for Linux) Tags: hyperref (Prev Q) (Next Q) I have text with some non-ascii characters in chapters, sections... which I’d like to see in bookmarks displayed correctly. I noticed that, • If I run xelatex, everything is ine, no need to set \hypersetup{unicode=true} to get this working 1084
• If I run lualatex, I have these issues: 1. If unicode=false, then bookmarks containing non-ascii characters have strange unreadable symbols instead of those chars, but everything else is ine 2. If unicode=true, then bookmarks are just ine, but page numbers in resulting PDF ile are garbled in Adobe Reader 9 on Linux (and Okular shows some strange symbols in bookmark pane too) Is it a driver issue? Any suggestion how to overcome this problem? Here’s a MWE: Skip code block \documentclass{article} \usepackage{hyperref} %\hypersetup{unicode=true} \begin{document} \section{Test 1 čćžđš} Some text.\clearpage \section{Test 2 šđžćč} Some text. \end{document} A notice: I tried to post this question on comp.text.tex earlier, but something went wrong and it didn’t show up. Anyway, if the post shows up later, I’ll post the link here. Tags: hyperref (Prev Q) (Next Q) User: meho-r. Answer by meho-r. I received an email from Heiko suggesting that I try auto pdfencoding which worked indeed. So, the solution is: 1085
\hypersetup{pdfencoding=auto} And corrected MWE from above: Skip code block \documentclass{article} \usepackage{hyperref} \hypersetup{% pdfencoding=auto, pdfauthor={Author Test ČĆŽĐŠ}, pdftitle={Title test, čćžđš} } \begin{document} \section{Test 1 čćžđš} Some text.\clearpage \section{Test 2 šđžćč} Some text. \end{document} Complete Heiko’s answer can be found on comp.text.tex. Tags: hyperref (Prev Q) (Next Q)
Q: Possible LuaLaTeX Problem (compilation seems to hang) Tags: hyperref (Prev Q) I asked a question earlier, where I had problems with my font speciication, since I am using LuaLaTeX with Caslon. I am on Win 7 with TeXLive 2013 (up to date). The ile compiles just ine with XeLaTeX.
1086
Here is my preamble and the compiler seems to hang at this point of the output: Skip code block \documentclass[ a4paper, % DIVcalc, % BCOR12mm, 12pt]{scrartcl} \linespread{1.6} \usepackage{setspace} % \singlespacing % \onehalfspacing % \doublespacing %\setstretch{1.2} % for custom spacing %\usepackage[T1]{fontenc} %\usepackage[ansinew]{inputenc} %\usepackage[latin9]{inputenc} %\usepackage[english]{babel} %\synctex=-1 \usepackage{xcolor} \usepackage{pdfcolmk} \usepackage{textcomp} \usepackage{verbatim} \PassOptionsToPackage{normalem}{ulem} \usepackage[normalem]{ulem} \usepackage{units} %for nicefrac \usepackage{ftnxtra}
%%%XeTeX-font-modifications \usepackage[no-math]{fontspec} \usepackage{lipsum} \usepackage[rm]{titlesec} %\usepackage{titletoc} \usepackage[titles]{tocloft} \usepackage{polyglossia} 1087
\usepackage{csquotes} \setdefaultlanguage{english} %\defaultfontfeatures{Ligatures=TeX} %\setmainfont[Numbers=Proportional,Ligatures=TeX]{Adobe Caslon Pro} \setmainfont[ Extension = .otf, Ligatures = TeX, BoldFont = ACaslonPro-Bold, ItalicFont = ACaslonPro-Italic, BoldItalicFont = ACaslonPro-BoldItalic ]{ACaslonPro-Regular} %\usepackage{luaotfload} %%%for luatex %\usepackage{uniinput-lualatex} %\usepackage{luatextra} %%%special typesetting adjustment %\usepackage{microtype} %\usepackage[english]{selnolig} %%% Equations \usepackage{amsmath} \usepackage{mathcomp} \usepackage{amssymb} \usepackage{breqn} \usepackage{upgreek} \usepackage{stmaryrd} % % % %
%%%XeTeX Mathfont XITS Math \usepackage[MnSymbol]{mathspec} \setmathsfont(Digits,Latin,Greek) [Numbers={Lining,Proportional}]{Latin Modern Math} 1088
%%% THE BIB \usepackage[backend=biber, citestyle=authoryear,bibstyle=philosophy-modern, natbib=true,isbn=false,url=false,maxcitenames=2,language=english,hyperref=true,sor \addbibresource{draft.bib} %%%geometry \usepackage[lmargin=2.5cm,rmargin=2cm,bottom=2.5cm,top=2.5cm,includeheadfoot] {geometry}
%%%Symbols \usepackage{eurosym} %%% TABLES \usepackage{threeparttable} \usepackage{tabularx} \usepackage{fancyvrb} \usepackage{array} \usepackage{booktabs} \usepackage{multirow} \usepackage{multicol} \usepackage{longtable} \usepackage{supertabular} \usepackage{rotating} %Ḷum drehen von Tabellen ins Querformat \usepackage{dcolumn} % ??? \usepackage{enumerate} %%% Grafiken \usepackage{graphicx} \usepackage{subfig} \usepackage{rotating} \usepackage{tikḶ} 1089
\usetikḶlibrary{arrows,positioning} %%% version control \usepackage{mVersion} \increaseBuild %%%shaping %\usepackage{shapepar} %%% To-do-Notes % \usepackage[german,textsiḶe=footnotesiḶe]{todonotes} % \setlength{\marginparwidth}{4cm} % \reversemarginpar %vorübergehend, damit marginnotes PlatḶ haben % \setlength{\hoffset}{3cm} % \setlength{\textwidth}{14cm} %def:stodo % \newcommand{\stodo}[2][] % {\todo[caption={#2}, siḶe=\small, #1]{\renewcommand{\baselinestretch} %%% Schusterjungenkontrolle \widowpenalty=1ḷḷḷḷ \clubpenalty=1ḷḷḷḷ %%% VerḶeichnisse %%% Makros \newcommand{\HRule}{\rule{\linewidth}{ḷ.5mm}} %%% HYPERREF \usepackage[english,linktocpage=true]{hyperref} \hypersetup{ colorlinks = true, linkcolor = blue, anchorcolor = blue, citecolor = blue, 1090
{ḷ.5}\s
}
filecolor = red, urlcolor = blue
Here is where the compiler hangs: Skip code block
(c:/texlive/2ḷ13/texmf-dist/tex/latex/biblatex-philosophy/english-philosophy.lbx ( ) (c:/texlive/2ḷ13/texmf-dist/tex/latex/base/ts1cmr.fd) (c:/texlive/2ḷ13/texmf-dist/tex/latex/tipa/t3cmr.fd) (c:/texlive/2ḷ13/texmf-dist/tex/context/base/supp-pdf.mkii [Loading MPS to PDF converter (version 2ḷḷ6.ḷ9.ḷ2).] ) (c:/texlive/2ḷ13/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty (c:/texlive/2ḷ13/texmf-dist/tex/latex/oberdiek/grfext.sty) (c:/texlive/2ḷ13/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)) (./draft.bbl) *geometry* driver: auto-detecting *geometry* detected driver: pdftex ABD: EveryShipout initialiḶing macros (c:/texlive/2ḷ13/texmf-dist/tex/latex/hyperref/nameref.sty (c:/texlive/2ḷ13/texmf-dist/tex/generic/oberdiek/gettitlestring.sty)) (./draft.out) (./draft.out) If you have any idea, why the compiler hangs please tell me. Thanks in advance! Tags: hyperref (Prev Q) User: option_select Answer by option_select This got solved due to @egreg and @cgnieder and this suggestion tug.org/pipermail/tex-live/2013-July/033914.html. If you experience similar problems, run luaotfload-tool --update from the command line/shell.
1091
Tags: hyperref (Prev Q)
Protrusion Questions Q: How does one retrieve \rpcode values in LuaTeX? Tags: protrusion (Prev Q) The \rpcode values from pdfTeX are properties of font characters, e.g., \rpcode\font 5ḷ = 2ḷḷ sets the right protrusion value for character 50 in the current font to 200. Reading chapter 7 of the luatex reference manual my understanding is that this value then shows up in the character table for this particular character as right_protrusion. However, this is either not the case or I do something wrong, here is a minimal example: Skip code block \pdfprotrudechars=2 \rpcode\font 5ḷ = 2ḷḷ \efcode\font 5ḷ = 333 \directlua{ local function FMItable (name,t) print ("---- looking at table ", name, tostring(t)) for k, v in pairs(t) do print(" ", k,"=", tostring(v)) end print("----------------") end 1092
FMItable("char 5ḷ",font.fonts[font.current()].characters[5ḷ]) } \bye If run through luatex this generates Skip code block luatex rp-test.tex This is LuaTeX, Version beta-ḷ.79.1 (TeX Live 2ḷ14/W32TeX) (rev 4971) restricted \write18 enabled. (./rp-test.tex---- looking at table char 5ḷ table: ḷ2FB5E1ḷ height = 422343 used = false width = 327681 bot_accent = ḷ italic = ḷ expansion_factor = 333 depth = ḷ top_accent = ḷ ---------------) No pages of output. Transcript written on rp-test.log. You can see the changed \efcode so I’m getting at the right character table but no index for protrusion. Any idea what I’m doing wrong? Tags: protrusion (Prev Q) User: frank-mittelbach Answer by david-carlisle This seems to be ixed in the current 0.80 release Skip code block This is LuaTeX, Version beta-ḷ.8ḷ.ḷ (TeX Live 2ḷ15) (rev 5238) restricted \write18 enabled. 1093
(./gg384.tex---- looking at table depth = ḷ used = false width = 327681 expansion_factor = right_protruding = height = 422343 ---------------) No pages of output.
char 5ḷ table: ḷx6ḷ1ḷ6f27ḷ
333 2ḷḷ
showing right_protruding
=
2ḷḷ
is reported. Tags: protrusion (Prev Q)
Page Breaking Questions Q: Can LuaTeX change the PAGE-breaking algorithm Tags: page-breaking (Prev Q) (Next Q) One of the often highlighted features in LuaTeX is the ability to replace the default TeX line-breaking algorithm by something else. I wonder if it is similarly possible to replace the page-breaking algorithm? This would be a great feature, since the page-breaking algorithm in TeX is often described as more ”greedy” than the line-breaking algorithm, and as not very good at optimizing globally. EDIT: If this turns out to be possible, can this be used to solve the following problem, highlighted by Frank Mittelbach? I assume no, since Frank does 1094
not state so explicitly.
[ Issue: TEX generates pages based on precompiled paragraph data]Issue: TEX generates pages based on precompiled paragraph data This issue describes the fundamental problem in TeX’s approach: the program builds optimized paragraph shapes without any knowledge about their inal placement on a page. The result is a “galley” from which columns are cut to a speciied vertical size. A consequence of this is that one can’t have the shape of a paragraph depend on its inal position on the page when using TEX’s page builder algorithm. To some extent, it is possible to program around this limitation, e.g., by measuring the remaining space on a page and explicitly changing paragraph shapes after determining where the current textual material will inally appear. However, besides being complicated to implement, it requires accounting for all kinds of special situations that normally would be automatically managed by TEX, and providing “programmed” solutions for them. As a result, all attempts so far to provide such functionality had to impose strong limitations on the allowed input material, i.e., they worked only in restricted setups and even then, the results were often not satisfactory. Tags: page-breaking (Prev Q) (Next Q) User: gaussler Answer by david-carlisle Yes, see the documentation of the buildpage_filter callback, and possibly also the pre_output_filter callback. Note however that unlike the linebreaking algorithm, there are very few parts of the page breaker that you are forced to use directly, which is why difer1095
ent strategies can be programmed even in classic tex without needing lua extensions, such as two column mode in standard latex, or multicol package. Tags: page-breaking (Prev Q) (Next Q)
Q: pagebreak in ledpar (eledpar) Tags: page-breaking (Prev Q) I am sort of restating this question -- however only sort of. I will (1) describe a problem, (2) assume something about the functions of ledpar, and (3) ask a question. 1. Problem I am typesetting a bilingual edition of a text: edition on the left, translation on the right page. Since the translation is much longer than the original, the pagesynchronization is rarely correct (I assume that the unequal lengths of text on both pages is at least in part responsible; this assumption could be wrong, of course). Anyway, I would like to be able to insert a pagebreak manually an thereby to synchronize the contents manually. AFAIK such a manual pagebreak is not implemented in ledpar. There is this ine solution, but I want to state the problem from a slightly diferent angle. 2. Assumption I guess ledpar works like this: • looking at the text on both sides, • trying measure the contents on both sides, • deciding for a portion of text on the left page,
1096
• using some sort of command in order to let the left page break after that portion, • trying to measure the corresponding text on the right page, • trying to determine an equal portion on the right page and the correct spot for the break, • using some sort of command in order to let the right page break, • go to the next portion of text... etc. 3. Question What is this command that lets the page break? This command -- or something like it -- must exist, because ledpar uses it itself automatically all the time, right? So, can I just manually use this very same command that lets the page break myself wherever I want? If this command is some bigger function, then I think it should be possible to define a command I could execute in my text. Tags: page-breaking (Prev Q) User: clinteastwood Answer by maïeul The version 1.5.0 of eledpar add tools to manage pagebreak on eledpar. There is two commands : \ledpb to make page break, and \lednopb to prevent page break, by adding new line. It needs to make two runs. Tags: page-breaking (Prev Q)
Context Mkiv Skip to questions, 1097
Wiki by user topskip The tag context-mkiv is for the modern variant of context that uses luatex. You should use this tag if a Mark IV based answer would be helpful.
Questions Q: Escape a string printed from Lua using ConTeXt Tags: context-mkiv (Prev Q) (Next Q) This seems to have come up a couple times, but I cannot glean an answer to the generic question of how one might protect an arbitrary string in Lua to ensure its characters are printed. In other words, given some code in a .lua ile: local i_can_be_anything = '&\\%*_' context(i_can_be_anything) This balks for any number of reasons, because the characters have special meaning in TeX when ConTeXt pushes them out to the TeX compiler. The most apparent option to me would be to convert the string in Lua so that it contains the proper escaping or substitutions that can be passed to TeX to achieve the desired outcome, which would be in this case along the lines of: \&\textbackslash{}\%\&\_ I believe the full list of replacements one would be looking for would be along the lines of (and this is from some Python I wrote): Skip code block tex_replacements = [ (u'{', ur'\{'), (u'}', ur'\}'), (u'[', ur'{[}'), (u']', ur'{]}'), 1098
]
(u'\\', ur'\textbackslash{}'), (u'$', ur'\$'), (u'%', ur'\%'), (u'&', ur'\&'), (u'#', ur'\#'), (u'_', ur'\_'), (u'~', ur'\textasciitilde{}'), (u'^', ur'\textasciicircum{}'),
tex_mapping = {ord(char):rep for char, rep in tex_replacements} def escape(s): return unicode(s).translate(tex_mapping) Is there no function in Lua or LuaTeX to achieve this set of substitutions (or otherwise) so that an arbitrary string could be printed? A straightforward iteration over the characters with a substitution along the lines of the tex_replacements above could do the trick, but I would expect that someone had already written a solution to this problem.
EDIT It is worth noting that @phg posed a plausible solution of changing the catcodes to vrbcatcode (i.e. \verbatim, or context.sprint(catcodes.numbers.vrbcatcodes, i_can_be_anything)). This does perform the escaping desired, however it seems to have serious issues with line breaking that make it essentially unusable. Tags: context-mkiv (Prev Q) (Next Q) User: brian-m.-hunt Answer by aditya This answer is based on an email from Hans Hagen. One way to achieve the desired output is using formatters. For example: 1099
\starttext \startluacode local text='&\%*_' context("%!tex!", text) \stopluacode \stoptext The %!tex! is plug to the formatters and tex is one of the pre-deined formatters. Other pre-deined formatters are lua and xml (which escape strings for Lua and XML, respectively). The above code is equivalent to context(string.formatters["%!tex!"](text)) which is equivalent to the rather low-level context(lpeg.match(lpeg.patterns.texescape,text)) The corresponding lpeg patterns for lua and xml formatters are lpeg.patterns.luaescape and lpeg.patterns.xmlescape. These are deined in util-str.lua as: patterns.xmlescape patterns.texescape patterns.luaescape patterns.luaquoted
= = = =
Cs((P("")/">" + P("&")/"&" + P('"')/" Cs((C(S("#$%\\{}"))/"\\%1" + P(1))^ḷ) Cs(((1-S('"\n'))^1 + P('"')/'\\"' + P('\n')/'\\n"')^ḷ) -- may Cs(Cc('"') * ((1-S('"\n'))^1 + P('"')/'\\"' + P('\n')/'\\n"')
The luaquoted pattern is not used in the core. Tags: context-mkiv (Prev Q) (Next Q)
Q: How can I list fonts available to LuaTeX in ConTeXt (TeX Live 2013)? Tags: context-mkiv (Prev Q) I’ve looked at How do I get a list of all available fonts for luaotload?, but the answers don’t work for me in TeX Live 2013, at least not without La1100
TeX. This is because there they rely on the ile otfl-names.lua under \luatex-cache\generic\names; but in my installations of TeX Live 2013 (ConTeXt scheme), the only directory under \luatex-cache is context, and there is no otfl-names.lua that I can ind. P.S. Following this comment, I also looked for luaotfload-names.lua, but can’t ind that ile either. Do I need to run a program to build it? I looked for mkluatexfontdb but no such command seems to exist. I tried the following ConTeXt mkiv (LuaTeX) document: Skip code block \starttext \startluacode myfonts=dofile(fonts.names.path.path) for i,v in ipairs(myfonts.mappings) do tex.print(-2, v.familyname) tex.print(', ') tex.print(-2, v.fontname) tex.print('\\par') end \stopluacode \stoptext But I get the error: ! LuaTeX error [string ”\directlua ”]:2: attempt to index ield ’path’ (a nil value) Any suggestions would be appreciated. Tags: context-mkiv (Prev Q) User: larsh Answer by philipp-gesang If all you need is a list of the registered fonts, you can run 1101
mtxrun --script fonts --list --all for Context, and luaotfload-tool --list=* for Lualatex/Luaotload (see man 1 luaotfload-tool for details). If you did not yet build the font indices you will have to do so before running above commands, e.g. mtxrun --script fonts --reload and luaotfload-tool --update Tags: context-mkiv (Prev Q)
Compiling Skip to questions, Wiki by user edd LaTeX is a compiled markup language, and as such there is a compilation process that needs to be followed to correctly produce output. This can be a long and complicated sequence of steps, with multiple passes being required to successfully build references and tables of contents amongst other things, as well as ensuring that externally generated iles are up to date.
Questions Q: Hiring someone to help me with LaTeX for my PhD thesis Tags: compiling (Prev Q) (Next Q), arabic (Next Q) 1102
I do not know whether this is an appropriate question, but I was carrying it around for quite some weeks and now it just has to come out. I am working on my PhD thesis. My thesis will include a long English textual analysis in the mainmatter ((almost) no problem with that) and a long appendix providing the source texts on which the analysis is based. These source text will be given in the original language (Arabic) on the left page as a critical edition with two or three apparatus and my english translation on the right page. I have chosen ledmac/ledpar to do the job (because there is no alternative, is there?) and now I’ve been wrestling for weeks/months to get everything in order -- and by wrestling, I really mean it. Other than that, I already started to edit my texts using the commands that the packages provide and all the while I’ve been hoping that in the end all problems can be overcome one after another, so that in the end I have a nice typeset thesis and I can conidently claim that I’ve made the right choice in chosing (Lua-) LaTeX for writing my thesis. This my situation. Now, since I’ve encountering problems after problems (in between solving one or two while others appear), I’ve become skeptical whether LaTeX is the right choice for my project. Even more since I also have the feeling that I myself won’t be able to solve all the issues, because I am lacking the IT-expertise. I’ve done a lot of delving into the depths of LaTeX, but I am coming close to my limits there. I still belive in LaTeX, but what I intend to do seems to be some major job for LaTeX and I doubt that I am the one who can get LaTeX to do the job. So, the question I’ve been having in my mind is this (and I want to repeat that I am not sure whether it is an appropriate question): 1. Is there anybody out there who I could hire (yes: hire) to look through my tex-iles and ix the problems I encounter while I can focus on writing my thesis (and of course ix what I can ix myself)? 2. How much would it be to hire someone like that? I am at the point where I have to decide whether to abandon LaTeX for my PhD and to take another application (e.g. CTE), or to stay with it. Once again: I like LaTeX, and I’d also like to stay with it, but I am not sure whether I should. And also, I don’t want to realize that using LaTeX was the wrong decision only two months before I hand in my thesis because then 1103
it is too late. Sorry for this question, but it had to come out...
Appendix: Random examples of problems • the line numbers in the apparatus are one to much (e.g., 7 instead of 6) • the arabic text has sometimes varying interlinespacing • the space between the paragraphs (created by ledpar) shouldn’t be there (see here) • the content is not correctly snychronized and the pagebreaks are thus wrong • the Arabic apparatus has problems with linebreaks • the page numbers in the table of contents need to be modiied (see here) • ... Tags: compiling (Prev Q) (Next Q), arabic (Next Q) User: clinteastwood Answer by topskip You can always contact your local TeX users group. They most likely know people that ofer LaTeX help (free/commercial). For the other question, on how much it would be. That depends, of course, but since you’re asking for special knowledge, it won’t be cheap. I see you are located in Germany: we maintain a list of professional TeX consultants here: http://texfragen.de/latex_hilfe#kommerzielle_dienstleister Answer by simurgh12 As far as I understand your question, you need someone who has expertise on both bidi typesetting in TeX and critical edition typesetting in TeX. You 1104
may contact these people/groups/mailing lists and see if they can help (or be hired): 1. Peter Wilson (the original author of ledmac, ledpar, and ledarab packages) 2. Dominik Wujastyk and John Lavagnino (the authors of edmac package) 3. Maïeul Rouquette (the current maintainer of ledmac package) 4. Klaus Lagally (the author of arabtex package) 5. Ahmad Yazdipour (the author of TeX-e-Parsi: a Persian TeX typesetting system) 6. FarsiTeX project group and in particular, Behdad Esfahbod 7. IvriTeX mailing list 8. François Charette (the original author of bidi and arabxetex packages) 9. Vafa Khalighi (current author/maintainer of bidi, xepersian, and arabxetex packages, previous maintainer of ledmac, ledpar, and ledarab packages). 10. Youssef Jabri (the author of arabi package) Answer by anabel In http://www.djdekker.net/ledmac/ you can ind lot of clues. It is more or less what you want, except for the Arabic. It saved my life day with my Ph.D. thesis. Tags: compiling (Prev Q) (Next Q), arabic (Next Q)
Q: how to get lualatexmk to run in \nonstopmode Tags: compiling (Prev Q) (Next Q) I use the engine lualatexmk to create my documents. This runs the entire pdf-generating-process several times until a stage is reached where an additional run of this process wouldn’t change the result anymore. This, at least, is more or less how I believe lualatexmk works.
1105
The content of lualatex.engine is:
#!/bin/bash export TSBIN="$HOME/Library/TeXShop/bin/tslatexmk" export LTMKBIN="$HOME/Library/TeXShop/bin/tslatexmk" export LTMKEDIT="$HOME/Library/TeXShop/bin" # make sure latexmkrcedit exists in bin if [ ! -e "${LTMKEDIT}/latexmkrcedit" ] ; then cp "${LTMKBIN}/latexmkrcDONTedit" "${LTMKEDIT}/latexmkrcedit" fi "${LTMKBIN}"/latexmk -f -pdf -r "${LTMKEDIT}/latexmkrcedit" -r "${TSBIN}/lualatexm When I get an error and don’t want to care about the error for the moment, I press ”r” in the console and it then runs through one process and forgets about all the errors. This mode is called \nonstopmode, because it does not stop at each and every error. Since, however, lualatexmk runs the documentgenerating-process several times, I need to press ”r” also several times. My simple question is: How do I have to edit lualatexmk.engine to let it run completely in \nonstopmode, so that each and every error is ignored for the moment? Tags: compiling (Prev Q) (Next Q) User: clinteastwood Answer by yo’ The \...mode commands can be added directly in the document, and this should work in LuaTeX as well. Therefore adding the following line as the irst line of your document should suice: \nonstopmode Tags: compiling (Prev Q) (Next Q)
1106
Q: How to set the interactive editor in TeXLive? lualatex bug? Tags: compiling (Prev Q), bugs (Prev Q) (Next Q), editors (Next Q) After some research we determined this is a problem inherent to lualatex. If you have a solution for this problem in LuaLaTeX please post it below and I will accept you answer. When compiling a ile with LaTeX (and others), if there is an error one has the option to edit the ile at the line of the error (or near) by pressing e + Enter. For example, if one has this ile \documentclass{article} \begin{document} \badcommand \end{document} I get this ... Document Class: article 2ḷḷ7/1ḷ/19 v1.4h Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/siḶe1ḷ.clo)) (./main.aux) ! Undefined control sequence. l.3 \badcommand ? However, in my current coniguration TeXLive 2015 (Fedora), nothing happens. I only get this message: You want to edit file ./main.tex at line 81 297 words of node memory still in use: 3 hlist, 1 rule, 48 glue_spec, 1 write, 1 dir, 1 pdf_colorstack nodes avail lists: 2:12,3:1,6:2,9:1 No pages of output. Transcript written on document.log. prompt $_ How can I conigure the editor? in particular Gedit. (I am suspecting it tries to open emacs which is not installed, but still I would 1107
like to use Gedit instead). Tags: compiling (Prev Q), bugs (Prev Q) (Next Q), editors (Next Q) User: alfc Answer by cfr If you are happy setting this system wide, you can edit the customisation into texmf.cnf but it is important to pick the correct texmf.cnf. Probably kpsewhich texmf.cnf should return the correct ile. On my system, for TeX Live 2015, this is /usr/local/texlive/2ḷ15/texmf.cnf. Wherever it is, the ile should be almost empty with just some explanatory comments at the top. Here’s mine after adding the coniguration line for the editor: Skip code block % (Public domain.) % This texmf.cnf file should contain only your personal changes from the % original texmf.cnf (for example, as chosen in the installer). % % That is, if you need to make changes to texmf.cnf, put your custom % settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than % the distributed file (which is .../texlive/YYYY/texmf-dist/web2c/texmf.cnf). % And include *only* your changed values, not a copy of the whole thing! % TEXEDIT = /usr/bin/vim +%d '%s' You will need to add an appropriately modiied TEXEDIT = /usr/bin/vim +%d '%s' to your ile, as I just added this line to mine. After doing so, I can edit the ile using e. I am not sure why the default is not to use the system or user value of EDITOR. TeX simply ignores this on my system and tries to use an editor which doesn’t exist, with inevitably unsatisfactory results. What it should do is use EDITOR if that’s conigured, but I can’t even get the ile to use the value of a shell variable, so probably this is a hopeless enterprise. Hence, I
1108
hard-coded it as shown above, which does work even though the solution is not really a satisfying one. Tags: compiling (Prev Q), bugs (Prev Q) (Next Q), editors (Next Q)
Format Files Questions Q: How can I dump Lua code to a format ile? Tags: format-iles (Prev Q) (Next Q) From this format: Skip code block %% testformat.ini \input plain \directlua {tex.enableprimitives('', tex.extraprimitives())} \directlua { testFunction = function () tex.print("This was print by Lua's testFunction.\par") end } %% \directlua {testFunction()} %% \bye \dump I create a testformat.fmt with $ luatex -ini testformat.ini, but when trying to use it with the following test ile: %% test-testformat.tex \directlua{testFunction()} \bye 1109
the globaly deined function testFunction is lost: Skip code block $ luatex -fmt testFormat.fmt test-testformat.tex This is LuaTeX, Version beta-ḷ.7ḷ.1-2ḷ1112ḷ612 (./test-testformat.tex ! LuaTeX error :1: attempt to call global 'testFunction' (a nil va lue) stack traceback: :1: in main chunk. l.2 \directlua{testFunction()} ? Should I do another trick in Lua or it simply can’t be dumped and I must use something like \everyjob{\directlua{dofile("testformat.lua")}}? Tags: format-iles (Prev Q) (Next Q) User: caio-lopes Answer by joseph-wright For the LaTeX3 l3bootstrap module, we wanted to enable the equivalent of \pdfstrcmp using Lua code for LuaTeX. To build that into a format, we wanted to avoid having to read a .lua ile each run. Taco Hoekwater suggested the use of lua.bytecode. We use this as: Skip code block \directlua { lua.bytecode[1] = function () function strcmp (A, B) if A == B then tex.write("ḷ") elseif A < B then tex.write("-1") else tex.write("1") 1110
end end end lua.bytecode[1]()
} \everyjob\expandafter {\the\everyjob\directlua{lua.bytecode[1]()}} i.e. you have to save the bytecode and use the \everyjob TeX primitive to active it for each run. (I’ve modiied slightly from the version in the .dtx as there are other details there which are not relevant to this question.) For reference, you would access the above using something like \long\def\pdfstrcmp#1#2{% \directlua{strcmp("\luaescapestring{#1}","\luaescapestring{#2}" )}% } (The pdfstrcmds package calls this \pdf@strcmp, as it requires an additional expansion compared to the primitive and so is ’safest’ given a diferent name. In the LaTeX3 load code, that’s not a worry as we don’t directly expose this, so we take a slightly diferent approach.) Tags: format-iles (Prev Q) (Next Q)
Q: LuaTeX 0.85 \pdf* primitive changes and format ile generation Tags: format-iles (Prev Q) (Next Q) TeX Live 2015 ships with LuaTeX 0.80. As LuaTeX 0.85 became available last month and I am supposed to do be doing other things I found this to be a wonderful opportunity to procrastinate by giving the 0.85 version a try. Building the executable was unproblematic. However to avoid a (Fatal format file error; I'm stymied) 1111
error, the format iles had to be regenerated. fmtutils-sys --all however failed to regenrate the LuaTeX related format iles. Doing it manually via: luatex -ini
-jobname=luatex -progname=luaex luatex.ini
revealed that the very irst line fails: ! Undefined control sequence. l.4 \pdfoutput =1 ? ! Emergency stop. Which is quite bad, because \pdfoutput is primitive control sequence of pdfTeX, it is always there, out of the box. But not any more in LuaTeX 0.85 it seems. In fact section 8.1.7 of the LuaTeX manual explains that all but three of the \pdf* primitives are gone. In the same section the manual provides a list of commands to get the traditional pdfTeX \pdf*-primitives back. However the use of \protected is only possible if the eTeX primitives in LuaTeX have been enabled. That happens in /usr/local/texlive/2ḷ15/texmf-dist/tex/generic/config/luatexiniconfig.tex which is the irst thing that /usr/local/texlive/2ḷ15/texmf-dist/tex/plain/config/luatex.ini loads. Extending luatexiniconfig.tex with list of commands almost succeeds. The last commands on the list use \newdimen which is not a primitive. It is deined in the plain-TeX-Format. As luatex.ini loads pdfetex.ini which in turn loads etex.src which loads plain.src the \newdimen command sequence will not be available until after all the iles have been processed. However pdfetex.ini of course ends with \dump end \endinput Adding something after pdfetex.ini has been processed would be pointless. Thus, my modiied luatex.ini therefore looks like this: 1112
Skip code block % $Id: luatex.ini 26647 2ḷ12-ḷ5-24 23:54:ḷ5Z karl $ % Karl Berry, originally written 2ḷḷ8. Public domain. % PDF output by default. % must be done first (activation of primitives) \input luatexiniconfig.tex \input luatex-unicode-letters.tex \input pdftexconfig.tex \input etex.src \input pdftexmagfix.tex \newdimen\pdfeachlineheight \newdimen\pdfeachlinedepth \newdimen\pdflastlinedepth \newdimen\pdffirstlineheight \newdimen\pdfignoreddimen \dump \endinput Now fmtutils-sys successfully generats the luatex.fmt format ile. The lualatex.fmt still fails. The lualatex.ini can be extended with the list of \pdf* commands just as well. However do something like \protected\def\pdfliteral{\pdfextension literal} one needs at least \catcode`\{=1 \catcode`\}=2 as we are in iniTeX-mode. But there very irst thing that latex.ltx checks is \ifnum\catcode`\{=1 \errmessage {LaTeX must be made using an initex with no format preloaded} \fi and this is triggered now. Thus the lualatex.ini needs and additional 1113
\catcode`\{=2 It now looks like this: Skip code block % $Id: lualatex.ini 38624 2ḷ15-1ḷ-12 23:38:27Z karl $ % Originally written 2ḷḷ8 by Karl Berry. Public domain.
\begingroup \catcode`\{=1 % \catcode`\}=2 % % JAW: Enable 'extra' pdfTeX primitives only in .ini file % latex.ltx enables the extra primitives bu a subset of those from % pdfTeX are needed to do the configuration below (pdftexconfig.tex). % Rather than list them all, just enable those classed as 'pdftex'. \directlua{tex.enableprimitives('',tex.extraprimitives('pdftex', 'luatex', 'et % JAW: Set up job name quoting before latex.ltx % Web2c pdfTeX/XeTeX quote job names containing spaces, but LuaTeX does % not do this at the engine level. The behaviour can be changed using % a callback. Originally this code was loaded via lualatexquotejobname.tex % but that required a hack around latex.ltx: the behaviour has been altered % to allow the callback route to be used directly. \global\everyjob{\directlua{require("lualatexquotejobname.lua")}} \endgroup \catcode`\{=1 \catcode`\}=2 % recreate the traditional pdfTeX primitives here REMOVED FOR BREVITY \catcode`\{=2 % settings inherited from pdftex \input pdftexconfig.tex % pdf output by default \input latex.ltx Again latex.ltx ends with \dump and \endinput so the necessary 1114
\newdimen commands: \newdimen\pdfeachlineheight \newdimen\pdfeachlinedepth \newdimen\pdflastlinedepth \newdimen\pdffirstlineheight \newdimen\pdfignoreddimen cannot be inserted after the \input latex.ltx line, that would be to late. Removing the last to lines from latex.ltx \dump \endinput and placing them in lualatex.ini as follows Skip code block % settings inherited from pdftex \input pdftexconfig.tex % pdf output by default \input latex.ltx \newdimen\pdfeachlineheight \newdimen\pdfeachlinedepth \newdimen\pdflastlinedepth \newdimen\pdffirstlineheight \newdimen\pdfignoreddimen \dump \endinput allows fmtutil-sys --all to regenerate the lualatex.fmt format ile. But now that the LaTeX source has been changed all other formats of course are broken. There must be a better way to do this! Any ideas? Tags: format-iles (Prev Q) (Next Q) User: uli 1115
Answer by joseph-wright LuaTeX from v0.85 onward removes essentially all of the pdfTeX ’back end’ primitives in favour of three new interfaces: • \pdfextension • \pdffeedback • \pdfvariable At the same time, there are several other renames and changes to the Lua side (the original token library is removed, and the newtoken library replaces it meaning there is no newtoken any more). These changes require signiicant work in the format-building process (many of the primitives impacted are not used by end users), in parts of the LaTeX kernel (where the change to the token library impacts) and in packages (most obviously graphics drivers and ifpdf). ’Fixing’ all of this in a transparent way is non-trivial. (There’s not just LaTeX to think about: plain LuaTeX is also afected.) The LaTeX team have been working on this with the TeX Live maintainer for some time, deciding on how best to handle the required adaptation. At the time of writing, we have several parts of the ’jigsaw’ decided but are still implementing them. There are particular issues with the package support: it’s very likely that a ’compatibility’ package will be needed at least in the short term. (The core team do not control all packages using the PDF back end primitives!) There is also a need to co-ordinate with MiKTeX, TeX Live management utilities and so on. All of this means that oicial (CTAN release) support for LuaTeX v0.85+ will not happen ’just yet’. Currently the plan is to get this in place by early in 2016 with a deinite requirement for it all to work for TL’16. Anyone testing in the meantime should get in contact with the team/me to get onto the CC list for discussions. To be clear: unless you are entirely comfortable hand-rebuilding formats and messing with your TeX tree, do not try LuaTeX v0.85 but wait for oicial support from TeX Live.
1116
Tags: format-iles (Prev Q) (Next Q)
Q: How to create luatex.fmt Tags: format-iles (Prev Q) I wanted to try the latest version of LuaTeX, so I downloaded the oicial precompiled binaries but these raw binaries are useless without a luatex.fmt. How can this ile be created? Tags: format-iles (Prev Q) User: h0b0 Answer by joseph-wright I’m assuming you have TeX Live installed, so will have the ile ’luatex.ini’. You need that (i.e. copy to where you are going to generate your format ile), as it speciies how to build the format. You should then be able to do luatex -ini luatex.ini to build the format ile. Tags: format-iles (Prev Q)
Packages Questions Q: Good lua code in .tex doesn’t work in .sty? Tags: packages (Prev Q) 1117
I have some luacode in a .tex ile that works ines, but does’t in a .sty ile -- with this error message : Runaway argument? ! File ended while scanning use of \luacode@grab@lines. \par mwe.tex .tex ile Skip code block \documentclass{article} \usepackage{luacode,mwe} \begin{document} % works fine for i = ḷ,1ḷ do tex.print (i) end % doesn't work \For \end{document} mwe.sty ile \newcommand{\For}{% \begin{luacode} for i = ḷ,1ḷ do tex.print (i) end \end{luacode} } Tags: packages (Prev Q) User: tarass
1118
Answer by joseph-wright The luacode environment works by changing catcode codes to make in the input easier to pass to Lua. That can’t work inside a macro: the input is already tokenized. In that sense luacode is similar to a verbatim environment. For any long block of Lua code you are best having it in a separate ile, whilst for short blocks I’d stick to \directlua and be aware of the requirements, which here are minimal \newcommand*\For{% \directlua{ for i = ḷ,1ḷ do tex.print(i) end }% } (You actually get the error as the \end{luacode} is being found using a verbatim-like approach, and that will always fail inside a macro.) Tags: packages (Prev Q)
Windows Skip to questions, Wiki by user caramdir windows is for questions which are speciic for the Microsoft Windows operating systems. Questions regarding MikTeX, a popular TeX distribution for Windows, should be tagged with miktex instead.
1119
Questions Q: Is it possible to run LuaTeX from a USB lash drive Tags: windows (Prev Q) (Next Q) I am looking for ways to install and run LuaTeX on a USB lash drive (Windows operating system). Tags: windows (Prev Q) (Next Q) User: yiannis-lazarides Answer by aditya ConTeXt minimals does not require any installation and can be run from a USB stick. It contains the latest luatex binary along with plain and context macro packages ... but no latex. So, depending on what macro package you want to use, it may or may not be useful. Answer by will-robertson LuaTeX will be included MiKTeX 2.9, due out soon. When that happens, I presume you’ll be able to run it (and hence LuaTeX) on MiKTeX Portable. (I couldn’t see anything about the portable version on the MiKTeX 2.9 beta page.) Answer by mpg TeX Live also ofers a portable mode, thought it’s not well documented (if at all) currently. With TeX Live 2010, use install-tl -portable, then select your USB stick as the destination folder. You can customize the installation as usual (eg, selecting only the packages you need in order to save space). One installed, all you need to do is to run the tl-portable.bat script at the root of the installation.
1120
Tags: windows (Prev Q) (Next Q)
Q: Precompiled header in Lualatex on Windows? Tags: windows (Prev Q) I am trying to typeset a longer document with lots of packages. Now it seems that pre-compiling the header can speed up the edit-compile-revise cycle quite a bit. I tried to follow the guideline from How to speed up pdlatex for a very large document on MacOS X? but it does not work on my system and I am not sure what I am doing wrong. My preamble.tex looks as follows: \documentclass[a4paper]{scrbook} \usepackage{scrpage2} \def\preambleloaded{Precompiled preamble loaded.} and the main.tex ile:
\def\ifundefined#1{\expandafter\ifx\csname#1\endcsname\relax} \ifundefined{preambl \typeout{PRECOMILED PREAMBLE NOT LOADED}\input{preamble} \else \typeout{\preambleloaded} \fi \begin{document} test test test \end{document} Now after compiling the preamble with lualatex -ini -job-name="main" "&lualatex preamble.tex\dump" a main.fmt ile is created and lualatex runs without errors. Compiling the main ile with lualatex -shell-escape main.tex gives the message right at the beginning that the preamble was not included: LaTeX2e 1121
LuaTeX adaptation of babel and hyphenation patterns for engl ish, loaded. PRECOMILED PREAMBLE NOT LOADED (C:/Users/User/Documents/LaTeX/precompile/preamble.tex (C:/Users/User/AppData/Roaming/MiKTeX/2.9/tex/latex/koma-script/scrbook.cls ... The only diference that I can think of at the moment is that I am using LuaLaTeX on Windows 7 instead of pdftex on Mac OS X as in the linked question. Any hint how to ix this is very appreciated. Tags: windows (Prev Q) User: alexander Answer by taco-hoekwater You need: lualatex -shell-escape "&main main.tex" otherwise the newly generated main.fmt ile is not used at all. Tags: windows (Prev Q)
Conditionals Skip to questions, Wiki by user lockstep conditionals is about macros like \if and \ifx that may execute other macros depending on whether certain conditions are true or not. Popular packages are etoolbox and ifthen.
1122
Questions Q: Check if LuaTeX is running Tags: conditionals (Prev Q) (Next Q) I want to check if my tex document is compiled with LuaTeX (or any other Lua TeX compiler). The simple approach from the TeXbook is to check the \directlua macro against \@empty, like \ifx\directlua\@empty{\errmessage{...}}\fi If I’m running luatex, everything is ine. If I run tex, the compilation fails with my \errmessage -- ine. But if I run latex, my error does not occur, but the compilation fails because of the undeined \directlua environment. Which \ifx statement works for all TeX dialects? And why not the one which works ine with plain TeX, the one from above? Thanks in advance :) UPDATE An solution for this is very easy, but I don’t know if it’s causing any problems in the future. \ifx\directlua\pgf@gd@undefined@donotuse{% \errmessage{an error}\fi works well with TeX and LaTeX. Is there a way which is more elegant and doesn’t need any additional packages? Otherwise I will post this as answer. Tags: conditionals (Prev Q) (Next Q) User: matten Answer by ulrike-ischer \@empty is deined in LaTeX, so your test fails. ifluatex.sty? It will work with plainTeX too, Answer by hasan-zakeri 1123
Why don’t you use
How about iftex? it works ine in plain, and gives you some other useful macros. It is also included in TeXLive. Tags: conditionals (Prev Q) (Next Q)
Q: Testing for TeX boolean in Lua code Tags: conditionals (Prev Q) How can I test for a TeX boolean in Lua? This kind of code doesn’t work: Skip code block \newif\if@mypkg@someif \begin{luacode} -- some lua code \if@mypkg@someif -- some more lua code \else -- another lua code \fi -- again some lua code \end{luacode} Is there a way to achieve this? Tags: conditionals (Prev Q) User: aphink
1124
Answer by aditya Tex expansion happens before control is passed to lua. The following minimal example works. Skip code block \documentclass{minimal} \usepackage{luacode} \newif\ifluaflag % \luaflagtrue \begin{luacode} print("before flag") \ifluaflag print("lua flag true") \else print("lua flag false") \fi \end{luacode} \begin{document} test \end{document} Tags: conditionals (Prev Q)
Graphics Skip to questions, Wiki by user seamus 1125
graphics is about inclusion of external graphic iles in your document. For questions about vector graphics created programmatically inside a (La)TeX document, use diagrams instead, or preferably the tag for speciic packages like tikz-pgf, pstricks, or metapost. Frequently Asked Questions 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.
How can I include SVG images in LaTeX documents? How can I convert a TeX document into a small PNG? What’s the best way to include Matlab graphics in LaTeX? Which graphics formats can be processed by LaTeX and pdfLaTeX? How can I include graphics whose ile path has spaces? Why does using transparency in illustrations cause text to appear in bold? Why can’t pdfLaTeX print EPS igures? What GUI applications exist to help generate graphics for LaTeX? Can I use TikZ to draw on an image? How can I include graphics whose ile path has multiple dots? How can I add a border to an image?
Questions Q: Ploting a function using mplib in lualatex Tags: graphics (Prev Q) This question asked about ways to generate a nice function graph in LaTeX. There are several great answers, however, most of the either rely on an external program to generate the plot, or, if they use TeX to calculate the coordinates of the graph, are restricted to only fairly simple functions. I wanted to come up with an answer using luatex, using lua to do the calculations, and mplib to actually draw the graph. However, I could not igure out how to use lua and mplib together. Generating the graph in lua is not hard, and I can pass the generated path to tikz for rendering: Skip code block 1126
\documentclass{article} \usepackage{luacode} \usepackage{tikḶ} \begin{luacode} require("math") sin=math.sin;cos=math.cos;pi=math.pi point = function (f,x) return "("..x..","..f(x)..")" end; path = function (f,a,b,n) local step = (b-a)/n; local s = ""; for x = a, b - step/2, step do s = s .. point(f,x) .. "--" end; s = s .. point(f,b); return s end; \end{luacode} \def\plot#1#2#3#4{% \directlua{ do local f = function (x) return #1 end; tex.print(path(f,#2,#3,#4)) end; }% }
\begin{document} \begin{tikḶpicture} \draw[thin,->] (-.2,ḷ)--(6.5,ḷ)node[right]{$x$}; \draw[thin,->] (ḷ,-2.2)--(ḷ,2.2)node[above]{$y$}; \draw[thick] \plot{sin(2*x)+cos(x)}{ḷ}{2*pi}{4ḷ}node[above]{$y=\sin(2x)+\cos(x) \end{tikḶpicture} \end{document} I would like to know what would be a best way to generate a drawing using lua and render it using mplib. Tags: graphics (Prev Q) User: jan-hlavacek
1127
Answer by aditya This is how I would do it in ConTeXt. I don’t know if similar functionality is available in a LaTeX package. Basically, I do the calculations in lua and write the result inside a \startMPcode .. \stopMPcode environment. \startluacode require("math") local sin = math.sin local cos = math.cos local pi = math.pi local function scale(x) return x .. " * 1cm" end local function pair(x,y) return "(" .. scale(x) .. "," .. scale(y) .. ")" end local function point(f,x) return pair(x, f(x)) end userdata = userdata or {} function userdata.draw_function(f, a, b, n) local step = (b-a)/n local path = {} local i = ḷ for x = a, b, step do path[i] = point(f,x) i = i + 1 end path = table.concat(path, "--") context("draw " .. path .. " withpen pencircle scaled 2bp;") end function userdata.draw_x_axis(from, to) 1128
end
context(" drawarrow " .. pair(from,ḷ) .. " -- " .. pair(to,ḷ) .. "; ") context(" label.rt ( btex $x$ etex , " .. pair(to,ḷ) .. ") ;")
function userdata.draw_y_axis(from, to) context(" drawarrow " .. pair(ḷ, from) .. " -- " .. pair(ḷ,to) .. "; ") context(" label.top ( btex $y$ etex , " .. pair (ḷ,to) .. ") ;") end function userdata.plot() userdata.draw_x_axis(-2, 6.5) userdata.draw_y_axis(-2.2, 2.2) local f = function (x) return sin(2*x) + cos(x) end userdata.draw_function(f, ḷ, 2*pi, 4ḷ) end \stopluacode \starttext \ctxlua {context.startMPcode() ; userdata.plot() ; context.stopMPcode() ; } \stoptext However, this assumes that everything that is written inside teh userdata.plot() function is MP code. If you also want that function to print stuf to the TeX stream, then you can store all the MP code inside a \startMPdrawing and \stopMPdrawing environment and retrieve them using \getMPdrawing. \startluacode require("math") 1129
local sin = math.sin local cos = math.cos local pi = math.pi local function scale(x) return x .. " * 1cm" end local function pair(x,y) return "(" .. scale(x) .. "," .. scale(y) .. ")" end local function point(f,x) return pair(x, f(x)) end userdata = userdata or {} function userdata.draw_function(f, a, b, n) local step = (b-a)/n local path = {} local i = ḷ for x = a, b, step do path[i] = point(f,x) i = i + 1 end path = table.concat(path, "--") context.startMPdrawing() context("draw " .. path .. " withpen pencircle scaled 2bp;") context.stopMPdrawing() end function userdata.draw_x_axis(from, to) context.startMPdrawing() context(" drawarrow " .. pair(from,ḷ) .. " -- " .. pair(to,ḷ) .. "; ") context(" label.rt ( btex $x$ etex , " .. pair(to,ḷ) .. ") ;") context.stopMPdrawing() end 1130
function userdata.draw_y_axis(from, to) context.startMPdrawing() context(" drawarrow " .. pair(ḷ, from) .. " -- " .. pair(ḷ,to) .. "; ") context(" label.top ( btex $y$ etex , " .. pair (ḷ,to) .. ") ;") context.stopMPdrawing() end function userdata.plot() userdata.draw_x_axis(-2, 6.5) userdata.draw_y_axis(-2.2, 2.2) local f = function (x) return sin(2*x) + cos(x) end userdata.draw_function(f, ḷ, 2*pi, 4ḷ) end \stopluacode \starttext \ctxlua { context.resetMPdrawing() ; userdata.plot() ; context.MPdrawingdonetrue() ; context.getMPdrawing() ; } \stoptext Answer by jan-hlavacek I combined Aditya’s ConTeXt solution with my original code and modiied it for LaTeX. It mostly works, except I seem to have trouble with using btex ... etex in labels. If I replace the two lines with mpost labels with their commented version in the code below, I get Skip code block 1131
! LuaTeX error ...share/texmf-texlive/tex/luatex/luamplib/luamplib.lua:74: invalid stack traceback: [C]: in function 'format' ...share/texmf-texlive/tex/luatex/luamplib/luamplib.lua:74: in function 'log' ...share/texmf-texlive/tex/luatex/luamplib/luamplib.lua:143: in function 'repor ...share/texmf-texlive/tex/luatex/luamplib/luamplib.lua:173: in function 'proce ...share/texmf-texlive/tex/luatex/luamplib/luamplib.lua:1ḷ1: in function 'proce :1: in main chunk. \endmplibcode ...adirect {luamplib.processlines()} l.49 \plot{sin(2*x)+cos(x)}{ḷ}{2*pi}{4ḷ}{-2}{2} The following works: Skip code block \documentclass{article} \usepackage{luatextra} \usepackage{luamplib} \begin{luacode} scale = function (x) return x .. " * 1cm" end; pair = function (x,y) return "("..scale(x)..","..scale(y)..")" end; point = function (f,x) return pair (x,f(x)) end; path = function (f,a,b,n) local step = (b-a)/n; local s = ""; for x = a, b - step/2, step do s = s .. point(f,x) .. "--" end; s = s .. point(f,b); return s end; draw_x_axis = function (from, to) tex.print(" drawarrow " .. pair(from,ḷ) .. " -- " .. pair(to,ḷ) .. "; ") tex.print([[ label.rt ( "x" , ]] .. pair(to,ḷ) .. ") ;") % The following does not work, though: %tex.print(" label.rt ( btex $x$ etex, " .. pair(to,ḷ) .. ") ;") end draw_y_axis = function (from, to) tex.print(" drawarrow " .. pair(ḷ, from) .. " -- " .. pair(ḷ,to) .. "; ") 1132
tex.print([[ label.top ( "y" , ]] .. pair (ḷ,to) .. ") ;") % The following does not work, though: %tex.print(" label.top ( btex $y$ etex , " .. pair (ḷ,to) .. ") ;")
end beginMPcode = function () tex.print("\string\\begin{mplibcode}") tex.print("beginfig(ḷ)") end; endMPcode = function () tex.print("endfig;") tex.print("\string\\end{mplibcode}") end; \end{luacode}
\def\plot#1#2#3#4#5#6{% \directlua{ require("math") local sin=math.sin;local cos=math.cos;local pi=math.pi % ... and so on local f = function (x) return #1 end;
}
beginMPcode() draw_x_axis(#2-.2,#3+.2) draw_y_axis(#5-.2,#6+.2) tex.print("draw " .. path(f,#2,#3,#4) .. " withpen pencircle scaled 2pt;" ) endMPcode() }%
\begin{document} \plot{sin(2*x)+cos(x)}{ḷ}{2*pi}{4ḷ}{-2}{2} \end{document} Any ideas on how to make this better, and how to ix the problem with labels? Tags: graphics (Prev Q)
1133
Verbatim Skip to questions, Wiki by user martin-scharrer verbatim is about macros and environments like \verb and verbatim which implement some form of verbatim mode, i.e. change the catcodes. A popular package is fancyvrb. For questions about the listings or the minted package, use the respective tag instead.
Questions Q: How to handle verbatim material in LuaLaTeX? Tags: verbatim (Prev Q) (Next Q) While trying to implement an own working alternative to shdoc (one of its issues see here) I encountered an interesting behaviour of LuaLaTeX I cannot explain. Consider the following code: Skip code block \documentclass{scrreprt} \usepackage{xparse} \usepackage{luacode} \DeclareDocumentCommand{\terminaloutput}{+v}{ \directlua{tex.print("\luatexluaescapestring{#1}")} } \begin{document} \terminaloutput{ total 1ḷ244 1134
drwxr-xr-x 47 User dr-xr-xr-x 8 User drwxr-xr-x 9 User -rw-r--r-- 1 User } \end{document}
Users Users Users Users
16384 4ḷ96 4ḷ96 295ḷ
Mar Jun Dec Mar
31 18:26 . 27 2ḷ15 .. 23 12:49 .editor 31 ḷ9:ḷ1 .bash_history
I just deined a function using a verbatim argument (\terminaloutput) which has to be verbatim since there is a _ in .bash_history. My question is why LaTeX is able to print the whole content of #1 (as expected in a continuous way) and Lua doesn’t print anything. Tags: verbatim (Prev Q) (Next Q) User: texnician Answer by mico Rather than re-invent the wheel, I prefer to refer to and build on Paul Isambert’s wonderful article LuaTEX: What it takes to make a paragraph, published in 2011 in Volume 32 of TUGBoat. In this article, the author discusses inter alia how one can make use of the LuaTeX’s process_input_buffer callback to handle verbatim material in a very robust and lexible manner. To quote from the article: One of the most arcane areas of TeX is catcode management. This becomes most important when one wants to print verbatim text, i.e. code that TeX should read as characters to be typeset only, with no special characters, and things turn deinitely dirty when one wants to typeset a piece of code and execute it too (one generally has to use an external ile). With the process_input_buffer callback, those limitations vanish: the lines we would normally pass to TeX can be stored and used in various ways afterward. The MWE shown adapts Paul’s code to LaTeX coding practices. (Paul’s code is distinctly PlainTEX-ish.) If you’re at all interested in this issue, you should absolutely read Paul’s original article; the material on handling verbatim material is on pp. 2 and 3 in the pdf ile (pp. 69 and 70 in original 1135
published article). Paul explains the issues far better than I possibly could. • The Lua-side code consists of deining a Lua table (which will hold the verbatim material) and 3 Lua functions that do most of the work. • The TeX-side code sets up several TeX macros that activate, invoke, and suspend the operation of the Lua functions. The main LaTeX macros are \printverbatim (you should be able to guess what it does...) and \useverbatim; the latter executes whatever is in the most recently read verbatim chunk. • A verbatim chunk is anything sandwiched between lines that say \Verbatim and \EndVerbatim, respectively. Note that I have not deined a LaTeX environment called Verbatim, although it wouldn’t be too hard to do so.
Skip code block \documentclass{scrreprt} %% Set up a Lua table and 3 Lua functions \directlua{% verb_table = {} function store_lines (str) if string.find (str , "\noexpand\\EndVerbatim" ) then luatexbase.remove_from_callback ( "process_input_buffer" , "store_lines") else table.insert(verb_table, str) 1136
end return "" end function register_verbatim () verb_table = {} luatexbase.add_to_callback( "process_input_buffer" , store_lines , "store_lines") end function print_lines ( catcode ) if catcode then tex.print ( catcode , verb_table) else tex.print ( verb_table ) end end } %% TeX-side code: define several macros \def\Verbatim{\directlua{register_verbatim()}} \def\useverbatim{\directlua{print_lines()}} \def\printverbatim{% \par \bgroup \setlength{\parindent}{ḷpt} \ttfamily \directlua{print_lines(1)} \egroup } \def\createcatcodes{% \bgroup \catcode`\\=12 \catcode`\{=12 \catcode`\}=12 \catcode`\$=12 \catcode`\&=12 \catcode`\^^M=13 \catcode`\#=12 \catcode`\^=12 \catcode`\_=12 \catcode`\ =13 \catcode`\~=12 \catcode`\%=12 \savecatcodetable 1 % '\savecatcodetable' is a LuaTeX primitive \egroup} \createcatcodes \def\Space{ } \bgroup 1137
\catcode`\^^M=13\gdef^^M{\quitvmode\par}% \catcode`\ = 13\gdef {\quitvmode\Space}% \egroup \begin{document} \Verbatim total 1ḷ244 drwxr-xr-x 47 User dr-xr-xr-x 8 User drwxr-xr-x 9 User -rw-r--r-- 1 User \EndVerbatim \printverbatim
Users Users Users Users
16384 4ḷ96 4ḷ96 295ḷ
Mar Jun Dec Mar
31 18:26 . 27 2ḷ15 .. 23 12:49 .editor 31 ḷ9:ḷ1 .bash_history
\bigskip \Verbatim \def\lululu{% Lua\kern-.ḷ1em \TeX }% \EndVerbatim \printverbatim \bigskip \useverbatim % this "registers" the macro "\lululu" \noindent\lululu \end{document} Answer by henri-menke Mico’s answer is very good and shows how a low-level implementation of verbatim bufers in LuaTeX could look like. ConTeXt comes with this feature included and it is super easy to use. Skip code block \starttext 1138
\startbuffer[terminal] total 1ḷ244 drwxr-xr-x 47 User Users dr-xr-xr-x 8 User Users drwxr-xr-x 9 User Users -rw-r--r-- 1 User Users \stopbuffer
16384 4ḷ96 4ḷ96 295ḷ
Mar Jun Dec Mar
31 18:26 . 27 2ḷ15 .. 23 12:49 .editor 31 ḷ9:ḷ1 .bash_history
\typebuffer[terminal] \startbuffer[logo] \def\lululu{% Lua\kern-.ḷ1em \TeX }% \stopbuffer \typebuffer[logo] \getbuffer[logo] \lululu \stoptext The output is similar to Mico’s answer. Tags: verbatim (Prev Q) (Next Q)
Q: show content of token register as a string in the document Tags: verbatim (Prev Q) I’m trying to implement a command that can execute its argument, but also print it. 1139
To that end I’m dumping the argument into a toks register and use LuaTex to put it back with inactive catcodes; as it says in the manual: tex.print( n, s, ...) If n is −1, the currently active catcode regime is used. If n is −2, the resulting catcodes are the result of \the\toks: all category codes are 12 (other) except for the space character, that has category code 10 (space) \newcommand{\showandtell}[1]{\toksḷ{#1}% {using the argument #1 executes}\\ {printing with current \directlua{tex.print(-1, tex.toks[ḷ])} executes}\\ {printing with inert \texttt{ \directlua{tex.print(-2, tex.toks[ḷ])}} shows the code}\\ {reading the register \the\toksḷ executes} } \noindent\showandtell{\bfseries\color{red}} From ”the resulting catcodes are the result of \the\toks” in the manual I was expecting \the\toksḷ to have the opposite efect. How can I get the efect of print(-2 in pure TeX? The token register appears to be stored as a string, discarding the original catcodes, but then how can packages like verbatim just use just \the\verbatim@line and produce plain output?
Tags: verbatim (Prev Q) User: pascal Answer by egreg 1140
You can obtain the same efect in e-TeX (not in Knuth TeX) with \detokeniḶe, which is available when LaTeX is used (on TeX distributions not more than ten years old). Skip code block \documentclass{article} \usepackage{color} \newcommand{\showandtell}[1]{% {using the argument #1 executes}\\% printing with detokeniḶe \texttt{\detokeniḶe{#1}} shows the code% } \begin{document} \noindent \showandtell{\bfseries\color{red}} \end{document}
If you want to use a token register, then \detokeniḶe\expandafter{\the\toksḷ} will do. Verbatim modes attain their purpose by changing category codes before starting to read the material, which is why they can’t be used in the argument to a command. Note, however, that \detokeniḶe, like the LuaTeX code you used, adds a space after control words (which verbatim modes don’t). Answer by jfbu It is also possible to achieve this in Knuth TeX via \meaning. Although there is no reason not to use \detokeniḶe if it is available. Skip code block
1141
\documentclass{article} \usepackage{color} \makeatletter \let\StripPrefix\strip@prefix % Latex kernel command \makeatother
\newcommand{\showandtell}[1]{% {using the argument #1 executes}\\% \def\TEMP {#1}% playing tricks with meaning \texttt{\expandafter\StripPrefix\meaning\TEMP} shows } \begin{document} \noindent \showandtell{\bfseries\color{red}} \end{document}
and if you want to show things from \toksḷ register you can do \expandafter\def\expandafter\TEMP\expandafter{\the\toksḷ} or simpler \edef\TEMP{\the\toksḷ} and then the \meaning thing. Tags: verbatim (Prev Q)
1142
Latexmk Skip to questions, Wiki by user martin-scharrer The latexmk program allows to automatically run latex and related commands as many times as needed to build the inal document. It is an alternative or complement to Makeiles or similar functionality of integrated LaTeX editors. It is available on CTAN and on its project site by the maintainer, John Collins. See the manpage for more information. There is a similar tool named LaTeX-Mk, which yet is distinct from latexmk.
Questions Q: Is there latexmk functionality for LuaTeX? Tags: latexmk (Prev Q) (Next Q) I am a big fan of latexmk and lately I have been looking a bit towards LuaTeX. However I am am yet to ind a way to get the functionality of latexmk (mainly recompilation on changes and automatic rerun an appropriate number of times to resolve cross references and such) for LuaTex. Is there something similar and if not how do you LuaTeX people survive without it? :) Tags: latexmk (Prev Q) (Next Q) User: jonalv Answer by diabonas You can use Lua(La)TeX with latexmk by setting the -pdflatex parameter: 1143
-pdflatex= - set program used for pdlatex. (replace ’’ by the program name) So latexmk should call lualatex instead of pdflatex if you invoke it like this: latexmk -pdflatex=lualatex -pdf or with newer versions of latexmk there is direct Lua(La)TeX/XeLaTeX support: -lualatex Use lualatex. That is, use lualatex to process the source ile(s) to pdf (in place of pdlatex). This option is exactly equivalent to specifying the following sequence of options: -pdlatex=”lualatex %O %S” -pdf -dvi- -psAnswer by yossi-gil Instead of adding the -lualatex lag to each application of latexmk, you could place the following $pdflatex = 'lualatex -file-line-error %O %S'; $pdf_mode = 1; in an ’.latexmkrc’ ile. This ile should reside in your home folder, if you use lualatex in all your jobs, or in the folder(s) where your lualatex jobs are. More generally, you will ind a host of examples and boilerlate code for .latexmkrc in the respective CTAN repository Tags: latexmk (Prev Q) (Next Q)
Q: Specify timezone for \today and \currenttime Tags: latexmk (Prev Q) 1144
Is there a way I can specify the timezone LaTeX should use when printing the \today and \currenttime (or the datetime package in general)? I need this because travisCI does build my PDF automatically on every commit and their timezone seems to be set to GMT. I’d need GMT+1. Contrary to some other questions I don’t want the timezone to be displayed, I just want the date & time to be in the speciied timezone. For building I use latexmk with pdlatex set to LuaLaTeX. Tags: latexmk (Prev Q) User: michael-weibel Answer by michael-weibel Immediately after asking this question an idea came to my mind which worked out. In order to specify the timezone you can just set the usual linux environment variable TZ before building the PDF. As an example if you have a Makefile which builds it on running make you can set it like this: TZ='Europe/Zurich' make Or, of course, export it before running the build using export TZ='Europe/Zurich'. Tags: latexmk (Prev Q)
1145
Boxes Questions Q: Value of LuaTeX’s \mathstyle in \frac (de)nominator Tags: boxes (Next Q) This was ixed in version from 2017/06/15 (available on CTAN). This is a followup question of How to transfer math style in \hbox_set?. While the code I posted there as an answer using LuaTeX’s \mathstyle primitive it doesn’t work inside of the (de)nominator of a \frac. If a \frac happens to appear in \textstyle the (de)nominator actually is set in \scriptstyle (as far as I can tell), but \mathstyle stell equals 2.
Skip code block % !TeX program = luatex \documentclass{article} \usepackage{parskip,xparse,xcolor} \usepackage{amsmath,lualatex-math} 1146
\ExplSyntaxOn\makeatletter
\cs_new:Npn \tobi_save_math_style: { \int_case:nn { \mathstyle } { { \displaystyle } { \tl_set:Nn \l_tobi_saved_math_style_tl { \displaystyle } { \textstyle } { \tl_set:Nn \l_tobi_saved_math_style_tl { \textstyle } } { \scriptstyle } { \tl_set:Nn \l_tobi_saved_math_style_tl { \scriptstyle } } { \scriptscriptstyle } { \tl_set:Nn \l_tobi_saved_math_style_tl { \scriptscr } }
\NewDocumentCommand { \boxtest }{ m }{ \mode_if_math:TF { % aktuellen Mathemodus ermitteln und für später sichen \tobi_save_math_style: % Box mit entsprechender Formel speichern \hbox_gset:Nn \l_tmpa_box { \begingroup \( \m@th \tl_use:N \l_tobi_saved_math_style_tl #1 \) \endgroup } } { \hbox_set:Nn \l_tmpa_box { #1 } } \fbox { \box_use:N \l_tmpa_box } [\tl_to_str:n { \mathstyle } = \mathstyle; saved style = \tl_to_str:N \l_tobi_s } \cs_new:Npn \tobi_genfrac:nnnn #1#2#3#4 { % \colorlet { l_tobi_current_color_before_frac } { . } % \begingroup % \color { #2 } \genfrac { } { } { } { #1 } { 1147
% % % }
} {
\color { l_tobi_current_color_before_frac } #3 \color { l_tobi_current_color_before_frac } #4
} \endgroup
\RenewDocumentCommand { \frac } { O{.} m m } { \tobi_genfrac:nnnn { } { #1 } { #2 } { #3 } } \makeatother\ExplSyntaxOff \begin{document} OK: $a^2 = a^{\boxtest{2}}$ OK: $\displaystyle \frac{1}{2} = \frac{\boxtest{1}}{2}$ OK: $\frac{1}{2} = \boxtest{\frac{1}{2}}$ OK: $\displaystyle \frac{1}{2} = \boxtest{\frac{1}{2}}$ wrong: $\frac{1}{2} \neq \frac{\boxtest{1}}{2}$ wrong: $\genfrac{}{}{}{}{1}{2} \neq \genfrac{}{}{}{}{\boxtest{1}}{2}$ \end{document} So … is it possible to capture the correct style in this case too? Update: I added an example using \genfrac, which is used in my real document do get a coloured fraction line. Tags: boxes (Next Q) User: tobi 1148
Answer by david-carlisle \frac{a}{b} is essentially {a \over b} and the big problem with the inix \over is that it makes tracking the current style hard luatex does not change that. to get a version in which \mathstyle is set you need \Ustack{a \over b} so in latex you would have to redeine \frac and related commands to use \Ustack. One possibility would be to load lualatex-math which redeines \frac in this way. Tags: boxes (Next Q)
Q: write the content of an hbox in an auxilary ile Tags: boxes (Prev Q) (Next Q) I know that TeX can’t write the content of hbox in an auxiliary ile (Re-parse the content of a box register). That mean that \newwrite\foo \immediate\openout\foo=\jobname.txt \setboxḷ=\hbox{bar} \immediate\write\foo{\boxḷ} can’t write However, can LuaTeX do it? I have found \directlua{ n = tex.getbox(ḷ) } But I don’t understand what n is representing and if I could use it to write the box content in a ile. 1149
Tags: boxes (Prev Q) (Next Q) User: maïeul Answer by michal.h21 Variablen in your example is a node list. Various types of nodes exists, such as glyphs for characters, glue for spacing, or hlist which is the type you get for your \hbox. hlist contains child nodes, which are accessible in n.head attribute. You can then loop this child list for glyphs and glues. Each node type is distinguishable by value of n.id attribute. Particular node types and possible attributes are described in chapter ”8 Nodes”. In this particular example, we need to process just glyph and glue nodes, but you should keep in mind that node lists are recursive and various nodes can contain child lists, like hlist, vlist, etc. You can support them with recursive call of nodeText on current node head attribute. Regarding glyph nodes, char attribute contains unicode value only in the case if you use opentype or truetype fonts, if you use old 8-bit fonts, it contains just 8-bit value which actual encoding depends on used font encoding and it isn’t easy to convert it to unicode. Skip code block \documentclass{article} \usepackage{fontspec} \begin{document} % child \hbox will produce a hlist node \setboxḷ=\hbox{Příliš žluťoučký kůň úpěl \hbox{ďḹbelské} ódy} \directlua{ local char = unicode.utf8.char local function nodeText(n) local t = {} for x in node.traverse(n) do % glyph node if x.id == 37 then table.insert(t,char(x.char)) % glue node elseif x.id == 1ḷ and x.subtype == ḷ then 1150
}
table.insert(t," ") % hlist elseif x.id == ḷ then table.insert(t,nodeText(x.head)) end end return table.concat(t) end local n = tex.getbox(ḷ) print(nodeText(n.head)) local f = io.open("hello.txt","w") f:write(nodeText(n.head)) f:close()
\boxḷ \end{document} nodeText function returns text contained in the node list. It is used to print \hbox contents to the terminal and to write to ile hello.txt in this example. For basic info about font style, you can try to use l4fontstyles module, like this: local fontstyles = require "l4fontstyles" ... if x.id == 37 then table.insert(t,char(x.char)) local y = fontstyles.get_fontinfo(x.font) print(y.name,y.weight,y.style) Tags: boxes (Prev Q) (Next Q)
Q: How to get box dimensions within lualatex Tags: boxes (Prev Q) 1151
I’m new to lualatex, which looks phenomenal. I wonder what the easiest way is to access the dimensions of a box from within lualatex. I intend to use it in more complicated situations than this (as part of lua chunks) so I’m not looking for a hack within latex that feeds the dimensions to the lua chunk. I’m aware of the limitations of \directlua. Is this something that should be done using the node library? How? Skip code block \documentclass{minimal} \usepackage{luacode} \newcommand{\measureme}[1]{% \directlua{-- what should go here to get the siḶe of the box?}% } \begin{document} The siḶe is \measureme{this box}. \end{document} Tags: boxes (Prev Q) User: jpi Answer by david-carlisle Skip code block \documentclass{article} \makeatletter \let\pc\@percentchar \makeatother \newbox\ḶḶḶ 1152
\newcommand{\measureme}[1]{% \sbox\ḶḶḶ{#1}% \typeout{from TeX ht:\the\ht\ḶḶḶ, dp:\the\dp\ḶḶḶ, wd:\the\wd\ḶḶḶ}% \directlua{ local n = tex.getbox('ḶḶḶ') print(string.format("from Lua ht:\pc fpt, dp:\pc fpt, wd:\pc fpt", n.height/65536, n.depth/65536, n.width/65536 )) }} \begin{document} The siḶe is \measureme{this box}. \end{document} demonstrates accessing box dimensions from tex and Lua, it logs: from TeX ht:6.94444pt, dp:ḷ.ḷpt, wd:35.33342pt from Lua ht:6.944443pt, dp:ḷ.ḷḷḷḷḷḷpt, wd:35.33342ḷpt Tags: boxes (Prev Q)
TeX4ht Skip to questions, Wiki by user n.n. TeX4ht is a highly conigurable TeX-based authoring system dedicated 1153
mainly to produce hypertext. It interacts with TeX-based applications through style iles and postprocessors, leaving the processing of the source iles to the native TeX compiler. Consequently, TeX4ht can handle the features of TeX-based systems in general, and of the LaTeX and AMS style iles in particular. Pre-tailored conigurations are ofered for diferent output formats, including (X)HTML, MathML, OpenDocument, and DocBook.
Questions Q: text4ht and LuaTeX Tags: tex4ht (Prev Q) (Next Q) There is a speciic command to run tex4ht with XeTeX: htxelatex (which doesn’t really work actually as far as I’m concerned). What is the command to run text4ht with LuaTeX instead? Tags: tex4ht (Prev Q) (Next Q) User: aphink Answer by michal.h21 Edit Oct 2015: Issues with babel are now ixed, the document can be compiled without errors. make4ht, new build tool for tex4ht supports LuaLaTeX out of the box, you can just use make4ht -l filename The minimal sample ile may look like this: \documentclass{article} \usepackage[cḶech]{babel} 1154
\usepackage[T1]{fontenc} \usepackage[utf8]{luainputenc} \begin{document} Příliš žluťoučký kůň úpěl ďḹbelské ódy. NaḶd\~ar \end{document} There is also some experimental support for Fontspec, see my guide Original post You can try this shell script, windows version is there
#!/bin/sh lualatex --output-format=dvi --jobname=$1 $5 '\makeatletter\def\HCode{\futurelet\H lualatex --output-format=dvi --jobname=$1 $5 '\makeatletter\def\HCode{\futurelet\H lualatex --output-format=dvi --jobname=$1 $5 '\makeatletter\def\HCode{\futurelet\H tex4ht -.dvi -f/$1 -i~/tex4ht.dir/texmf/tex4ht/ht-fonts/$3 t4ht -.dvi -f/$1 $4 ## -d~/WWW/temp/ -m644 save it as htlualatex and make executable. This code sample \documentclass{article} \usepackage[english]{babel} \usepackage[utf8]{luainputenc} \begin{document} \section{Does it make sense?} Příliš žluťoučký kůň úpěl ďḹbelské ódy \end{document} gives some compilation errors about invalid utf-8 sequences, but the html output is correct. Without \usepackage[utf8]{luainputenc} the output ile ended at the irst accented character. Tags: tex4ht (Prev Q) (Next Q)
1155
Q: tex4ht corrupts ”--” inside CDATA in the HTML ile Tags: tex4ht (Prev Q) I am using an outside javascript package (syntaxHighlighter) for code formatting when I compile to HTML that requires one to put code inside as explained in the above link
This causes no problem, except that tex4ht for some reason changes -- (two dashes) to something strange which causes syntaxHighlighter to fail rendering it, since it does not show on the screen, which is wrong. Here is a MWE, and I show the command used and the inal HTML, one can see clearly that -- has been changed. This should not happen. Anything inside should not be touched by tex4ht as this is plain verbatim code and should be left as is. It is means to be used by the Javascript library. Skip code block \documentclass[11pt]{scrartcl}% \IfFileExists{luatex85.sty}{\usepackage{luatex85}}{} \ifdefined\HCode% detect tex4ht \usepackage[utf8]{luainputenc} \usepackage[T1]{fontenc} \else \usepackage{fontspec} \fi
1156
\begin{document} \ifdefined\HCode {\ScriptEnv{html}{\ifvmode\IgnorePar\fi\EndP\NoFonts\hfill\break}{\EndNoFonts\endg \begin{html}
\end{html}} \else test \fi \end{document} Compiled using make4ht --lua foo7_1.tex and this is how the HTML looks like Skip code block
1157
Notice the -- are not displayed any more. They are changed to some nondisplayable code. Here is screen shot
What do I need to change to make tex4ht not change code inside my HTML like this? Please note that when you compile the above to HTML on your computer, nothing will display, since one needs the javascript package installed. But by viewing the source, one can see the problem. A hex dump of the HTML shows that -- was changed to hex 15
1158
Which from the ascii table it is NAK (negative acknowledge) Update This problem happens for any data, even in ... and has nothing to do with CDATA. It seems tex4ht simply does not like to see -when in lualatex mode. Here is a new MWE Skip code block \documentclass[11pt]{article}% \IfFileExists{luatex85.sty}{\usepackage{luatex85}}{} \ifdefined\HCode% detect tex4ht \usepackage[utf8]{luainputenc} \usepackage[T1]{fontenc} \else \usepackage{fontspec} \fi
\begin{document} \ifdefined\HCode {\ScriptEnv{html}{\ifvmode\IgnorePar\fi\EndP\NoFonts\hfill\break}{\EndNoFonts\endg \begin{html}
-- this is a test
\end{html}} \else test \fi \end{document} Same problem. Here is the HTML generated after make4ht --lua foo.tex
1159
If I do not NOT compile using lualatex mode, then it works! And I get -show up in HTML. i.e. if I compile the above using make4ht foo.tex, here is the HTML
Now the -- are there. So this is a problem with lualatex mode with tex4ht. Tags: tex4ht (Prev Q) User: nasser
1160
Answer by michal.h21 Hyphen character is made active by \ScriptEnv command, which means that it calls a command when it is encountered in the environment deined with it. The ScriptEnv deinition is little bit cryptic: Skip code block \bgroup \catcode`\-=13 \catcode`\(=1 \catcode`\)=2 \catcode`\/=ḷ \catcode`\{=12 \catcode`\}=12 \catcode`\\=12 /gdef/ScriptEnv#1(% /expandafter/let/csname :#1:/endcsname=/empty /edef/:temp(/def/expandafter/noexpand/csname a:#1/endcsname ####1/expandafter/noexpand/csname end/endcsname{#1}% (####1/noexpand/:EndVerbatim/noexpand/end(#1)))/:temp % /expandafter/def/csname % b:#1/endcsname##1\end{#1}(##1/:EndVerbatim/end(#1))% /expandafter/def/csname b:#1/endcsname(/bgroup /catcode`/-=13 /def/:temp####1\end{#1}(/egroup /def-(/string-/relax) ####1/:EndVerbatim% /expandafter/def/csname end#1/endcsname()% /end(#1))% /:temp)% /edef/:temp(/noexpand/DefScript: /expandafter/noexpand/csname #1/endcsname (/expandafter/noexpand/csname a:#1/endcsname)% (/expandafter/noexpand/csname b:#1/endcsname))/:temp ) /egroup the important line is: /def-(/string-/relax) it seems that under LuaTeX, two consecutive hyphens forms endash in this case, which is not translated to unicode character for some reason, but remains in 8-bit encoding. I don’t really understand it, but the solution is 1161
to alter the \ScriptEnv deinition to suppress the ligature forming: Skip code block \bgroup \gdef\:scriptenv:breakhyphen{\hbox{}} \catcode`\-=13 \catcode`\(=1 \catcode`\)=2 \catcode`\/=ḷ \catcode`\{=12 \catcode`\}=12 \catcode`\\=12 /gdef/ScriptEnv#1(% /expandafter/let/csname :#1:/endcsname=/empty /edef/:temp(/def/expandafter/noexpand/csname a:#1/endcsname ####1/expandafter/noexpand/csname end/endcsname{#1}% (####1/noexpand/:EndVerbatim/noexpand/end(#1)))/:temp % /expandafter/def/csname % b:#1/endcsname##1\end{#1}(##1/:EndVerbatim/end(#1))% /expandafter/def/csname b:#1/endcsname(/bgroup /catcode`/-=13 /def/:temp####1\end{#1}(/egroup /def-(/string-/:scriptenv:breakhyphen/relax) ####1/:EndVerbatim% /expandafter/def/csname end#1/endcsname()% /end(#1))% /:temp)% /edef/:temp(/noexpand/DefScript: /expandafter/noexpand/csname #1/endcsname (/expandafter/noexpand/csname a:#1/endcsname)% (/expandafter/noexpand/csname b:#1/endcsname))/:temp ) /egroup correct the deinition in local copy of latex.4ht. I will update the tex4ht sources. Tags: tex4ht (Prev Q)
1162
Arabic Questions Q: What happened to \luatextextdir? Tags: arabic (Prev Q) (Next Q) As of today, the command \luatextextdir does no longer seem to work. I employ the command in order to be able to typeset Arabic. To that end I created the following commands: \newcommand{\arabtext}[1] % Arabic inside LTR {\bgroup\luatextextdir TRT\arabicfont #1\egroup} \newcommand{\arabnr}[1] % for numbers inside Arabic text {\bgroup\luatextextdir TLT #1\egroup} \newenvironment{arabpar} % Arabic paragraph {\luatextextdir TRT\luatexpardir TRT\arabicfont}{} As of today, however, I get the otherwise well-known ”Undeined control sequence” - error. I just updated all the packages to the newest version using the TeX Live Utility. Tags: arabic (Prev Q) (Next Q) User: clinteastwood Answer by joseph-wright The ’proper’ (internal) name of the primitive has always been \textdir, but for various reasons it used to be ’activated’ as \luatextextdir in LuaLaTeX. The LaTeX team have recently revised this approach and all primitives now have their ’natural’ names in LuaLaTeX. Thus you should either update your code or add \directlua{ tex.enableprimitives("luatex",tex.extraprimitives("omega")) } 1163
to your preamble. (\textdir comes from Omega so is currently in a list called omega. At some stage in the near future it will be moved to a list called luatex, so tex.extraprimitives("omega", "luatex") is slightly more future-proof. However, I’d strongly advise revising your code to drop the preix entirely.) Tags: arabic (Prev Q) (Next Q)
Q: Typesetting arabic with LuaLaTeX Tags: arabic (Prev Q) For typesetting arabic with LaTeX there are arabtex and arabi; for typesetting arabic with XeLaTeX there are arabxetex and polyglossia; but how to typeset arabic with LuaLaTeX, since neither of these packages/methods does not work? And there is deinitely a way (with very nice results) as demonstrated in ”Fonts” papers (PDF) from LuaTeX web page. I’ve also found Khaled’s lualatex-package package, but still no go. Any suggestions? Tags: arabic (Prev Q) User: meho-r. Answer by user9783 It is because some works is in progress specially for the bidi package, on the other hand I am waiting for some of luatex bidi bugs getting ixed. you can test things if you want: \documentclass{article} \usepackage{fontspec} \setmainfont[Script=Arabic]{font-name} \usepackage{bidi} 1164
\pagedir TRT\pardir TRT\bodydir TRT\textdir TRT \begin{document} %your Arabic text \end{document} Answer by clinteastwood Two days ago Khaled Hosny sent me this: Skip code block \documentclass{article} \usepackage{fontspec} \setmainfont[Ligatures=TeX]{Junicode} \newfontfamily\arabicfont [Script=Arabic, % to get correct arabic shaping Scale=1.2] % make the arabic font bigger, a matter of taste {ScheheraḶade} % whatever Arabic font you like \newcommand{\textarabic}[1] % Arabic inside LTR {\bgroup\luatextextdir TRT\arabicfont #1\egroup} \newcommand{\n} [1] % for digits inside Arabic text {\bgroup\luatextextdir TLT #1\egroup} \newcommand{\afootnote} [1] % Arabic footnotes {\footnote{\textarabic{#1}}} \newenvironment{Arabic} % Arabic paragraph {\luatextextdir TRT\luatexpardir TRT\arabicfont}{} \begin{document} English text ``\textarabic{ {'' with Arabic in between. English paragraph left aligned English paragraph left aligned English paragraph left aligned English paragraph left aligned English paragraph left aligned English paragraph left aligned English paragraph left aligned English paragraph left aligned English paragraph left aligned English paragraph left aligned English paragraph left aligned.
1165
\begin{Arabic} }afootnote\ \end{Arabic}
\n{} {. .
\end{document} This probably is as uptodate as it gets atm. Tags: arabic (Prev Q)
File Size Questions Q: Is there a limit to the size of a tex-ile? Tags: ile-size (Prev Q), input (Next Q) I’ve been writing a document for some time now. It is steadily growing and hopefully will continue to do so. Lately I realised that -- although I just recently bought a new MacBook -- when I work on my largest tex-file typing is a little slow in TexShop. To be precise, when I write a sentence, then I am often inished on the keyboard with typing and still see the letters appear one after another on the screen for, say, two or three seconds until TexShop is inally done with the sentence. There is, then, a certain latency. Now, I am aware that this is a separate issue that should be directed at the developers of TexShop, but it started me thinking whether there is 1. a maximum size of a tex-file (characters or kilobytes) that one can technically \input or \include into the the main ile which contains 1166
the preamble and the \begin{document} and \end{document} or, alternatively, whether there is 2. a maximum ile size that is recommended for a tex-file to \input or \include into the the main ile. The question has a bearing on my latency problem, because I could solve the latency problem by subdividing the larger iles into smaller ones, but I would prefer not to do so -- actually for no good reason -- unless it was recommended along the lines of question #2. While I would primarily be interested in answers that pertain to LuaLaTeX, I guess for other users here on the site answers that pertain to LaTeX and XeLaTeX will also be interesting. Tags: ile-size (Prev Q), input (Next Q) User: clinteastwood Answer by david-carlisle TeX only processes the input line by line, so there is a limit on the number of characters in a line, but not on the total size of the ile. Your editor however probably does need to read the entire ile into memory so may have limits on the ile size. The editor I use warns if the ile is more than 10MB but will open iles larger than that, up to the memory available on the machine. The line bufer is conigurable in texmf.cnf, the one with texlive 2014 says % Buffer siḶe. TeX uses the buffer to contain input lines, but macro % expansion works by writing material into the buffer and reparsing the % line. As a consequence, certain constructs require the buffer to be % very large, even though most documents can be handled with a small value. buf_siḶe = 2ḷḷḷḷḷ In luatex this bufer setting is ignored and the bufer is dynamically allocated as needed luatex manual section 10.2:
1167
The input line bufer and pool size are now also reallocated when needed, and the texmf.cnf settings buf_size and pool_size are silently ignored. Tags: ile-size (Prev Q), input (Next Q)
Tcolorbox Skip to questions, Wiki by user cmhughes {tcolorbox} provides an environment for colored and framed text boxes with a heading line. Optionally, such a box can be split in an upper and a lower part. The package can be used for the setting of LaTeX examples where one part of the box displays the source code and the other part shows the output. Another common use case is the setting of theorems. The package supports saving and reuse of source code and text parts. The tcolorbox package has many features: • • • • • • • •
Colored graphical boxes with background, frame and titles TikZ overlays and underlays to make use of the TikZ engine Code listings with listings and minted Theorems Rasters of boxes Vignetted boxes Magazine mode beamer support with the beamer syntax for slide overlays
1168
Questions Q: Possible Lualatex problem with documentation library from tcolorbox Tags: tcolorbox (Prev Q), listings (Next Q) I am developping a package which uses some lualatex features. In order to show examples in the documentation, I have to use lualatex for the compilation as well. I decided to use the documentation library from the tcolorbox package, however this fails, if I want to use lualatex. The compilation stops with this error message right at the start (i.e. in the preamble phase) ! String contains an invalid utf-8 sequence. l.52 moredelim={[is][\itshape\rmfamily]{ }{}}, The additional tcolorbox libraries listings or listingsutf8 did not help. Since documentation is based on those libraries (as far as I understand it) I suspect however that this unhealthy feature has it’s origin in the listings package (the moredelim error is some indicator) I tried the solution to a similar problem (LuaLaTeX and listings do not work while XeLaTex works ine), but it does not improve the situation. I don’t claim this is a bug of tcolorbox or listings.sty really. Skip code block \documentclass{article} \usepackage{blindtext} \usepackage[documentation]{tcolorbox} \begin{document} \blindtext \end{document}
1169
Tags: tcolorbox (Prev Q), listings (Next Q) User: christian-hupfer Answer by ulrike-ischer Replacing the two § with ^^a7 in tcbdocumentation.code.tex should work. Tags: tcolorbox (Prev Q), listings (Next Q)
Bugs Skip to questions, Wiki by user alfc This tag should be used for asking about workaround over possible bugs in TeX and related programs. (Bugs should be reported else where.)
Questions Q: TeX Live 2016: minted doesn’t work with LuaLaTeX (bug ixed in June 2016) Tags: bugs (Prev Q) I’ve installed TeX Live 2016 as it was released today (thanks to the developers for that). Now I have the following MWE: Skip code block
1170
\documentclass{article} \usepackage{minted} \begin{document} \begin{minted}{ruby} class Foo def init pi = Math::PI @var = "Pi is approx. #{pi}" end end \end{minted} \end{document} When running pdflatex --shell-escape test.tex it runs through the ile and produces the PDF as expected. Doing the same with lualatex --shell-escape test.tex fails with Skip code block This is LuaTeX, Version ḷ.95.ḷ (TeX Live 2ḷ16) system commands enabled. (./test.tex LaTeX2e Babel and hyphenation patterns for 1 language(s) loaded. (/opt/texlive/2ḷ16/texmf-dist/tex/latex/base/article.cls Document Class: article 2ḷ14/ḷ9/29 v1.4h Standard LaTeX document class (/opt/texlive/2ḷ16/texmf-dist/tex/latex/base/siḶe1ḷ.clo)) (/opt/texlive/2ḷ16/texmf-dist/tex/latex/minted/minted.sty (/opt/texlive/2ḷ16/texmf-dist/tex/latex/graphics/keyval.sty) (/opt/texlive/2ḷ16/texmf-dist/tex/latex/oberdiek/kvoptions.sty (/opt/texlive/2ḷ16/texmf-dist/tex/generic/oberdiek/ltxcmds.sty) (/opt/texlive/2ḷ16/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty (/opt/texlive/2ḷ16/texmf-dist/tex/generic/oberdiek/infwarerr.sty) (/opt/texlive/2ḷ16/texmf-dist/tex/generic/oberdiek/etexcmds.sty (/opt/texlive/2ḷ16/texmf-dist/tex/generic/oberdiek/ifluatex.sty)))) (/opt/texlive/2ḷ16/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty Style option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix 1171
(tvḶ)) (/opt/texlive/2ḷ16/texmf-dist/tex/latex/float/float.sty) (/opt/texlive/2ḷ16/texmf-dist/tex/latex/base/ifthen.sty) (/opt/texlive/2ḷ16/texmf-dist/tex/latex/tools/calc.sty) (/opt/texlive/2ḷ16/texmf-dist/tex/latex/ifplatform/ifplatform.sty (/opt/texlive/2ḷ16/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty (/opt/texlive/2ḷ16/texmf-dist/tex/generic/oberdiek/ifpdf.sty) (/opt/texlive/2ḷ16/texmf-dist/tex/generic/oberdiek/luatex-loader.sty (/opt/texlive/2ḷ16/texmf-dist/scripts/oberdiek/oberdiek.luatex.lua))) (/opt/texlive/2ḷ16/texmf-dist/tex/generic/oberdiek/catchfile.sty) uname -s > "test.w18" ! Package catchfile Error: File `test.w18' not found. See the catchfile package documentation for explanation. Type H for immediate help. ... l.93
\CatchFileDef\@tempa{\ip@file}{}
? As mentioned, it’s a freshly installed TeX Live 2016; I’ve also checked the installed Pygmentize version, which is 2.1.3 (installed via pip). Testing with TeX Live 2015, the above code, however, works without problems with both pdlatex and lualatex. Does anybody have a hint for me on how to ix this, or is it a bug in lualatex or minted (or whatever other package) that should be reported? Update: With minted version 2.2 (2016-06-08), the package loads the shellesc package automatically, as mentioned by @David Carlisle and @egreg in the comments; therefore, the problem should not occur any more, if you have this version installed. Tags: bugs (Prev Q) User: stephan-lukasczyk Answer by egreg 1172
Several packages using \write18 will need to be updated for compatibility with LuaLaTeX under LuaTeX 0.90; minted is among them. However, the shellesc package provides the necessary workaround: Skip code block \documentclass{article} \usepackage{shellesc} \usepackage{minted} \begin{document} \begin{minted}{ruby} class Foo def init pi = Math::PI @var = "Pi is approx. #{pi}" end end \end{minted} \end{document} (credit to ArTourter for noting it). Here’s a set of patches that replace all appearances of \immediate\write18 with \ShellEsc, the safer way without relying on redeinitions of \write. These patches don’t need LuaLaTeX at all, so the code works with all engines. Skip code block \documentclass{article} \usepackage{shellesc,xpatch} \usepackage{minted} \makeatletter \xpatchcmd{\DeleteFile} {\immediate\write18} {\ShellEscape} {}{} 1173
\xpatchcmd{\DeleteFile} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\ProvideDirectory} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\TestAppExists} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\TestAppExists} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\minted@checkstyle} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\minted@checkstyle} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\minted@checkstyle} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\minted@checkstyle} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\minted@pygmentiḶe} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\minted@pygmentiḶe} {\immediate\write18} 1174
{\ShellEscape} {}{} \xpatchcmd{\minted@pygmentiḶe} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\minted@pygmentiḶe} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd{\minted@pygmentiḶe} {\immediate\write18} {\ShellEscape} {}{} \makeatother \begin{document} \begin{minted}{ruby} class Foo def init pi = Math::PI @var = "Pi is approx. #{pi}" end end \end{minted} \end{document}
1175
Note: I can’t check the patches on Windows, so they might not be complete in that case. Shorter code is available if one uses regexpatch: Skip code block \documentclass{article} \usepackage{shellesc,regexpatch} \usepackage{minted} \makeatletter \xpatchcmd*{\DeleteFile} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd*{\ProvideDirectory} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd*{\TestAppExists} {\immediate\write18} {\ShellEscape} {}{} \xpatchcmd*{\minted@checkstyle} {\immediate\write18} 1176
{\ShellEscape} {}{} \xpatchcmd*{\minted@pygmentiḶe} {\immediate\write18} {\ShellEscape} {}{} \makeatother \begin{document} \begin{minted}{ruby} class Foo def init pi = Math::PI @var = "Pi is approx. #{pi}" end end \end{minted} \end{document} Tags: bugs (Prev Q)
Input Questions Q: How to use luatex callbacks to generate a verbatim copy of the input ile Tags: input (Prev Q) I’m trying to devise a LuaTeX solution for the question Extracting the contents of text in a speciied environment into a new ile, but it is turning more 1177
diicult than expected. To begin, I need to solve a problem which seemed simple enough, but I’m unable to solve properly. I want to use some of the LuaTeX callbacks or hooks to dump into a ile a copy of each line of the main document ile. My irst approach was to hook into process_input_buffer, with this code: -- luafuncions.lua f = io.open(tex.jobname .. "-copy.tex", "w") letpass = function(line) f:write(line.."\n") return nil end callback.register("process_input_buffer",letpass) When I use the following tex document: Skip code block \directlua{dofile("luafunctions.lua")} % Example.tex \documentclass{article} \usepackage{fontspec} \usepackage{lipsum} \begin{document} 1. \lipsum[1] 2. \lipsum[2] 3. \lipsum[3] \end{document} And compile it through lualatex, I get: 1. The expected Example.pdf ile in which all looks correct 2. The ile Example-copy.tex which I expected to contain a copy of Example.tex (except perhaps for the irst line) However, I get a 1.4Mb ile (gasp!) which starts and ends with: Skip code block 1178
% Example.tex \documentclass{article} \usepackage{fontspec} %% %% This is file `article.cls', %% generated with the docstrip utility. %... 3375ḷ lines omitted \begin{document} %... 4874 lines omitted 1. \lipsum[1] 2. \lipsum[2] 3. \lipsum[3] \end{document} \relax So, sort of worked :-) But I guess that what is happening is that all the lines read from .cls, .sty, .def, .aux etc... are being processed by the calback too, and thus they are being dumped. I want to avoid that. So I hoped that I could hook some other callback to the event of an external ile being open (and closed), and set a boolean to let my function know that it should not write those parts. However I cannot igure which callback can be useful to do this. Callbacks open_read_file and close look promising, but apparently I have to provide a reader if I use those callbacks. I would hoped that if my hooks returned nil, the default readers will be used, but it is not that way. Is there a simple solution for this problem? Tags: input (Prev Q) User: jldiaz Answer by scott-h. 1179
You can do this without a callback but maybe you need one for some reason. If not, then the following works (as far as I can tell): --luafunctions.lua myout = io.open(tex.jobname.."-copy.tex", "w") myin = io.open(tex.jobname..".tex", "r") for line in myin:lines() do myout:write(line.."\n") end myout:close() myin:close() With your main .tex being. Skip code block \directlua{dofile("luafunctions.lua")} \documentclass{article} \usepackage{fontspec} \usepackage{lipsum} % Example.tex \begin{document} 1. \lipsum[1] 2. \lipsum[2] 3. \lipsum[3] \end{document} Also, there is some code here that might help with your original goal. Tags: input (Prev Q)
1180
Indexing Questions Q: Footnote numbers in index (e.g., 23n3) Tags: indexing (Prev Q) I’m currently weighing indexing options for a book-length project. One of the more surprising hurdles is that there doesn’t seem to be a way to create an index (in my case, several indices) that disambiguates references in the text from those that appear in the footnotes. For example, there will be several hundred references to Roman and canon law, but usually these will be in the footnotes, where there will be, on average, several footnotes per page. Thus a generic reference to page 100 in the citation index is not nearly as helpful as a reference to ’100n34’ (which is standard practice for publishers who still bother to include things like an ’index locorum’). For sorting reasons, it seems like xindy will be the best option, but a solution that can deal with footnote references will trump that since it will be easier to manually sort the .idx ile than to manually identify every citation in a footnote versus one in the text. (Note also that the footnotes invariably contain other arbitrary elements, such as text and citations to modern studies, so a ’special’ footnote command will probably not work.) Finally, in case this complicates things any further, this project is tied to the memoir class (page layout) and lualatex (fonts). Tags: indexing (Prev Q) User: jon Answer by ienissei Here is my attempt at doing it. I haven’t tested extensively, but it seems to work (with two books, two inline citations, and two footnote citations with dummy footnotes in-between). The idea, following what Paul Stanley said in his comments, is to use 1181
BibLaTeX to index things properly. In order to do so, we need to redeine \DeclareIndexFieldFormat (which is used for indexing titles, but it has several variants for names, etc.), and to create a macro that will format the page number by appending the footnote number to it. I am also renewing two macros because biblatex does some formatting before indexing titles, and we need to preserve it while incorporating the added |note command. Skip code block \documentclass{memoir} \usepackage[backend=biber,indexing=cite]{biblatex} \makeatletter \DeclareIndexFieldFormat{indextitle}{% \iffootnote% {\usebibmacro{index:title}{\index}{#1}{|note{\thefootnote}}}% {\usebibmacro{index:title}{\index}{#1}{}}% } \renewbibmacro*{index:title}[3]{% \usebibmacro{index:field}{#1}{\thefield{indexsorttitle}}{\emph{#2}}{#3}} \renewbibmacro*{index:field}[4]{% \begingroup \protected@edef\theindexentry{% \unexpanded{#1}{#2\actualoperator\unexpanded{#3#4}}}% \theindexentry \endgroup} \newcommand{\note}[2]{#2n#1} \makeatother \begin{filecontents}{\jobname.bib} @book{author:2ḷḷḷ, 1182
author = {Author, A.}, year = {2ḷḷḷ}, title = {My first title},
} @book{buthor:2ḷḷ2, author = {Buthor, B.}, year = {2ḷḷ2}, title = {My second title}, } \end{filecontents} \makeindex \begin{document} Some inline citation \cite{author:2ḷḷḷ}. Some footnote\footnote{A, b and c}. Some \clearpage
Some footnote\footnote{A, b and c}. Some footnote citation \footcite{author:2ḷḷḷ}. \printindex \end{document} Edit: Looking at your irst question, I think perhaps you could create an entry using the following code: Skip code block @book{digest, title = {Digestum}, indextitle = {Digestum!\emph{Dig.}}, indexsorttitle = {ḷ2}, } @book{institutes, title = {Institutiones}, indextitle = {Institutiones!\emph{Inst.}}, 1183
}
indexsorttitle = {ḷ1},
Don’t forget to replace the \emph{#2} by #2 in \renewbibmacro{index:title} at l. 14, otherwise it won’t work. Now, if you want two indexes with one of them being sorted arbitrarily and the other alphabetically, you need to specify things accordingly, by saying where to index which data (see the memoir documentation). If you further want the ”Institutiones” and ”Digestum” to look like letter headings, I suggest you look for a way to solve your irst question with xindy (or wait until someone ind it). Sorry I can’t help there. Answer by jon So far it seems as though the easiest solution is to create two commands, one for in-text citations (which are rare in my case), and one for the citation occurs in a footnote. Here is a simpliied example using makeindex (which will end up sorting things incorrectly in a fuller example, but that’s a diferent problem...). Note that I exaggerated the \digtext and \insttext commands for clarity (including how they are indexed); I suppose you could do the same with ’starred’ commands, but I prefer expressing the point of the command in its name where possible. Skip code block \documentclass[12pt]{memoir} \usepackage{makeidx} \makeindex \newcommand{\nn}[2]{#2n#1} \newcommand{\inst}[1]{Inst.\,#1\index{Inst. #1@I. #1|nn{\thefootnote}}} \newcommand{\insttext}[1]{Inst.\,#1\index{Inst. #1@I. #1}} \newcommand{\digtext}[1]{Dig.\,#1\index{Dig. #1@D. #1}} \newcommand{\dig}[1]{Dig.\,#1\index{Dig. #1@D. #1|nn{\thefootnote}}} \begin{document} 1184
Some text.% \footnote{A footnote with no citations.} % % % \digtext{21.1.3} \digtext{1.1.5} \digtext{4.3.15.5}.% \footnote{% \inst{2.4.2} \inst{4.1.1} \inst{3.17.1} } \newpage \insttext{1.2 pr} \insttext{2.4.2} \insttext{3.17.1}.% \footnote{% \dig{3.1.9} \dig{5ḷ.17.188} \dig{12.2.2.2} \dig{1.1.5} } \printindex \end{document} A more automatic, not to mention elegant, solution would be better, but changing a several dozen in-text citations might be the easiest solution. Tags: indexing (Prev Q)
1185
Color Skip to questions, Wiki by user arun-debray color is about using color in (La)TeX documents. There are two main packages for doing this: color (package documentation) and xcolor (package documentation). The xcolor package extends the color package, providing many more ways of specifying and using colors. Loading one of these packages by default gives you only a few color options (white, black, red, green, blue, cyan, magenta, and yellow), but by passing one of the options usenames, dvipsnames, svgnames, or x11names to xcolor, you can get access to a wider variety of named colors. Additionally, you can deine your own colors using \definecolor, e.g. \definecolor{orange}{RGB}{225, 127, ḷ}. To color a portion of text, use {\color{red} text} or \textcolor{red} text; you can also give text a colored background using \colorbox or \fcolorbox. Frequently Asked Questions 1. How can I remove the colored boxes around links created by hyperref?
Questions Q: Convert color name to pdliteral code Tags: color (Prev Q) How can I convert a color name (such as used with the xcolor package) to a pdliteral code, like q 1 ḷ ḷ rg (for red)? Tags: color (Prev Q) User: aphink
1186
Answer by herbert Skip code block \pdfcompresslevel=ḷ % to make everything visible in the pdf \documentclass{article} \usepackage{xcolor} \def\usecolor#1{\csname\string\color@#1\endcsname\space} \begin{document} foo \pdfliteral{\usecolor{red}} bar \end{document} in pdf it is: 1 ḷ ḷ rg 1 ḷ ḷ RG Tags: color (Prev Q)
Listings Skip to questions, Wiki by user seamus The listings package extends LaTeX’s verbatim features. A variety of syntax highlighting options are available. For general questions about verbatim or highlighting use the respective tag. For the unrelated concept of list structures, use lists or the tag corresponding to a speciic list structure (e.g. itemize, enumerate or description) instead.
1187
Questions Q: error with LuaLaTeX, lstinputlisting and an extension-less ile Tags: listings (Prev Q) I’m having troubles with LuaLaTeX and the listings package: the former doesn’t seem to accept me performing \lstinputlisting on a ilename that doesn’t have an extension. Minimal example: Makefile: hello: hello.c cc -o hello hello.c test.tex: \documentclass[a4paper]{article} \usepackage{listings} \begin{document} \lstinputlisting{Makefile} \end{document} pdfLaTeX is successful, LuaLaTeX displays the following error: ! Package Listings Error: File `Makefile(.tex)' not found. Type X to quit or to proceed, or enter new name. (Default extension: tex) Enter file name: I’m using the freshest versions from TeXLive 2012 (pdfTeX 3.1415926-2.41.40.13, LuaTeX beta-0.70.2-2012052410). What’s the trouble? Tags: listings (Prev Q) User: ravualhemio
1188
Answer by ulrike-ischer The problem has been mentioned on the luatex mailing list: http://tug.org/ mailman/htdig/luatex/2013-February/004042.html The problem is that LaTeX is using \openin and \ifeof to test for the existence of a ile and this test fails for iles without extensions (despite the fact that the (primitive) \input itself would work). The problem is not conined to luatex: In miktex your example fails with pdlatex too. With luatex there is a work around: \openin accepts arguments with braces and this seems to protect the ile name. So you can use \lstinputlisting{{Makefile}}. Tags: listings (Prev Q)
Installing Questions Q: Installing Lua Modules for use in LuaLaTeX - the sequel Tags: installing (Next Q) There is a question with the same title, Installing Lua Modules for use in LuaLaTeX, that apparently went unresolved. I’m having similar issues and at this point am out of ideas. I’m running Debian Testing and have installed lua’s xmlrpc library through the package manager. The iles are installed in /usr/share/lua/5.1/xmlrpc /usr/share/lua/5.1/xmlrpc/http.lua /usr/share/lua/5.1/xmlrpc/init.lua /usr/share/lua/5.1/xmlrpc/server.lua 1189
and are found alright by the system’s lua installation. I have determined that the package.path parameter difers between the system’s lua installation and luatex. System:
mpalmer@holḶkopf:~$ lua Lua 5.1.4 Copyright (C) 1994-2ḷḷ8 Lua.org, PUC-Rio > print(package.path) ./?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/lo > In luatex, /usr/share/lua and subdirectories are missing from the path. When I set the LUA_PATH environmental variable to the system’s path, /usr/share/lua and subdirectories show up in luatex’s package.path also, but the xmlrpc module still isn’t found. I have also tried to make /usr/local/share/lua (which didn’t actually exist) a symlink to /usr/share/lua, again without success. On the other hand, luatex does not give me an error, so presumably succeeds, with require "socket.http" That module lives in /usr/share/lua/5.1/socket/http.lua and is found even when /usr/share/lua is neither symlinked nor in package.path. So it almost seems as if package.path is completely ignored by luatex. Does anyone know what I’m missing here? Tags: installing (Next Q) User: michael-palmer Answer by topskip See this answer where LuaTeX searches for iles loaded by require. require ("socket.http") works, because LuaTeX has this built in (mentioned in the reference manual in section 3.3 ”Lua Modules”). Tags: installing (Next Q)
1190
Q: Updating to Beta Builds of ConTeXt / LuaTeX from tlcontrib breaks MacTeX Tags: installing (Prev Q) [What follows is my question, re-written with better information and condensed.] I might be missing something really simple and I might be overcomplicating something really easy. To Be Extremely Brief Prior to updating a fresh MacTeX install (with up-to-date packages installed from one of the main repositories), ConTeXt worked will, even in MK IV, except that I couldn’t get font selection to work. It seamed to ignore it or show garbage (Palatino). So I updated with the tlcontrib packages using tlmgr and now, even after doing what I can to rebuild hashes/-generate (mtxtools) etc, luatools always returns MTXrun | unknown script 'base.lua' or 'mtx-base.lua'. Question 1: What’s wrong? Question 1 MK II: :) Is there something called mtx-base.lua or base.lua, or is this some script not getting a variable name and just putting base in there, because that’s the constant... or something? Anyway, I cannot ind either ile, so I’m in the same boat as luatools.lua. :) To Be Kind of Brief 1. I installed MacTeX 2010 fresh, after a failed attempt at using updated ConTeXt iles. (resolved from an In an earlier question) 2. I updated all packages using the normal trees. 3. I changed my TEXMFHOME variable in /usr/local/texlive/2010/texmf.cnf to ~/src/texmf-trms, which is where I keep my custom modules/templates/packages. (This is normally within our github source control, but hasn’t been yet.) and moved the content from the old directory to the new. 1191
4. I was beating my head against the wall, trying to make font selection work using typescriptfile/typescript as well as simplefont. The closest I could get was with simplefont and Palatino spewing garbage text into the PDF. While it’s not the main topic of this post, if it’s helpful, typing sudo mtxrun --script fonts --list --name --pattern=*' always resulted inzsh: no matches found: --pattern=*‘. 5. I decided to try http://tlcontrib with tlmgr using: sudo tlmgr --repository http://tlcontrib.metatex.org/2010 update -all 6. I sudo texconfig rehashed (seemed okay), sudo mtxrun --generate (seemed okay). Then I sudo luatools --generate and got something that ended with MTXrun | unknown script 'base.lua' or 'mtx-base.lua' 7. Just typing luatools results in: 'base.lua' or 'mtx-base.lua'
MTXrun | unknown script
8. As per my attempt to solve this and some reading on the Interweb, I tried editing the two texmfcnf.lua iles that I found (in /usr/texlive/2ḷ1ḷ/ and /usr/texlive/2010/texmf/web2c‘) with: return { content = { TEXMFCACHE = ’~/Library/texlive/2010/texmfvar’, TEXMFHOME = ’~/src/texmf-trms’, }, TEXMFCACHE = ’~/Library/texlive/2010/texmf-var’, } This had no efect and, quite probably, has nothing to do with anything, as someone has helpfully pointed out. Outputs From Some Commands That I Tried Compile a document with luatools: MTXrun | warning: no format found, forcing remake (commandline driven) MTXrun | running command: luatools --generate MTXrun | unknown script 'base.lua' or 'mtx-base.lua' MTXrun | running command: luatools --make --compile cont-en 1192
MTXrun | unknown script 'base.lua' or 'mtx-base.lua' MTXrun | error, no format found with name: cont-en, aborting MTXrun | total runtime: ḷ.321 Output from sudo luatex --generate --verbose: Skip code block MTXrun | resolvers: variable 'SELFAUTOLOC' set to '/usr/local/texlive/2ḷ1ḷ/bin/x86_64-darwin' MTXrun | resolvers: variable 'SELFAUTODIR' set to '/usr/local/texlive/2ḷ1ḷ/bin' MTXrun | resolvers: variable 'SELFAUTOPARENT' set to '/usr/local/texlive/2ḷ1ḷ' MTXrun | resolvers: variable 'TEXMFCNF' set to '' MTXrun | resolvers: variable 'TEXMF' set to '' MTXrun | resolvers: variable 'TEXOS' set to 'bin' MTXrun | resolvers MTXrun | resolvers: loading configuration file '/usr/local/texlive/2ḷ1ḷ/texmfcnf.lua' MTXrun | resolvers MTXrun | resolvers: loading configuration file '/usr/local/texlive/2ḷ1ḷ/texmf/web2c/texmfcnf.lua' MTXrun | resolvers MTXrun | resolvers: locating list of '/Users/andrew/src/texmf-trms' (runtime) MTXrun | resolvers: handler 'tree:////Users/andrew/src/texmf-trms' -> 'locators' -> 'path=/Users/andrew/src/texmf-trms | noscheme=false | query= | scheme=tree | original=tree:////Users/andrew/src/texmf-trms | fragment= | authority=' MTXrun | resolvers: hash 'tree:////Users/andrew/src/texmf-trms' appended MTXrun | resolvers: skipping list of '/usr/local/texlive/2ḷ1ḷ/texmf-project' (cached) MTXrun | resolvers: skipping list of '/usr/local/texlive/2ḷ1ḷ/texmf-fonts' (cached) MTXrun | resolvers: skipping list of '/usr/local/texlive/2ḷ1ḷ/texmf-local' (cached) MTXrun | resolvers: skipping list of '/usr/local/texlive/2ḷ1ḷ/texmf-context' (cached) MTXrun | resolvers: locating list of '/usr/local/texlive/2ḷ1ḷ/texmf' (cached) 1193
MTXrun | resolvers: tex locator '/usr/local/texlive/2ḷ1ḷ/texmf' found MTXrun | resolvers: hash '/usr/local/texlive/2ḷ1ḷ/texmf' appended MTXrun | resolvers: locating list of '/usr/local/texlive/2ḷ1ḷ/texmf-dist' (cached) MTXrun | resolvers: tex locator '/usr/local/texlive/2ḷ1ḷ/texmf-dist' found MTXrun | resolvers: hash '/usr/local/texlive/2ḷ1ḷ/texmf-dist' appended MTXrun | resolvers MTXrun | resolvers: handler 'tree:////Users/andrew/src/texmf-trms' -> 'hashers' -> 'path=/Users/andrew/src/texmf-trms | noscheme=false | query= | scheme=tree | original=tree:////Users/andrew/src/texmf-trms | fragment= | authority=' MTXrun | resolvers: scanning path '/Users/andrew/src/texmf-trms' MTXrun | resolvers: 596 files found on 114 directories with 62 uppercase remappings MTXrun | resolvers: loading 'files' for '/usr/local/texlive/2ḷ1ḷ/texmf' from '/Users/andrew/Library/texlive/2ḷ1ḷ/texmf-var/luatex-cache/context/21ḷa81d6dcb1ḷ59 MTXrun | resolvers: loading 'files' for '/usr/local/texlive/2ḷ1ḷ/texmf-dist' from '/Users/andrew/Library/texlive/2ḷ1ḷ/texmf-var/luatex-cache/context/21ḷa81d6dcb1ḷ59 MTXrun | resolvers: using suffix based filetype 'lua' MTXrun | resolvers: using suffix based filetype 'lua' MTXrun | resolvers: remembering file 'mtx-base.lua' MTXrun | resolvers: using suffix based filetype 'lua' MTXrun | unknown script 'base.lua' or 'mtx-base.lua' Tags: installing (Prev Q) User: andrew-starks Answer by andrew-starks Mica is almost correct, but I couldn’t convey the edits in a comment, so if it is more appropriate, he can edit his and I’ll remove my answer... The current MacTeX needs the following line in the /usr/local/texlive/2ḷ1ḷ/texmfcnf.lua ile: return { TEXMFCACHE = '$HOME/Library/texlive/2ḷ1ḷ/texmf-var' } 1194
Sweet! But, this does not work for the beta builds on tlcontrib! Mica’s solution should work, except that there is an issue with how the betas deal with the ~ that is beyond my brain capacity. So, instead, one needs to edit the ile to say: return {content={ TEXMFCACHE = '$HOME/Library/texlive/2ḷ1ḷ/texmf-var', TEXMFHOME = '$HOME/src/texmf-trms'}, TEXMFCACHE='$HOME/Library/texlive/2ḷ1ḷ/texmf-var' } ...instead. Notice the absent coma after the last TEXMFCACHE and notice the use of $HOME instead of ~.
To speed things up, I made two iles. One called /usr/local/texlive/2ḷ1ḷ/texmfcnf-tlcontrib. has the new code and another called /usr/local/texlive/2ḷ1ḷ/texmfcnf-mactex.lua which has the standard MacTeX installation code. Then, in my zsh proile (I think bash is the same) I added the following utility commands: Skip code block
alias tlc="sudo tlmgr --repository http://tlcontrib.metatex.org/2ḷ1ḷ" function tlcontext { sudo cp -f -v /usr/local/texlive/2ḷ1ḷ/texmfcnf-tlcontrib.lua /usr/local/texlive/ sudo tlmgr --repository http://tlcontrib.metatex.org/2ḷ1ḷ update context luatex }
function tlmactex { sudo cp -f -v /usr/local/texlive/2ḷ1ḷ/texmfcnf-mactex.lua /usr/local/texlive/2ḷ1 sudo tlmgr install context luatex metapost --reinstall; } function tlun { sudo tlmgr $1 --reinstall; } tlcontext seems to do everything that I need to move to the newest ConTeXt build. tlmactex appears to bring me back. I’ll let all ya’all know if I’m wrong, but it appears that this works perfectly. Tags: installing (Prev Q) 1195
Editors Questions Q: Which is the best editor for LuaTeX? Tags: editors (Prev Q) Many (La)TeX editors support the LuaTeX engine. However, which one ofers the best support for writing LuaTeX? Which editor or plugin supports features such as syntax highlighting and auto-completion for both Lua and (La)TeX? Common useful features of LaTeX focused IDEs such as integrated viewer, forward and inverse search, structure browser and spell checking are still important, though supplemented by some Lua syntax support. Tags: editors (Prev Q) User: stefan-kottwitz Answer by aditya Vim supports embedding syntax highlighting of one language in another. I use that to support both MP and Lua syntax highlighting in ConTeXt regions. The basic trick is do deine a syntax region as follows: unlet b:current_syntax syn include @LUA syntax/lua.vim syn region luatex matchgroup=contextIdentifier \ start='\\startluacode' \ end='\\stopluacode' \ contains=@LUA
1196
Then everything inside \startluacode ... \stopluacode will have Lua syntax highlighting. Here is a screenshot showing code from one of my modules (not that the lua comments and the function os.remove inside the \startluacode environment are syntax highlighted)
For completeness, here is a screenshot showing highlighted Metapost code inside a tex ile
1197
The same idea will also work in LaTeX, as follows: Skip code block unlet b:current_syntax syn include @LUA syntax/lua.vim syn region luatexSnip matchgroup=Snip \ start='\\begin{\Ḷ(luacode\|luacode*\)}' \ end='\\end{\Ḷ1}' \ contains=@LUA syn region luatexSnip matchgroup=Snip \ start='\\\(directlua\|luadirect\){' \ end='}' 1198
\ contains=@LUA highlight link Snip SpecialComment Vim also supports auto-completion, but I don’t use that feature so I don’t know if language dependent auto-completion is possible or not. Other requirements, like forward/backward search, spell checking, structure browser, are straight forward, but even then, vim is not what you will call an IDE. Answer by keks-dose Emacs as well ofers syntax highlighting for Lua and LaTeX. I do not know whether there is something like ”embedded syntax highlighting” for luachunks inside a *.tex-ile. Usually you do that by opening the ile into an indirect bufer: in the base bufer you get LaTeX-highlighting, in the indirect bufer you change the major mode to lua-mode. But: this doesn’t work with lua-mode yet, at least for me. Independently from changing the mode to lua-mode, Emacs keeps highlighting LaTeXkeywords in the indirect bufer. Emacs with AucTEX is great for LaTeX, the lua-mode is by far less convenient. Alexander Answer by yan-zhou Aditya’s answer does not work for me anyway. I use LaTeX and it may be the reason. Anyway, inspired by your answer I got it works for LuaLaTeX by putting the following in the ’tex.vim’ ft plugin ile. Skip code block autocmd BufWinEnter * if exists("b:current_syntax") && b:current_syntax == "tex" autocmd BufWinEnter * unlet b:current_syntax autocmd BufWinEnter * syntax include @TEX syntax/tex.vim 1199
autocmd autocmd autocmd autocmd autocmd autocmd autocmd
BufWinEnter BufWinEnter BufWinEnter BufWinEnter BufWinEnter BufWinEnter BufWinEnter
* * * * * * *
unlet b:current_syntax syntax include @LUA syntax/lua.vim syntax region luatex matchgroup=Snip start="%--beginlua--" e syntax region luatex matchgroup=Snip start="--beginlua--" en highlight link Snip SpecialComment let b:current_syntax="luatex" endif
It should worked by simply put these codes without autocmd BufWinEnter in to the after/syntax/tex.vim ile. But in my case that causes some problems and got vim halted. So I use the au to get them executed at the very end of ile loading process. After doing these, everything marked by --beginlua-- and --endlua-- are highlighted as lua code. One can use the version with % in \directlua or luaexec where TeX line comment is allowed but not lua line comment. And the version without % in the \begin{luacode}, etc. Tags: editors (Prev Q)
Biblatex Skip to questions, Wiki by user seamus biblatex provides advanced bibliographic typesetting features for LaTeX. It can be used as a replacement for packages like natbib. It is used either within a normal latex bibtex latex compile cycle, or with biber replacing bibtex. Related tags If your question concerns bibliography formatting generally you might want to use the bibliographies tag in addition to this tag. If your question is about 1200
a speciic .bst style, or natbib you should use the bibtex and/or natbib tags instead. Should I use biblatex or natbib? Humanities style citations biblatex is almost required if you need any of the following: • humanities style citations (author-title type schemes; citations using ibid etc.) • a much wider array of BibTeX database ields (again, especially suited for the humanities) • Unicode encoded .bib iles (usable with the biber replacement for bibtex) • ine control over your own bibliography styles using regular latex methods Author-year and numeric citations biblatex provides the same functionality as natbib for author-year and numeric citations common in the natural and social sciences. It can therefore be used as a replacement for natbib. You might want to use natbib if: • there is a .bst ile already created for the speciic journal you submitting a paper to; • a journal accepts latex submissions and requires or expects natbib. Such journal may not accept biblatex for the bibliography. However, many new journal styles are being created for biblatex, so this may become less of a problem. Given the lexibility of adapting biblatex styles, in many cases it may be quite easy to modify an existing style to accommodate a particular journal’s style. Available biblatex styles In addition to the standard styles that are documented in the biblatex manual, CTAN currently lists the following extra style packages for biblatex: 1201
• biblatex-apa APA Style for biblatex. • biblatex-chem Chemistry styles for biblatex. • biblatex-chicago Chicago style iles for biblatex. • biblatex-dw Humanities styles for biblatex. • biblatex-fiwi Humanities styles, especially ilm studies. • biblatex-historian A Biblatex style based on Turabian. • biblatex-ieee IEEE style iles for biblatex. • biblatex-jura Biblatex styleiles for German legal literature. • biblatex-juradiss Biblatex styleiles for German law theses. • biblatex-luh-ipw Biblatex styles for social sciences. • biblatex-mla MLA style iles for biblatex. • biblatex-musuos A biblatex style for citations in musuos.cls, designed for the department of music, Osnabrück. • biblatex-nature Biblatex support for the journal Nature. • biblatex-nejm Biblatex style for the New England Journal of Medicine (NEJM). • biblatex-philosophy Styles for using biblatex for work in philosophy. • biblatex-science Biblatex support for the journal Science. • historische-Ḷeitschrift Biblatex style for the journal Historische Zeitschrift. • uni-wtal-ger Biblatex style for literary studies at the University of Wuppertal.
1202
Questions Q: Engines of Tex-Editors and Biber/Biblatex Tags: biblatex (Prev Q) Today I detected that biblatex, biber or whatever is responsible for citations and bibliography does not work correctly on my tex-iles. I can think of two reasons for it: Maybe my engine-ile (I am calling it engine-ile because it is in the enginefolder of my TexShop-folder) is not well written or does not work with the latest update (if there was such an update...). This is my engine-ile: #!/bin/tcsh set path= ($path /usr/texbin /usr/local/bin /opt/local/bin/) lualatex -file-line-error -synctex=1 "$1" biber "${1:r}" lualatex -file-line-error -synctex=1 "$1" Or the following error is responsible:
ERROR - Error loading data source package 'Biber::Input::file::bibtex': data sourc Compilation failed in require at (eval 71) line 2. It looks like this error might cause the trouble. However, I do not know what could have caused the error... I did not delete any ile (e.g., the bibtex.dcf, which the error message claims not to have found). I have two additional questions: Are there diferences between diferent editors when it comes to how the engine-ile should look like? Is the engine-ile I am using ok as it is? (I do not understand a single word of that ile) Tags: biblatex (Prev Q) User: clinteastwood Answer by alan-munn
1203
Too long for a comment, and more or less an answer: • Are you sure this is the actual engine you are using? It should begin with #! not just !. Also, make sure your distribution is up-to-date. The error you’re getting looks more like a biber problem. See egreg’s answer for the solution to this. • Unless you have MacPorts installed, you don’t need /opt/local/bin in your path. (and even then, you probably don’t need it). • This engine won’t actually do what you intend it to do (i.e. resolve the references correctly.) You would need an additional lualatex line to do that. I would suggest as an alternative to use the lualatexmk engine which comes with TeXShop. If it’s not active, go to ~/Libary/TeXShop/Engines and move it from the Inactive folder to the Engines folder. You will need to quit out of TeXShop to have the change take efect. Then in your document you can just add: % !TEX TS-program = lualatexmk and this engine will be chosen automatically. You can insert this line by using the Program item from the Macros menu. Answer by egreg Unfortunately, it happens that Biber gets confused and that message means that the binaries it produces are not in good shape. The only method I know to solve the issue is to open the Terminal and issue
rm -fr /var/folders/ḶE/ḶEWMdMuCGnyHENetv8k-CU+++TI/-Tmp-/par-User/cache-5a7f3ḷ69e2 where the string is what goes from /var/folder/ up to // in the error message. This will force Biber to rebuild the binaries. This is mentioned in the documentation for Biber, page 30. On diferent systems than Mac OS X, the string might be diferent. Note: it happened just now, when testing for answering. :-O
1204
Tags: biblatex (Prev Q)
E TeX Skip to questions, Wiki by user n.n. An extended version of TeX, which is capable of running as if it were TeX unmodiied. -TeX has been speciied by the LaTeX team as the engine for the development of LaTeX, in the immediate future; as a result, LaTeX programmers may (in all current TeX distributions) assume -TeX functionality. More information is available in the -TeX manual (texdoc etex).
Questions Q: \lastnodetype not working as expected in luaTeX Tags: e-tex (Prev Q) I’m currently experimenting with the linebreak_filter of luatex and when using it to change/replace the linebreaking algorithm the \lastnodetype command stopped working. A MWE is the following: Skip code block \def\partest{% \directlua{% function hpackparagraph (head) return node.hpack(head) end callback.register("linebreak_filter", hpackparagraph) }% 1205
}
\par
\setboxḷ\vbox{ABC\par {\tracingonline1\showboxbreadth\maxdimen\showboxdepth\maxdimen\showlists}% \showthe\lastnodetype } \setboxḷ\vbox{ABC\partest {\tracingonline1\showboxbreadth\maxdimen\showboxdepth\maxdimen\showlists}% \showthe\lastnodetype } In a nutshell the \partest command changes the paragraph breaking algorithm to simply pack the unbroken paragraph into an hbox and return that hbox unchanged to the vertical list (not useful standalone, but this is the shortest version that shows my problem). So if you run this you get: Skip code block This is LuaTeX, Version beta-ḷ.7ḷ.1-2ḷ11ḷ61421 (rev 4277) restricted \write18 enabled. (./lua-bug.tex ### internal vertical mode entered at line 13 \hbox(6.83331+ḷ.ḷ)x469.75499, glue set 427.9494fil, direction TLT .\whatsit ..\localinterlinepenalty=ḷ ..\localbrokenpenalty=ḷ ..\localleftbox=null ..\localrightbox=null .\hbox(ḷ.ḷ+ḷ.ḷ)x2ḷ.ḷ, direction TLT .\tenrm A .\tenrm B .\tenrm C .\penalty 1ḷḷḷḷ .\glue(\parfillskip) ḷ.ḷ plus 1.ḷfil .\glue(\rightskip) ḷ.ḷ 1206
prevdepth ḷ.ḷ, prevgraf 1 line ### vertical mode entered at line ḷ prevdepth ignored ! OK. l.14 ...h\maxdimen\showboxdepth\maxdimen\showlists }% ? > 1. l.15 \showthe\lastnodetype ? ### internal vertical mode entered at line 18 \hbox(6.83331+ḷ.ḷ)x41.8ḷ56, direction TLT .\whatsit ..\localinterlinepenalty=ḷ ..\localbrokenpenalty=ḷ ..\localleftbox=null ..\localrightbox=null .\hbox(ḷ.ḷ+ḷ.ḷ)x2ḷ.ḷ, direction TLT .\tenrm A .\tenrm B .\tenrm C .\penalty 1ḷḷḷḷ .\glue(\parfillskip) ḷ.ḷ plus 1.ḷfil prevdepth ignored ### vertical mode entered at line ḷ prevdepth ignored ! OK. l.19 ...h\maxdimen\showboxdepth\maxdimen\showlists ? > -1. l.2ḷ
}%
\showthe\lastnodetype
As you can see the \lastnodetype for the irst test is 1(hbox) as expected. 1207
But for the second it is -1 which means current list has no nodes. This of course is not correct as it does have an hbox inside the one returned by my primitive linebreak_filter. The only diference between the two lists that one can observe is that in the irst one the hbox is 469pt wide while in the second one it is at its natural width, but this is expected as it was packed this way. My guess is that the node list that is placed by the standard paragraph builder is updating the data structure for \lastnodetype but that doesn’t happen is such a ilter is applied which feels like a bug. Or am I missing something fundamental here? Update Consistent with the problem the command \lastbox also returns a void box in the case where the linebreak_filter is applied, i.e., \setboxḷ\lastbox \showboxḷ fails to return the last object in the current list. Tags: e-tex (Prev Q) User: frank-mittelbach Answer by frank-mittelbach I’m now fairly certain this this is a bug in the current implementation of linebreak_filter. What seems to happen is the following: when TeX builds a list (in this case a vertical list) it keeps track of it through a pointer to the head and to the tail of that list. Now when a paragraph is broken into lines those lines get appended to the current vertical list by the linebreaking algorithm and the tail pointer is updated to point to the new end of this list. However, if the linebreak_filter replaces TeX’s algorithm the material from that ilter is appended to the list but the tail pointer is not changed. Thus in my example it still points to the node before the paragraph (which happens to be nil as the paragraph starts the vbox). Fortunately this tail pointer is accessible and modiiable from Lua code, so there is a way to ix this. We can’t do this in linebreak_filter, however, because the current luatex code that calls the ilter expects the tail in 1208
precisely this wrong as it does some inal checkup and changes. But what we can do is to use the followup ile post_linebreak_filter to do the work for us, because by then all these things have happened. So the workaround looks like this: Skip code block function hpack_paragraph h = node.hpack(head) return h end
(head)
function fix_nest_tail (head) tex.nest[tex.nest.ptr].tail = node.tail(head) return true end callback.register("linebreak_filter", hpack_paragraph) callback.register("post_linebreak_filter",fix_nest_tail) The second ilter simply updates TeX’s tail pointer in the current semantic nest to become the tail of the result produced from the line breaking. A bit nasty, but at least it allows to use the linebreak_filter in the current implementation. If you wonder what this this code does: without anything further it changes the output so that every paragraph is returned as a single line (and indentations like from itemiḶe or similar environments are dropped) and inserts like footnotes or \vadjusts stay within those hboxes. So it needs a little more to become useful, but let your imagination run. Update Hans Hagen pointed out to me that a proper linebreak_filter would normally need to set a few more variables, namely things like prevdepth and prevgraf and possibly add glue nodes representing a baselineskip. In contrast to the issue with the tail pointer these could be set in the ilter directly, so a more complete solution would look then like this:
1209
Skip code block
function oneliner(head) local h = node.hpack(head) local d = tex.baselineskip.width - tex.nest[tex.nest.ptr].prevdepth - h.height tex.nest[tex.nest.ptr].prevdepth = h.depth tex.nest[tex.nest.ptr].prevgraf = 1 local n if d < tex.lineskiplimit then n = 1 d = tex.lineskip else n = 2 end local s = node.new("glue_spec") local n = node.new("glue",n) s.width = d n.spec = s return node.insert_before(h,h,n) end callback.register("linebreak_filter",oneliner) -- fix the bug with the tail pointer not being updated: function fix_nest_tail (head) tex.nest[tex.nest.ptr].tail = node.tail(head) return true end callback.register("post_linebreak_filter",fix_nest_tail) For the use case that I had in mind this extra coding is not necessary, as I want to store away those boxes anyway for later use, but in case one wants to write a real line breaking algorithm this kind of additional work deinitely needed, so it makes sense to remark on this here. Tags: e-tex (Prev Q) 1210
External Files Questions Q: Parsing iles through LuaTeX Tags: external-iles (Prev Q) This question has two parts: 1. How would one generally parse a ile with LuaTeX, assuming the ile only holds data that is delimited either by spaces, commas or semicolons. 2. How would you parse the ile (if it includes (all)TeX code as well as text code), for example an ini ile where some of the ields are written in TeX. This question aims at inding a solution that is also well documented in the post. As LuaTeX is still in heavy development, I ind the documentation to be sparse and this is the irst of a number of questions that I intend to post (with bounties) so that the answers can provide some form of documentation on the web (and on our favourite Site!). Edit: The irst part is a simple CSV ile. If you want you can use the example in my answer in Adding a list of bios to the book class. As the answer included alpha sorting using TeX, it might be a good example, where LuaTeX should have an advantage over normal (all)TeX. Ini iles are normally used as coniguration iles, although I have used them for all sort of data capturing. If you wish you can also use a Yaml format. Skip code block [general] 1211
languages=en,ngerman ;This is a comment [article] pagewidth=15cm pageheight=2ḷcm paper=a4 [book] includeparts=true ;defines chapter [chapter] ;packages [graphicx] keys="keya,keyb,keyc" For TeX code, add one command to the ini ile. texcode="\def\test#1#2{}" Tags: external-iles (Prev Q) User: yiannis-lazarides Answer by taco-hoekwater Following the two comments for the actual cases I wrote above, I think the general approach goes like this: • If the ile format you want to parse is more or less standardized, there usually is already some lua code out there in the wild that can read it and produce a lua table from the ile’s contents. Otherwise, usually the best solution is to use LPEG to do the same (see links in Aditya’s reply). • Once that is done, you have to igure out how to feed the ile name to the existing (or new lua) code that does the actual parsing, and what the structure is of the returns values. 1212
• Chances are high that the result of parsing is a Lua table, and you just have to tex.sprint() the bits you want. For example, here is how the \directlua input for the inilaḶy module could look: \directlua { require ("inilaḶy") local tt = assert (inilaḶy.get"try.ini") for k,v in pairs(tt['graphicx']['keys']) do tex.print(k) end } Answer by aditya One possibility is to use LPEG. ConTeXt uses LPEG (with some enhancements) to • • • • •
parse XML (this is just a wrapper ile that loads a bunch of other iles), parse bibtex, parse chemical formulas, parse asciimath and calculator math, parse TeX and Metapost for pretty printing (also see other buff-imp-* iles). • parse CSV • parse ini iles (third party module). These iles in themselves are not documented. To understand the usage, you will need to read the corresponding *.mkiv ile where the lua functions are called. Tags: external-iles (Prev Q)
1213
Catcodes Skip to questions, Wiki by user gonzalo-medina catcodes is about ”category codes” — an integer number from 0–15 associated to each of the 256 character codes. The category codes indicate the role of a character. The following is a list of the sixteen category codes and the Plain TeX settings: • 0 = Escape character; this signals the start of a control sequence. IniTeX makes the backslash \ (code 92) an escape character. • 1 = Beginning of group; such a character causes TeX to enter a new level of grouping. The plain format makes the open brace { a beginning-of-group character. • 2 = End of group; TeX closes the current level of grouping. Plain TeX has the closing brace }as end-of-group character. • 3 = Math shift; this is the opening and closing delimiter for math formulas. Plain TeX uses the dollar sign $ for this. • 4 = Alignment tab; the column (row) separator in tables made with \halign (\valign). In Plain TeX this is the ampersand &. • 5 = End of line; a character that TeX considers to signal the end of an input line. IniTeX assigns this code to the return, that is, code 13. Not coincidentally, 13 is also the value that IniTeX assigns to the \endlinechar parameter. • 6 = Parameter character; this indicates parameters for macros. In plain TeX this is the hash sign #. • 7 = Superscript; this precedes superscript expressions in math mode. It is also used to denote character codes that cannot be entered in an input ile; see below. In Plain TeX this is the circumlex ^. • 8 = Subscript; this precedes subscript expressions in math mode. In plain TeX the underscore _ is used for this. 1214
• 9 = Ignored; characters of this category are removed from the input, and have therefore no inluence on further TeX processing. In Plain TeX this is the null character, that is, code 0. • 10 = Space; space characters receive special treatment. IniTeX assigns this category to the ASCII space character, code 32. • 11 = Letter; in IniTeX only the characters a..Ḷ, A..Z are in this category. Often, macro packages make some ‘secret’ character (for instance @) into a letter. • 12 = Other; IniTeX puts everything that is not in the other categories into this category. Thus it includes, for instance, digits and punctuation. • 13 = Active; active characters function as a TeX command, without being preceded by an escape character. In Plain TeX this is only the tie character ~, which is deined to produce an unbreakable space. • 14 = Comment character; from a comment character onwards, TeX considers the rest of an input line to be comment and ignores it. In IniTeX the percent sign % is made a comment character. • 15 = Invalid character; this category is for characters that should not appear in the input. IniTeX assigns the ASCII delete character, code 127, to this category. The user can change the mapping of character codes to category codes with the \catcode command.
Questions Q: \scantokens in LuaTeX Tags: catcodes (Next Q) The eTeX \scantokens command appears to work diferently in LuaTeX than it does in eTeX, pdfTeX and XeTeX. Compiling the following test
1215
ile with any engine other than LuaTeX performs \show+, which shows the character +, but LuaTeX skips this statement entirely. \newlinechar=1ḷ \catcode1ḷ=12 \endlinechar=13 \catcode13=5 \scantokens{^^J\show+} \bye This behaviour reminds me of how TeX does not look in a line after tokens of category code 5 (end-of-line), so at irst I thought that the default category codes might be diferent in LuaTeX. This is why I added some redundant catcode assignments. Obviously, that didn’t suice. Tags: catcodes (Next Q) User: bruno-le-loch Answer by joseph-wright This is a known bug in the LuaTeX implementation of \scantokens: http: //tracker.luatex.org/view.php?id=733 (taking pdfTeX as a ’reference’ behaviour and therefore correct by deinition). Tags: catcodes (Next Q)
Q: Automatically ixing catcode output Tags: catcodes (Prev Q) Using the following macro to redeine catcodes for lua blocks to make programming lua inside tex iles more natural has a fault: Skip code block \def\lua{% \bgroup \catcode`\\=12 1216
}
\catcode`\{=12 \catcode`\}=12 \catcode`\^^M=12 \catcode`\#=12 \catcode`\~=12 \catcode`\%=12 \catcode`\_=12 \catcode`\@=12 \doluacode
\bgroup \catcode`\|=ḷ \catcode`\^^M=12 % \catcode`\\=12 % |long|gdef|doluacode#1^^M#2\endlua{|directlua{#2}|egroup}% |egroup Because it redeines the codes it also redeines the codes from tex.print output. The following code will fail \lua
tex.print("\\mymacro") \endlua because \ is interpreted with a catcode of 12. Is there any way to get tex.print to revert back to using the original tex catcodes so printing tex stuf will work WITHOUT having to redeine each character by hand(which obviously doesn’t work when you are generating tex code programmatically in lua). That is, I would like to simply run the above code with LITTLE modiication and have it work correctly and not have to do stuf like tex.print(0, ”\”) tex.print(”mymacro”) which ,AGAIN, does not work for programmatically generated tex. The only way to do this that I have of is to create a new print function that scans the string and converts the cat codes but hopefully there is a better way? 1217
Tags: catcodes (Prev Q) User: abstractdissonance Answer by aditya ConTeXt provides \startluacode and \stopluacode macros that provide the same functionality as your \lua ... \endlua macros. The main diference between the macros is that the ConTeXt macros switch to normal catcodes before calling \direclua. The code below is copied from luat-ini.mkiv Skip code block %D A few more goodies:
\unexpanded\def\startlua {\luat_start_lua } \let\stoplua \relax % tex ca \unexpanded\def\startluacode{\luat_start_lua_code} \let\stopluacode\relax % lua ca % It might makes sense to have a \type {\directelua} so that we can avoid % the \type {\normalexpanded} around \type {\directlua}. Something to discuss % in the team. \def\luat_start_lua {\begingroup \obeylualines \luat_start_lua_indeed} \def\luat_start_lua_indeed#1\stoplua {\normalexpanded{\endgroup\noexpand\directlua\Ḷerocount{#1}}} \def\luat_start_lua_code {\begingroup \obeylualines \obeyluatokens \luat_start_lua_code_indeed} \def\luat_start_lua_code_indeed#1\stopluacode {\normalexpanded{\endgroup\noexpand\directlua\Ḷerocount{#1}}} 1218
where \obeylualines is equal to \relax (a left over from previous deinition?) and \obeyluatokens is deined as Skip code block \appendtoks \let\\\lualetterbackslash \let\|\lualetterbar \let\(\lualetterlparent \let\{\lualetterlbrace \let\'\lualettersquote \let\n\lualettern \let\f\lualetterf \let\a\lualettera \let\v\lualetterv \let\1\lualetterone \let\3\lualetterthree \let\5\lualetterfive \let\7\lualetterseven \let\9\lualetternine \to \everyluacode
\let\-\lualetterdash \let\)\lualetterrparent \let\}\lualetterrbrace \let\"\lualetterdquote \let\r\lualetterr \let\t\lualettert \let\b\lualetterb \let\s\lualetters \let\2\lualettertwo \let\4\lualetterfour \let\6\lualettersix \let\8\lualettereight \let\ḷ\lualetterḶero
\def\obeyluatokens {\setcatcodetable\luacatcodes \the\everyluacode} Tags: catcodes (Prev Q)
1219
Cjk Questions Q: Convert numbered pinyin to pinyin with tone marks Tags: cjk (Prev Q) Is there any package which can convert numbered pinyin (e.g. dian4 nao3) to UTF-8 pinyin with tone marks (e.g. diàn nǎo)? I found this (https://stackoverflow.com/a/8200388/2421048) Python script, so it should be possible with LuaLaTeX using directlua. Tags: cjk (Prev Q) User: susis-strolch Answer by dumm-dumm I have translated the Python script mentioned in the question to Lua. Compile it with LuaLaTex and it should work: Skip code block \documentclass{article} \usepackage{fontspec} \usepackage{luacode} \begin{luacode*} PinyinToneMark = { {'ā', 'ḹ', 'ǎ', 'à'}, {'ē', 'é', 'ě', 'è'}, {'ī', 'í', 'ǐ', 'ì'}, {'ō', 'ó', 'ǒ', 'ò'}, {'ū', 'ú', 'ǔ', 'ù'}, {'ǖ', 'ǘ', 'ǚ', 'ǜ'} }
1220
function convertPinyin(str) if str~= nil and string.len(str)>ḷ then local s = string.lower(str) local r = '' local t = '' for i = 1, string.len(s) do local c = s:sub(i,i) if c >= 'a' and c = 'ḷ' and c 1 then local positions = vowelpositions (nucleus) 1225
local pos --- 1) locate correct vowel for j = 1, 3 do pos = positions[precedence[j]] if pos then break end end if not pos then -- iu or ui, thus second gets tone pos = 2 end local vowel = nucleus[pos] --- 2) place tone mark if tone == 1 then nucleus[pos] = vowel elseif tone == 2 then nucleus[pos] = vowel elseif tone == 3 then nucleus[pos] = vowel elseif tone == 4 then nucleus[pos] = vowel end
.. cmacron .. cacute .. ccaron .. cgrave
tonified = tableconcat (nucleus) else --- no vowel, could be mismatch tonified = "" end result[#result+1] = elm.onset result[#result+1] = tonified result[#result+1] = elm.coda end elseif t == "string" then result[#result+1] = elm end 1226
end return tableconcat (result) end ------------------------------------------------------------------------- export ----------------------------------------------------------------------pinyintones.convert = function (str) local converted = todiacritic (str) if converted then texsprint (converted) end end Result:
For convenience, I created a gist of the code. Tags: cjk (Prev Q)
Terminal Output Skip to questions, 1227
Wiki by user texnician Questions tagged with terminal-output are about LaTeX and its (or its compiler’s) interactions with the command line (e.g. printing something in the command-line or executing command etc.). Especially \typeout and related commands are in the focus of this tag. If you just use terminal output to describe your error (e.g. just printing the error message) please use appropriate tags for your error.
Questions Q: Accessing to .log messages from LuaTeX. Is it possible? Tags: terminal-output (Next Q) Reading the question How to visualize the underfull box in inal output PDF iles I thought that it could be possible to use LuaTeX to intercept the ”Underfull vbox” message and draw some kind of overlayed mark (using tikz or whatever) at that point. Probably not very useful, but fun to try as a proof of concept. Before dealing with the appropriate point at which introduce the mark, or the pattern expression required to capture the relevant info, I tried irst a simpler goal, but I was unsuccessful. My goal was, from lualatex, write a document which produces a copy of the .log ile into another .lbk ile (or any other extension, that’s not relevant). I tried the following approaches: 1. I wrote a lua function copylog() which simply opens the .log, read all its contents, and write those back in other ile: function copylog() local f = io.open(tex.jobname .. ".log", "r") local fo = io.open(tex.jobname .. ".lbk", "w") s = f:read("*all") f:close() fo:write(s) 1228
fo:close() end 2. In the document I wrote \AtBeginDocument{\directlua{copylog()}} (I wanted to read the log from the previous compilation). This was partially successful. The resulting ile contained part of the log, but not complete, it stopped a few lines before than the \begin{document} was processed. I realized that I was not reading the log from previous compilation, but instead the log of the current compilation. As soon as lualatex was run, a new log ile was opened, a lot of contents from the preamble was written and then my lua code read all that stuf (but not what will come later). 3. So I changed the point at which my function was executed and wrote: \AtEndDocument{\directlua{copylog()}}, trying to process the log from the current compilation, when it was done. This failed again. This time I got a few lines more from the log ile, but not the complete log ile. Somehow I expected that, because at the point where my lua code reads the log it is still not complete (extra info and statistics are dumped even after the end of the document), but at least I expected it to contain part of the warning messages generated by my document. No luck, the copy ended again before \begin{document} was run. I realized that this was due to the bufered output. Luatex already wrote the information I wanted in the ile, but this info was still in some ile bufers, not actually written in the disk, so not accessible to my lua function. 4. Since \end{document} was still to early to hook my function, I tried also using the end_run callback, but got the same results. At end_run the log ile is still open, so I cannot get its full contents (because of the bufered output again). From these experiments I concluded two questions: 1. Is it possible to read the .log from the previous compilation before lualatex opens it (and cleans it) again? I guess the 1229
answer is no. Apparently the .log ile is the irst output which is open, even before the document is loaded. 2. It is possible to force, from lua or from tex, a flush() of the log ile from lua, to be able to read all the messages generated up to \end{document}? If the two question above have negative answer, then new questions arrive: 3. There is some callback I could use to get the log messages or terminal output as they are written? I tried the obvious ones: process_output_buffer and show_error_hook. The irst one didn’t get any result. The second one was only activated by error messages, not by warnings. 4. Any other idea? I only want to capture the warning messages. Should not be that diicult... Any expert in luatex internals can help me? Tags: terminal-output (Next Q) User: jldiaz Answer by jldiaz From the comments received so far, and my own conclusions after reading the LuaTeX manual, I’m now convinced that the log ile cannot be read reliably from lua code being run in the same document whose log ile I’m trying to read. Opening that ile from lua and reading with file.read() is not reliable because the same ile is open and being written in by TeX, and since ile output is bufered, even if I read the ile at the end of the run, I don’t get its full contents. The other approach, to use some callback to get the log messages while they are written in the log ile, is unfeasible because LuaTeX does not provide any callback to process log messages. The closest thing is show_error_hook but this callback is only called at the error messages and not at the informative messages nor warning messages. In short, the answer to the question posed in the title is NO. 1230
Fortunately I was able to solve my original problem in a diferent, and IMHO better, way. Tags: terminal-output (Next Q)
Q: ^^M garbles my terminal output Tags: terminal-output (Prev Q) Contrarily to pdfTeX and XeTeX, which send ^^M to the terminal for the character 13, LuaTeX sends the character 13 itself. This garbles the output of my terminal (bash under Ubuntu 10.04). \edef\foo{\string\^^M} \message{\meaning\foo ab} gives abcro:->\ i.e., the same as macro:->\ ab but smashed into a single line. How can I tell LuaTeX to output ^^M instead? Tags: terminal-output (Prev Q) User: bruno-le-loch Answer by david-carlisle As @egreg says, it looks like a bug to me. For writing to iles you can modify a lua callback but unfortunately the callback (as documented) is not called when writing to the terminal. Skip code block
1231
\edef\foo{\string\^^M} {\catcode`\^=12 \directlua{ callback.register( "process_output_buffer", function (s) snew, n = string.gsub(s,"\string\r","^^M") return snew end) }} \message{\meaning\foo ab} \newwrite\x \immediate\openout\x=nnl.out \immediate\write\x{\meaning\foo ab} \stop On the terminal you get ab )o:->\ but in the ile you get: $ cat nnl.out macro:->\^^Mab Answer by heiko-oberdiek From LuaTeX Reference, beta 0.70.1, section 2.3 UNICODE text support: Output to the terminal uses ^^ notation for the lower control range (c < 32), with the exception of ^^I, ^^J and ^^M. These are considered ’safe’ and therefore print-as-is. And in the manual are the terminal/log explicitely excluded for process_output_buffer: 1232
4.1.3.2 process_output_buffer (0.43) […] It is only called for output to an actual ile (that is, excluding the log, the terminal, and \write18 calls). Tags: terminal-output (Prev Q)
Letterspacing Skip to questions, Wiki by user nils-l Deinition Letterspacing is the adjustment of the space between letters of a font. Usage It is often confused with kerning, which is also concerned with space between letters. But whereas kerning refers to the adjustment of space between pairs of speciic letters (such as T and o, which usually require a decrease in the space between them), letterspacing is a uniform adjustment. The same amount of adjustment is applied to all letters (all glyphs, to be precise, as igures and punctuation signs are afected as well). In *TeX, a common tool for letterspacing is the microtype package. Applications Text set in large type sizes, such as an 18pt heading in a book with 12pt body text, is often given negative, or “tighter” letterspacing: all the letters are brought closer together by a certain amount. Conversely, it is considered good practice to increase letterspacing for text in all capitals. Drastic letterspacing can also be found as a means of adding emphasis to words or short passages of text, in cases where the typeface used does not provide any other means (such as italics). Thus letterspacing used to be common for emphasis in texts produced on typewriters, and it still considered the only appropriate choice when using blackletter typefaces. When using roman type, however, using letterspacing in place of italics for emphasis is a practice frowned upon by typographers.
1233
Letterspacing and Tracking An alternative term for “letterspacing” is “tracking”. Occasionally, a distinction between the two is made, in which “tracking” is used for a minute adjustment applied to the entire font (in a certain size), whereas “letterspacing” is reserved for referring to the method of emphasis (see above). The microtype package, for example, allows for the adjustment of an entire font’s “tracking”, while in addition providing commands for local “letterspacing” for emphasis purposes.
Questions Q: How to letter space (German) abbreviations automatically Tags: letterspacing (Prev Q) In German abbreviations like ”z. B.” should be written with a space in between. In good old typewriter days the usual way to write them was without space. And even today I often type them without a space. Is there a way to automatically replace them with a correctly spaced version (e.g. with \, in between)? I’m on LuaLaTeX, so a Lua solution would be okay. Example document: \documentclass{article} \usepackage[ngerman]{babel} \begin{document} Dies ist Ḷ.B. ein Test. \end{document} This input should result in an output equivalent to Ḷ.\,B. in the document. Tags: letterspacing (Prev Q) User: texnician Answer by mico 1234
(I rewrote this answer rather signiicantly after discussions with OP and after receiving very signiicant coding help from @EgorSkriptunof) Here’s a solution that doesn’t pre-specify a list of all abbreviations for which thinspace should be inserted after interior periods (aka ”full stops”). Instead, it sets up a pattern matching function to capture u.a., u.a.m., u.v.a.m., Ḷ.Zt., Bem.d.Red. and many more such cases. (See the function insert_thinspaces in the code below for the exact pattern matches that are performed.) Observe also the use of unicode.utf8.gsub instead of string.gsub inside the Lua function insert_thinspaces. This lets the code deal correctly with non-ASCII-encoded letters, such as ä and Ä, which may occur in abbreviations. On the downside (potentially), this solution method doesn’t capture abbreviations if they occur at the start of a sentence, e.g., Z.T. or U.U.; for what it’s worth, your parallel answer currently doesn’t catch such cases either, right? The Lua function is assigned to the process_input_buffer callback via a LaTeX macro called \ExpandAbbrOn. If, for any reason, you need to suspend operation of the Lua function, simply execute the instruction \ExpandAbbrOff. The code checks if the string to be processed lies inside a verbatim-like environment such as verbatim, Verbatim, and lstlisting; if that’s the case, no processing is performed. And, with the latest iteration, the code now also ignores material that’s in the arguments of inline-verbatim-like macros, such as \verb, \Verb, \lstinline, and \url. For sure, the contents of URL strings should never be processed by the Lua function, right?
1235
Skip code block % !TeX program = lualatex \documentclass{article} \usepackage[ngerman]{babel} \usepackage{fancyvrb} % for "Verbatim" env. \usepackage[obeyspaces]{url} % for "\url" macro \usepackage{listings} % for "\lstinline" macro %% Lua-side code: \usepackage{luacode} % for 'luacode*' environment \begin{luacode*} -- Names of verbatim-like environments local verbatim_env = { "[vV]erbatim" , "lstlisting" } -- By default, we're *not* in a verbatim-like env.: local in_verbatim_env = false -- Specify number of parameters for every macro; use neg. numbers -- for macros that support matching pair of curly braces {} 1236
local all_macros = { verb = 1, Verb = 1, lstinline = -1, url = -1 } -- List all poss. delimiters local all_delimiters = [[!"#$%&'*+,-./:;?^_`|~()[]{}ḷ123456789]] -- Quick check if "s" contains an inline-verbatim-like macro: function quick_check ( s ) if s:find("\\[vV]erb") or s:find("\\url") or s:find("\\lstinline") then return true else return false end end -- Function to process the part of string "s" that -- does *not* contain inline-verbatim-like macros local function insert_thinspaces ( s ) s = unicode.utf8.gsub ( s , "(%l%.)(%a%l?%l?%.)(%a%l?%l?%.)(%a%l?%l?%.)", "%1\\,%2\\,%3\\,%4" ) -- e.g. "u.v.a.m.", "w.Ḷ.b.w." s = unicode.utf8.gsub ( s , "(%l%.)(%a%l?%l?%.)(%a%l?%l?%.)", "%1\\,%2\\,%3" ) -- e.g., "a.d.Gr." s = unicode.utf8.gsub ( s , "(%u%l%l?%.)(%a%l?%l?%.)(%a%l?%l?%.)", "%1\\,%2\\,%3" ) -- e.g., "Anm.d.Red." s = unicode.utf8.gsub ( s , "(%l%.)(%a%l?%l?%.)", "%1\\,%2" ) -- e.g., "Ḷ.T.", "Ḷ.Zt.", "v.Chr." return s end -- Finally, the main Lua function: 1237
function expand_abbr ( s ) -- Check if we're entering or exiting a verbatim-like env.; -- if so, reset the 'in_verbatim_env' "flag" and break. for i,p in ipairs ( verbatim_env ) do if s:find( "\\begin{" .. p .. "}" ) then in_verbatim_env = true break elseif s:find( "\\end{" .. p .. "}" ) then in_verbatim_env = false break end end -- Potentially modify "s" only if *not* in a verbatim-like env.: if not in_verbatim_env then -- Quick check if "s" contains one or more inlike-verbatim-like macros: if quick_check ( s ) then -- See https://stackoverflow.com/a/45688711/1ḷ14365 for the source -- of the following code. Many many thanks, @EgorSkriptunoff!! s = s:gsub("\\([%a@]+)", function(macro_name) if all_macros[macro_name] then return "\1\\"..macro_name ..(all_macros[macro_name] < ḷ and "\2" or "\3") :rep(math.abs(all_macros[macro_name]) + 1) end end ) repeat local old_length = #s repeat local old_length = #s s = s:gsub("\2(\2+)(%b{})", "%2%1") until old_length == #s s = s:gsub("[\2\3]([\2\3]+)((["..all_delimiters:gsub("%p", "%%%ḷ").."])(.until old_length == #s s = ("\2"..s.."\1"):gsub("[\2\3]+([^\2\3]-)\1", insert_thinspaces):gsub("[\1 else 1238
-- Since no inline-verbatim-like macro found in "s", invoke -- the Lua function 'insert_thinspaces' directly. s = insert_thinspaces ( s ) end end return(s) end \end{luacode*} %% LaTeX-side code: Macros to assign 'expand_abbr' %% to LuaTeX's 'process_input_buffer' callback. \newcommand\ExpandAbbrOn{\directlua{% luatexbase.add_to_callback("process_input_buffer", expand_abbr, "expand_abbreviations")}} \newcommand\ExpandAbbrOff{\directlua{% luatexbase.remove_from_callback("process_input_buffer", "expand_abbreviations")}} \AtBeginDocument{\ExpandAbbrOn} % enabled by default %% Just for this example: \setlength\parindent{ḷpt} \obeylines \begin{document} Dies ist u.U. ein Test. \begin{Verbatim} Dies ist u.U. ein Test. \end{Verbatim} Ḷ.B. u.a. u.Ä. u.ä. u.U. a.a.O. d.h. i.e. v.a. i.e.S. Ḷ.T. m.E. i.d.F. Ḷ.Z. u.v.m. Ḷ.Zt. u.v.a.m. b.Ḷ.b.w. v.Chr. a.d.Gr. Anm.d.Red. \begin{verbatim} Ḷ.B. u.a. u.Ä. u.ä. u.U. a.a.O. d.h. i.e. v.a. i.e.S. Ḷ.T. m.E. i.d.F. Ḷ.Z. u.v.m. Ḷ.Zt. u.v.a.m. b.Ḷ.b.w. v.Chr. a.d.Gr. Anm.d.Red. 1239
-----U.S.A. U.K. % should *not* be processed \lstinline|u.a. u.Ä. u.ä.|; \Verb$u.a. u.Ä. u.ä.$ % nested verbatim-like macros \Verb+u.U.\lstinline|u.U.|u.U.+
\lstinline+u.U.\[email protected][email protected].+
% 2 URL strings u.U. \url{u.U.aaaa.Ḷ.T.bbb_u.v.a.m.com} u.U. u.U. \url?u.U.aaaa.Ḷ.T.bbb_u.v.a.m.com? u.U. \end{document} Answer by texnician Here’s a simple solution to the problem. It uses the Lua callback process_input_buffer to scan each input line for one of the given abbreviations and insert a small space in there. For that action you only need to specify the abbreviation (table key) you want to replace with a spaced version (table value). That mechanism can, of course, be used to simply replace any content (table key) with some other (table value). This solution also enables you to use verbatim input, but you have to make the verbatim environment known to the script. If the script wouldn’t check for verbatim environments those changes would be visible to the reader. You should note that the function works, but may not be the fastest as it always checks every line whether it is a verbatim start/end for every verbatim environment known to the script. Update: I have simpliied user input (dicitonary) by generating the required spaces automatically. The most problematic part mentioned in the discussions are abbreviations at sentence start and in inline verbatim. The irst one may be handled with this version (check for a dot, a space and then the abbreviation with capitalized letter) but the second one may be very hard to detect and change. 1240
Skip code block \documentclass{article} \usepackage[ngerman]{babel} \usepackage{luacode} \begin{luacode} local tabbr = {"Ḷ.B.","u.a.","u.Ä.","u.ä.","u.U.","a.a.O.","d.h.","i.e.", "i.e.S.","v.a.","Ḷ.T.","m.E.","i.d.F.","Ḷ.Z.","u.v.m.","u.v.a.m.", "Ḷ.Hd."} local verbenv = {"[vV]erbatim","lstlisting"} local tsub = {} local inverb = false function createsubstitutes() for i,p in ipairs(tabbr) do tsub[p] = unicode.utf8.gsub(p:sub(1,p:len()-1), "%.", ".\\,") .. "." end end function expandabbr(s) for i,p in ipairs(verbenv) do if s:find("\\begin{" .. p .. "}") then inverb = true break end if s:find("\\end{" .. p .. "}") then inverb = false break end end if not inverb then for k,v in pairs(tsub) do s = unicode.utf8.gsub(s, k:gsub("(%W)","%%%1"), v) end end return(s) end \end{luacode} 1241
\AtBeginDocument{% \luaexec{createsubstitutes()} \luaexec{luatexbase.add_to_callback("process_input_buffer", expandabbr, "expand_ } \begin{document} Dies ist Ḷ.B. ein Test.\\ In dieser Zeile gibt es Ḷ.B. \verb+Ḷ.B.+ \begin{verbatim} Test Ḷ.B. \endverbatim} \end{document} Answer by skillmon Just a minor tweak to @Mico’s answer. I put the replacement in a loop to match abbreviations of unknown length. The drawback is, that each chunk of a abbreviation must meet one of the deined patterns. For example o.B.d.A. would get evaluated by the second gsub pattern "(%l.)(%a)" and replaced by o.\,B.d.\,A.. In the next loop the pattern wouldn’t match, because the chunk B.d. doesn’t. I guess the combination of the two patterns should match almost every abbreviation but doesn’t create too many false-positives. Another tweak I made was to check only the closing verbatim-name which matches the irst opening. With this a construct of several nested verbatim environments is evaluated correctly. Inline verbatim is still missing though as well as other exceptions like \url. EDIT: I also wrote a function, that parses inline verbatim correctly, but only if there is only one kind of inline verbatim command per line and if it ends in the same line. Skip code block \documentclass{article} \usepackage[ngerman]{babel} \usepackage{fancyvrb} % for "Verbatim" environment \usepackage{luacode} \usepackage{url} 1242
%% Lua-side code: \begin{luacode} local verbatim_env = { "verbatim" , "Verbatim" , "lstlisting" } local verbatim_inl = { "verb" , "lstinline" } -- by default, *not* in a verbatim-like env.: local cur_verbatim_env = nil local cur_verbatim_inl = nil function replace_abbrs ( s ) local rep_rep1 = 1 local rep_rep2 = 1 while rep_rep1 ~= ḷ or rep_rep2 ~= ḷ do s,rep_rep1 = unicode.utf8.gsub ( s , "(%l%.)(%a%.)(%a)", "%1\\,%2\\,%3" ) s,rep_rep2 = unicode.utf8.gsub ( s , "(%l%.)(%a)", "%1\\,%2" ) end return(s) end function expand_inline_verb ( s , p ) local r = "" while string.len(s) > ḷ do local spos,epos = s:find( p.."%A" ) if spos ~= nil then r = r .. replace_abbrs(s:sub(ḷ,spos-1)) r = r .. s:sub(spos,epos) local delim = s:sub(epos,epos) s = s:sub(epos+1 , string.len(s)) local verb_end = s:find( delim ) r = r .. s:sub(ḷ,verb_end) s = s:sub(verb_end+1 , string.len(s)) else r = r .. replace_abbrs(s) break end end return(r) end function expandabbr ( s ) if cur_verbatim_env == nil then 1243
for i,p in ipairs ( verbatim_env ) do if s:find( "\\begin{" .. p .. "}" ) then cur_verbatim_env = verbatim_env[i] break end end elseif s:find( "\\end{" .. cur_verbatim_env .. "}" ) then cur_verbatim_env = nil end if cur_verbatim_env == nil and cur_verbatim_inl == nil then for i,p in ipairs ( verbatim_inl ) do pos = s:find( "\\" .. p ) if pos ~= nil then cur_verbatim_inl = s[pos+string.len(p)+1] break end end elseif cur_veratim_inl ~= nil then if s:find( cur_veratim_inl ) then cur_verbatim_inl = nil end end if cur_verbatim_env == nil then for i,p in ipairs ( verbatim_inl ) do if s:find( p ) then return(expand_inline_verb( s , p )) end end s = replace_abbrs ( s ) end return(s)
end \end{luacode}
%% LaTeX-side code: \newcommand\ExpandAbbrOn{\directlua{% luatexbase.add_to_callback("process_input_buffer", expandabbr, "expand_abbreviations")}} 1244
\newcommand\ExpandAbbrOff{\directlua{% luatexbase.remove_from_callback("process_input_buffer", "expand_abbreviations")}} \AtBeginDocument{\ExpandAbbrOn} % enabled by default %% Just for this example: \setlength\parindent{ḷpt} \obeylines \begin{document} Dies ist u.U. ein Test. \begin{Verbatim} Dies ist u.U. ein Test. \end{Verbatim} \begin{Verbatim} Dies ist u.U. ein schwierigerer Test. \end{Verbatim} Ḷ.B. u.a. u.Ä. u.ä. u.U. a.a.O. d.h. i.e. i.e.S. v.a. Ḷ.T. m.E. i.d.F. Ḷ.Z. u.v.m. Ḷ.Zt. o.B.d.A. a.d.Gr. n.Chr. Anm.d.Red. \verb|Ḷ.Zt. o.B.d.A. a.d.Gr. n.Chr. Anm.d.Red.| \begin{verbatim} Ḷ.B. u.a. u.Ä. u.ä. u.U. a.a.O. d.h. i.e. i.e.S. v.a. Ḷ.T. m.E. i.d.F. Ḷ.Z. u.v.m. \endverbatim} U.S.A. U.K. \ExpandAbbrOff % turn off abbreviation expansion A tricky URL: \url{u.U.aaaa.Ḷ.T.bbb} \end{document} Tags: letterspacing (Prev Q)
1245
Callback Questions Q: LuaTeX hpack_ilter callback not triggering on certain hlist creations Tags: callback (Next Q) EDIT: The hpack_ilter is triggered and my question pointless. Consult my answer on why I missed the callback invocation. I am using LuaTeX to analyze the creation process of math expressions in a document. To this efect, I use the mlist_to_hlist callback to insert a whatsit node into the node list. When the math expressions are assembled into their inal form by packing various node lists into horizontal and vertical lists, I hook into this process with hpack_filter and vpack_filter callbacks. This allows me to follow the creation path from the raw math expression all the way to the inal page. I encounter an issue with a speciic part of this process. It seems that the rows of an align-math-environment, are added to the main vertical list as horizontal lists with a speciic subtype. These hlist nodes have subtype 4, which is described as ’alignment column or row’ in the LuaTeX documentation. My problem now is that the creation of exactly these hlists is not iltered with the hpack_filter callback. For all other hlist types I get the expected invocation of hpack_filter but not for these. For my purposes, it already suices to check the input arguments of this process for the occurrence of certain whatsit node and then completely cancel the packing. The goal is to not have this content transferred to the main vertical list. This leads to my questions: • Why is hpack_filter not called for the creation of an hlist with subtype 4? • Is it possible to enable such a behavior or to somehow obtain an equivalent callback mechanism by other means?
1246
Tags: callback (Next Q) User: thomas-auzinger Answer by thomas-auzinger While inspecting the node list that were given as arguments to the hpack_filter callbacks, I did not notice that the input argument contained unset nodes. My take on how an alignment (that is generated by the TeX command \halign) is treated by LuaTeX is as follows: 1. Through a series of hpack invocation with argument groupcode == align_set, the input node lists are packed into the head ield of unset nodes. 2. These unset nodes (with glue nodes and perhaps other stuf) are then packed into an hlist node with subtype 4. The node lists that resided in the head ields of the unset nodes are still present but now in head ields of hlist nodes with subtype 5. This packing happens in an hpack invocation with argument groupcode == fin_row. This exactly the part that I missed and that I was asking for. This is what I igured out by looking at intermediate node lists and is my own opinion. This information cannot be found in LuaTeX manual so far (version 0.76) and unset nodes are hardly mentioned at all. That they have a head ield I deduced from looking at the LuaTeX source code. Tags: callback (Next Q)
Q: How to use LuaTeX ‘append_to_vlist_ilter‘ callback Tags: callback (Prev Q) I am considering a solution to the automatic grid typesetting problem though LuaTeX callbacks. The most relevant one seems to be append_to_vlist_filter. (vpack can also work, I support, but a less elegant solution) 1247
However, it seems that it does work properly. The documents is quite vague on its return value.
function( box, locationcode, , mirrored return list, prevdepth end It is ok to return nothing in which case you also need to lush the box or deal with it yourself. The prevdepth is also optional. Locations are box, alignment, equation, equation_number and post_linebreak Below is a minimal example, Skip code block \documentclass{article} \directlua{ function apvlist(head) return head end luatexbase.add_to_callback("append_to_vlist_filter", apvlist, "apvlist") } \begin{document} Test \end{document} I assumed that the return value list means the head of a node list. In the simple example, the original box is returned as the head of a single node list. Yet, when compiled there’s no page output. What does the document mean by lush the box or deal with it yourself ? Tags: callback (Prev Q) User: yan-zhou Answer by david-carlisle
1248
I’d found the same example as Ulrike in luatexja, and so I think the identity function is something like Skip code block \documentclass{article} \directlua{ function apvlist(head,c,p,b) print('adding ' .. type(head) .. ' in context ' .. c) node.write(head) return nil end luatexbase.add_to_callback("append_to_vlist_filter", apvlist, "apvlist") } \begin{document} Test \end{document} which typesets Test and echoes adding adding adding adding adding adding
userdata userdata userdata userdata userdata userdata
in in in in in in
context context context context context context
post_linebreak box box box box box
But the details are still a bit vague. Tags: callback (Prev Q)
Texdoc Skip to questions, 1249
Wiki by user n.n. texdoc is a tool that helps you ind and view documentation in texlive. Its primary function is to locate relevant documentation for a given keyword (typically, a LaTeX package name) on your hard disk, and open it in an appropriate viewer. For instance, say that you want to view the documentation for the package biblatex, then you issue the following in a terminal texdoc biblatex If you use auctex you can access texdoc via C-c ? (or M-x TeX-doc).
Questions Q: Why does texdoc call luatex Tags: texdoc Why is it that calling texdoc runs, amongst others, luatex? What is it needed for? Tags: texdoc User: nvaughan Answer by mico I’ll irst address the ”how” and ”what” components of your question, and defer the ”why” component to the end of this answer. Both TeXLive and MikTeX include the texdoc utility. (I don’t know if any other TeX distributions do as well.) The following is applicable for a MacTeXbased system; I would assume that other TeXLive systems are set up very similarly. I’m afraid I can’t provide much detailed information as to how, precisely, texdoc is implemented in a MikTeX-based system. On MacTeX2014, the executable texdoc is located in the directory /usr/local/texlive/2ḷ14/bin/x86_64-darwin 1250
Running ls -l texdoc in that directory reveals that the ile texdoc is a so-called symbolic link: lrwxr-xr-x [...] texdoc -> ../../texmf-dist/scripts/texdoc/texdoc.tlu Switching to /usr/local/texlive/2ḷ14/texmf-dist/scripts/texdoc and typing ls -l texdoc.tlu produces -rwxr-xr-x [...] texdoc.tlu i.e., it’s an ordinary ile whose status is ”world-executable” (and ”worldreadable”). Typing cat texdoc.tlu produces: #!/usr/bin/env texlua -- texdoc.tlu: small wrapper around main.tlu -- (makes it easier to install a new version of texdoc in TEXMFHOME) kpse.set_program_name(arg[-1], 'texdoc') require('texdoc.main') The irst line shows that texlua -- not luatex -- is launched via /usr/bin/env. Even though texlua is nothing but a symbolic link to luatex (both are located in /usr/local/texlive/2ḷ14/bin/x86_64-darwin), they are not identical. The man page says: ”If [luatex is] called as texlua it acts as Lua interpreter”. Section 3.1.1 of the LuaTeX reference guide notes that ”LuaTeX behave[s] like a standalone Lua interpreter [...] if the executable is named texlua”. Thus, texlua can only be run as a Lua interpreter. Aside: One of the many very useful properties of Lua is that it is multiplatform, meaning that one and the same set of Lua scripts will (generally...) produce the same results regardless of the platform it’s run on. While one cannot assume that lua (the executable) is available on any given system, it’s of course permissible for the texdoc to assume that texlua is available on any system that features texdoc. Once texlua is launched, two lua functions are called: kpse.set_program_name, which is provided in luatex’s kpse library (do check out section 4.6.1 of the LuaTeX reference manual for information on what the 1251
kpse.set_program_name function does), and require, which is a built-in lua function. The ile main.tlu, which is loaded by the require function, contains another Lua script -- in MacTeX2014, this script consists of 79 lines of code -- that does most of the ”real work”. If texdoc is invoked with no argument at all or as texdoc -h, a help screen is generated. If texdoc is invoked with one or more ”real” arguments, further Lua scripts are launched to invoke whatever programs are appropriate (usually, but not necessarily, a pdf viewer) to display the argument(s). For instance, if I type texdoc hyperref cleveref the user guides of the hyperref and cleveref packages are launched in my pdf ile viewing program. So far, I’ve only examined what texdoc does, but I haven’t ofered a reason as to why texdoc uses texlua -- as opposed to, say, perl, which is another multi-platform scripting utility. I haven’t checked back with the author of the texdoc utility (Manuel Pégourié-Gonnard), but I strongly suspect it’s because, as noted earlier, every TeX distribution that provides the texdoc utility also contains texlua, a full-ledged Lua interpreter. In contrast, expecting perl to be installed on all users’ systems may not be that great of an idea. Tags: texdoc
Header Footer Skip to questions, Wiki by user seamus header-footer is about customizing headers and footers, i.e., choosing a page style for certain pages (e.g. empty, plain, headings) and (for the styles 1252
employed) placing information like the current section title and page number. Popular packages are fancyhdr, scrlayer-scrpage, titleps, and scrpage2. The KOMA-script classes and the memoir class contain their own resources for customizing headers and footers.
Questions Q: How can I achieve dictionary headers for two page spreads in LaTeX Tags: header-footer I would like to produce a document where I can display the irst and last items of each two page spread in the headers of both the left and right pages. I know I can use \markboth{}{} to collect the usual form of marks that feed \leftmark and \rightmark. But that is limited to the text of one page at a time. There doesn’t appear to be a natural way to use the forward reference mechanism to do this, but there must be a trick, right? Tags: header-footer User: rberteig Answer by thorsten-donig The fancyhdr manual (Section 10 — Dictionary style headers, p.11) introduces exactly such a page style. Answer by rberteig An approach that seems to be working for me is to switch to LuaTeX, specifically the LuaLaTeX package, both from the current MiKTeX distribution for Windows. 1253
This has allowed me to write a Lua module that I load with \directlua{require"dictfun"} in my document’s preamble. When the dictfun module loads, it tries to initialize a table of the headers for every page from a ile named after the \jobname, found in the global tex.jobname. I used \makeevenhead and \makeoddhead to hook into the page header and call a Lua function from dictfun to update the index of header info and construct the text that belongs on this page’s header. The text of the header is placed from the Lua side with a call to tex.print(). Finally, after the main body is inished, I make one more call into the Lua module to write out the current content of the index table. This solution requires that the text be processed by lualatex at least twice with the pagination stable, but that isn’t an unreasonable requirement. I’m sure it could be done in pure TeX, but building data structures is something that native Lua does very well. Update: Since I’ve been asked, here are the ”interesting” bits. I have not attempted to package this in any rational way, these fragments have simply been lifted out of my book project with some light editing. First, here are fragments out of book.text, which holds most of the prologue code and which includes all of the book’s content by reference. The Makeile builds the inal PDF ile by compiling this ile.... Skip code block % Start with memoir and tweak. \documentclass[1ḷpt]{memoir} % % % %
... Stuff related to fonts, siḶes, page dimensions and similar cruft left out as not interesting here ...
% Allow for more than two column layouts. My dictionary ended up being only % two column, but other page designs were tried, and there may be a reason % why I kept the multicol package anyway but I've forgotten and didn't % document that detail. \usepackage{multicol} 1254
% Make a new environment for the dictionary body. This makes it easier to % constrain the dictionary page headers to just the definitions pages and % keep them out of the front matter and appendices. \copypagestyle{dict}{plain} % Load our Lua code to handle a database of page marker information. It will % read its state from a file named after the TeX job, with ".headmarks" appended. \directlua{require"dictfun"} % Define even and odd page headers and footers that invoke the Lua module % to both record information about the words on the pages as well as construct % the TeX source string that actually becomes the content of the page header % or footer. For my editorial sanity, the headers include the page numbers, but % located next to the binding not the page's outer edge. \makeevenhead{dict}{% \directlua{dictfun.headmarks(\thepage,"\leftmark","\rightmark")}}{}{\thepage} \makeoddhead{dict}{\thepage}{}{% \directlua{dictfun.headmarks(\thepage,"\leftmark","\rightmark")}} \makeevenfoot{dict}{\footnotesiḶe \directlua{dictfun.footmarks(\thepage)}}{}{} \makeoddfoot{dict}{}{}{\footnotesiḶe \directlua{dictfun.footmarks(\thepage)}} \pagestyle{dict} % More setup cruft was here...
% Hijack some section commands to collect information. In particular, each word % entry begins with a paragraphmark command naming the word. We redefine chapterma % and sectionmark to do nothing just in case. The markboth directive sets up the % information that will be passed to Lua in the page header via leftmark and % rightmark. \renewcommand{\chaptermark}[1]{} \renewcommand{\sectionmark}[1]{} \renewcommand{\paragraphmark}[1]{\markboth{#1}{#1}} % Actually set the page dimensions to match a specific binding at Lulu. %%%% PAGE DIMENSIONS 1255
%% Set up the paper for lulu trade paperback \setstocksiḶe{9in}{6in} \settrimmedsiḶe{\stockheight}{\stockwidth}{*} \settrims{ḷpt}{ḷpt} \setulmarginsandblock{ḷ.75in}{.5in}{*} \setlrmarginsandblock{.65in}{.5in}{*} \setheadfoot{\baselineskip}{2ex} \setheaderspaces{*}{*}{.618} \checkandfixthelayout % Memoir's title page details... changed from my project, obviously \title{Sample Dictionary} \author{Various} %\date{} \begin{document} \frontmatter % We'll emit a title page so the PDF page block has a dust cover. % Front.tex has fairly obvious content, including a call to maketitle to get % that part out of the way, and also including some statistics generated % by the project's build process. \input{front} % % % % % %
Here's the actual dictionary content. Each word's entry is a memoir paragraph that includes the plain text entry name in all caps, as well as the whole definition in multiple TeX paragraphs. Naturally, the content is extracted from other sources as part of the build process which actually writes the file "block.tex" before LuaLaTeX is called on to compile the book.
% Now move to the next recto page and include our actual body text % block in a suitable column count environment. \cleardoublepage \mainmatter \begin{multicols}{2} 1256
\footnotesiḶe \input{block} \normalsiḶe \end{multicols} \backmatter % One final call to our Lua module gives it a chance to update its page % database. This is the same data flow used by the native TeX forward % reference system, and does require multiple passes to get all references % placed so that even page headers can know what will be on the following % odd page. \directlua{dictfun.writemarks()} \end{document} The LaTeX code did all the plumbing, but the Lua code actually stores and retrieves the data needed by each page header and footer. Here is an abridged version of dictfun.lua which is placed in the same folder as book.tex: Skip code block -- module to load from luatex module(...,package.seeall) -- Storage for the database of what words begin and end each page headtab = {} -- Called from the page header with the page number, left word (first on page) -- and right word (last on page). Update the page database, and format a string -- containing the first and last words over each two page spread to return. function headmarks(pg,left,right) if not pg then return end pg = tonumber(pg) -- remember the index terms for this page, but strip off -- anything after a semicolon in each term headtab[pg]={left:gsub(";.*$",""),right:gsub(";.*$","")} local lpage, rpage if pg % 2 == ḷ then -- left page 1257
else
end
lpage = headtab[pg] rpage = headtab[pg+1] or {"",""} -- right page lpage = headtab[pg-1] or {"",""} rpage = headtab[pg]
end tex.print(lpage[1].."---"..rpage[2])
-- Called from the page footer with the page number. I've demonstrated that -- it can tell left from right. Other applications are left as an exercise. function footmarks(pg) if not pg then return end pg = tonumber(pg) local lpage, rpage if pg % 2 == ḷ then -- left page tex.print("left") else tex.print("right") end end -- Called when the module loads to attempt to open and read the table from -- a file related to the project name. function readmarks() local f = assert(loadfile(tex.jobname..".headmarks")) if not f then headtab = {} return end headtab = f() end -- Called to write the page database back out to a file. function writemarks() local f = assert(io.open(tex.jobname..".headmarks","w")) if not f then return end f:write"return {\n" for _,t in ipairs(headtab) do 1258
end
f:write(string.format(" end f:write"}\n"
{%q,%q},\n", t[1], t[2]))
-- Finally, load the page database. readmarks() I hope I haven’t left out anything too critical. I’ve had to chop out a bunch of proprietary details, but I believe I’ve left enough behind to show how I did it. Tags: header-footer
IDE Questions Q: LaTexing vs LaTexTools (Sublime text plugins) Tags: ide I want to use sublime as my default IDE for TeX (currently I’m using Latex Studio). I’ve found two great packages: 1. LaTexTools 2. LaTexing Both has somehow the same list of features but LaTeXing seems to have extra feature and hassle free (is it correct?). It seems support better auto complete features (esp. the citation) and better multiple PDF viewer compatibility and larger snippets (I might be wrong). In another side, LaTexTools seems to have much larger user community and It’s open source and again seems to have lots of primary features that La1259
TeXing has. LaTeXing isn’t free (15$/user) but it has free unlimited trial and seems closed source and premium support. I searched the web for comparison between these two, but I didn’t ind any proper thread. I think it could be beneicial for the users to have a good review and comparison between these two packages (to save time). What is the key diferences/features between the two? p.s. • I’m using Linux vs ST3 ( LaTexTools didn’t support ST3 some month ago and the choice was easier). • I sometimes work with XeTeX and I like to switch to LuaTeX in the future so build systems are essential. • I like to create TeX documents as projects and some times the projects are large so go to anything and auto complete the ile names are quite handy Update (Apr-09-2017) I no longer use Sublime text. Also the state of the latex support in sublime might have changed. So I’ve changed the approved answer. Tags: ide User: sdids Answer by serge-stroobandt The point of LaTeXing not being FLOSS is truly important and betting for small-scale closed-source is always risky. If the software author pulls the plug, forking by others is often not an option. ... And as it happens, look what is now iguring prominently on the LaTeXing home page: 2014-06-27 16:48 by Chris The purchase of a license for LaTeXing is temporary not possible. Due to personal issues the distribution is stopped and will be not
1260
continued for a few month. This is not the end of LaTeXing, the program will still receive updates and bug ixes during that time. Answer by holene I have used both plug-ins and I am currently using LaTeXing. I will continue to do so because I ind that LaTeXing has some really nifty features such as as cmd+l,cmd+l when including graphics or .tex iles.
Both plug-ins do support ST3, both plug-ins support root directives (with some diference in the syntax, the picture above illustrates the LaTeXing root file syntax) and both plug-ins support projects. LaTeXing supports partial build of a project, which I’m not sure if LaTeXtools does. However, doing a complete comparison is a tedious piece of work – the plugins are quite extensive. I’d recommend taking a look at the documentation of LaTeXing and LaTeXtools and inding your own preferences, as these tend to vary from one TeX personality to another. Personally I’m still uncovering new features with LaTeXing, and I believe (just speculations based on a overview comparison of the LaTeXing User Guide and the LaTeXtools documentation) that LaTeXing is a more extensive plug-in which will have a higher probability of satisfying a proper Sublimer’s needs. Tags: ide
1261
Paper Size Questions Q: Lualatex and a5 paper format Tags: paper-size I’m having problems generating a pdf ile with A5 format. With pdflatex this compiles ine, without, it doesn’t. Skip code block \documentclass[a5paper]{article} \usepackage{geometry} \usepackage{lipsum} \title{A Title} \author{An Author} \begin{document} \maketitle \section{Goals} \lipsum[1-3ḷ] \end{document} Any ideas? Tags: paper-size User: data_hope Answer by ulrike-ischer Add \usepackage{luatex85} or \usepackage{graphicx} (assuming that you have the newest luatex).
1262
Tags: paper-size
Numbering Questions Q: Compound representation of numbers. Possible? Tags: numbering I’ve got a Glagolitic font (Epistula Croatica) with letters mapped to numbers and some ligatures programmed. I don’t want to describe the nature of the Glagolitic numeral system here but to present what I’d like to achieve (the font’s licence doesn’t allow me to modify it). I’m trying to ind a solution that will allow me to use custom numerical system in page numbers, the enumerate environment and in text. What I need is just a diferent representation of arabic numerals, as in the examples below: • • • • • • •
1 through 9 — no change 11 — 10 1 19 — 10 9 25 — 20 5 347 — 300 40 7 901 — 900 1 50681 — 50000 600 80 1 etc.
Between the numbers I’d like to have a \textcompwordmark. I’d really appreciate any answers for the following questions: • Is it possible to deine such a numerical system with way of using as roman, arabic, alph, fnsymbol? I use LuaLaTeX so the solution can be a Lua code. • If yes, how to use it in page numbers or the enumerate environment? • Is it possible to have a text-mode command similar to \mynumerals{123}? 1263
Thank you in advance. Tags: numbering User: artur-s. Answer by egreg Here’s an implementation using expl3 Skip code block \documentclass{article} \usepackage[T1]{fontenc} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\glagonumeral}{m}{\glago_numeral:n { \int_eval:n { #1 } } } \seq_new:N \l_glago_digits_seq \int_new:N \l_glago_position_int \cs_new_protected:Npn \glago_numeral:n #1 { \cs_set:Npn \glago_reverse_ten: { } \seq_set_split:Nnx \l_glago_digits_seq { } { #1 } \int_set:Nn \l_glago_position_int {\seq_length:N \l_glago_digits_seq - 1 } \seq_map_inline:Nn \l_glago_digits_seq { \glago_symbol:x { \glago_make_digit:nn { ##1 } { \l_glago_position_int } } \int_decr:N \l_glago_position_int } \glago_reverse_ten: } \cs_generate_variant:Nn \seq_set_split:Nnn {Nnx} \cs_new:Npn \glago_make_digit:nn #1 #2 { #1 \prg_replicate:nn { \l_glago_position_int } { ḷ } } \cs_new:Npn \glago_symbol:n #1 1264
{
\int_compare:nTF { #1 == 1ḷ } { \cs_set:Npx \glago_reverse_ten: { \prop_get:Nn \g_glago_numerals_prop { #1 } } } { \prop_get:Nn \g_glago_numerals_prop { #1 } }
} \cs_generate_variant:Nn \glago_symbol:n {x} \prop_new:N \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop \prop_put:Nnn \g_glago_numerals_prop 1265
{ḷ}{\textcompwordmark} {1}{A} {2}{B} {3}{C} {4}{D} {5}{E} {6}{F} {7}{G} {8}{H} {9}{I} {ḷḷ}{\textcompwordmark} {1ḷ}{J} {2ḷ}{K} {3ḷ}{L} {4ḷ}{M} {5ḷ}{N} {6ḷ}{O} {7ḷ}{P} {8ḷ}{Q} {9ḷ}{R} {ḷḷḷ}{\textcompwordmark} {1ḷḷ}{S} {2ḷḷ}{T} {3ḷḷ}{U} {4ḷḷ}{V} {5ḷḷ}{W}
\prop_put:Nnn \prop_put:Nnn \prop_put:Nnn \prop_put:Nnn
\g_glago_numerals_prop \g_glago_numerals_prop \g_glago_numerals_prop \g_glago_numerals_prop
{6ḷḷ}{X} {7ḷḷ}{Y} {8ḷḷ}{Z} {9ḷḷ}{@}
\ExplSyntaxOff \newcommand{\glagovalue}[1]{\glagonumeral{\number\value{#1}}} \renewcommand{\thesection}{\glagovalue{section}} \begin{document} \tableofcontents \section{A section} \setcounter{section}{1ḷḷ} \section{Another} \glagonumeral{9ḷ9} \glagonumeral{1} -\glagonumeral{2} -\glagonumeral{3} -\glagonumeral{4} -\glagonumeral{5} -\glagonumeral{6} -\glagonumeral{7} -\glagonumeral{8} -\glagonumeral{9} -\glagonumeral{1ḷ} -\glagonumeral{11} -\glagonumeral{12} -\glagonumeral{13} -\glagonumeral{14} -\glagonumeral{15} -1266
\glagonumeral{16} -\glagonumeral{17} -\glagonumeral{18} -\glagonumeral{19} -\glagonumeral{2ḷ} -\glagonumeral{21} -\glagonumeral{22} -\glagonumeral{312} -\glagonumeral{321} -\glagonumeral{322} \end{document} What you have to do now is to change the letters I’ve used for the digits into suitable commands giving the appropriate glagolitic letters. You can use \glagovalue{} just like \arabic{}. Note: this version correctly sets 12 to ”AJ”, while 21 becomes ”KA”.
Important change Due to the changes made to expl3 in Summer 2012, \seq_length:N should be replaced by \seq_count:N Skip code block \cs_new_protected:Npn \glago_numeral:n #1 { \cs_set:Npn \glago_reverse_ten: { } \seq_set_split:Nnx \l_glago_digits_seq { } { #1 } \int_set:Nn \l_glago_position_int {\seq_count:N \l_glago_digits_seq - 1} \seq_map_inline:Nn \l_glago_digits_seq { \glago_symbol:x { \glago_make_digit:nn { ##1 } { \l_glago_position_int } } \int_decr:N \l_glago_position_int } \glago_reverse_ten: 1267
} Answer by topskip A half baked LuaTeX solution. I don’t know the LaTeX stuf that is needed to deine the page counter, but this Lua function prints a string as you need. Perhaps someone can edit this code to make it work with LaTeX counters. Edit: take the reverse numbering between 10 and 20 into account. Skip code block \documentclass{article} \usepackage{luacode} \begin{luacode*} glagolitic = function(cnt) local glag_reverse = {} local i = ḷ local m while cnt > ḷ do m = cnt % 1ḷ cnt = cnt - m glag_reverse[#glag_reverse + 1] = string.rep("ḷ",i) .. m cnt = cnt / 1ḷ i = i + 1 end if glag_reverse[2] == "ḷ1" then glag_reverse[1], glag_reverse[2] = glag_reverse[2], glag_reverse[1] end -- insert \textcompwordmark between elements and reverse the string tex.sprint(string.reverse(table.concat(glag_reverse,"kramdrowpmoctxet\\"))) end \end{luacode*} % (here we need to define some macros that use the function glagolitic) \begin{document} % prints: 31ḷ 2ḷ3 1ḷḷ2ḷ3 4ḷḷ5ḷ6 5ḷḷ71ḷ ... \directlua{glagolitic(13)} 1268
\directlua{glagolitic(23)} \directlua{glagolitic(123)} \directlua{glagolitic(456)} \directlua{glagolitic(517)} ... \end{document} Tags: numbering
Scripts Skip to questions, Wiki by user arun-debray scripts is for questions involving external scripts (small programs in source code form) related to (La)TeX. If your question is about using (La)TeX as a programming language, use programming; if your question is about typesetting code in LaTeX, use code, or the listings or minted packages. Syntax Highlighting If your question or answer includes code in a non-TeX language, you can syntax highlight it by doing the following:
code goes here Then, replace the ??? with the code for your language. Here is a list of available codes for supported languages, e.g. lang-bash and lang-csh for shell scripts, lang-java for Java, lang-js for Javascript, lang-lua for Lua, lang-perl for Perl, lang-py for Python, lang-r for R, and lang-xml for XML.
1269
Frequently Asked Questions 1. Is there a correct way to do a word count of a LaTeX document? 2. Issues with Perl and Python scripts when installing MikTeX 3. How can I detect all pages that contain color?
Questions Q: What are the advantages of Lua over other scripting languages for a TeX implementation? Tags: scripts The question is inspired by Martin Schröder’s answer to I am new to TeX. Should I use LaTeX, XeLaTeX, …? as well as my two previous questions on this forum: 1. Automatic document update 2. Generate LaTeX Truth Table with Python Cheetah In retrospect, I am truly surprised that no LuaTeX user ofered any answers to my questions as it seems to me that that could be easily done in LuaTeX by embedding Lua scripts into the LaTeX code. Can it be really done (question for LuaTeX users only) and is it easy? My second question is motivated by the fact that I hate very thought of having to learn another scripting/general programming language (Lua) if I already know Python (you can substitute Perl if you like) just to use it with TeX. Is anybody cooking a Python interface for TeX call it PythonTeX for short (PerlTeX actually does exist)? As far as I know PythonTeX doesn’t exist. There is something called PyTeX but that just look like a tool for people who want to type TeX documents using Python syntax. Is there an advantage of using Lua over Python as an embedded scripting language for TeX (apart of the fact that people who started LuaTeX probably were more familiar with Lua)? Tags: scripts 1270
User: predrag-punosevac Answer by michael-palmer The LuaTeX developers have commented on their choice of Lua over other languages, including Python, on their home page. Embedding the interpreter is one thing, and apparently no fun with Python. Another is to actually make the innards of TeX visible to the embedded interpreter. While much of the communication code could likely be adapted in some way from LuaTeX to PythonTeX, it will still be a lot of work. A better approach may be to cheat a bit, and simply piggyback on the LuaTeX interpreter. There is a bridge that ’embeds’ Python inside Lua called Lunatic Python, and maybe it can be made to work with LuaTeX also. However, it may be easier to just use XML-RPC: Let LuaTeX spawn a Python process, which acts as the XML-RPC server. LuaTeX commands can then make calls to the Python process. Bonus feature: Once this is implemented on the LuaTeX side, it can be used with any other scripting language, not just Python. Answer by g.-poore I have been coding ”PythonTeX” since last May, and am planning the irst public release sometime between next weekend and the beginning of March. I’m actually planning to call it PythonTeX, by analogy to PerlTeX and SageTeX. I’ve created a LaTeX package, and accompanying Python scripts, that provide most functionality of python.sty, SageTeX, and SympyTeX, but with emphasis on speed and usability. Here’s a brief summary of what PythonTeX will bring. • Persistence between commands and environments. For example, each environment \begin{pythoncode} ... \end{pythoncode} picks up where the last left of, so all variables, functions, etc. persist. You can optionally name commands and environments, and then there is only persistence between commands and environments with the same name. For example, \begin{pythoncode}[name] ... \end{pythoncode} 1271
only shares persistence with other commands and environments called name. • Automatic inclusion of printed content. For example, \begin{pythoncode} print(1+1) \end{pythoncode} is automatically replaced by 2 in the compiled document. • Speed. Each set of named commands and environments is executed in its own process, using Python’s multiprocessing package. Also, each set is hashed, so code is only executed when changed. The results of running the code are saved, and reused when no changes are detected. • Code typesetting. All code that is executed can also be typeset, using fancyvrb and its internals. Optionally, code can be typeset using Pygments, which is a Python package that does syntax highlighting (Pygments is used by the minted package). When Pygments is used, all code is hashed and the typeset results are saved, so that only changed code must be processed by Pygments in subsequent runs. This helps prevent Pygments from slowing things down. • Meaningful error messages. All error messages are parsed by code that determines the line of your document where the error occurred (as opposed to the line of the *.py ile that is actually executed). So you know exactly where things went wrong in your document. • Minimal iles. The code cleans up after itself, so the number of permanent iles created by Python is kept to a minimum and all temporary iles are deleted after each run. I can post a link as soon as PythonTeX is released. I will also be submitting it to CTAN shortly after the irst public release. Answer by christian-lindig My take is: Lua as a language was created as an embedded language and is well suited for the job. Now that with LuaTeX a scriptable TeX implementation exists, there is little principled reason to create another one. Of course, 1272
you can go ahead and create PythonTeX. But it seems that the community feels that this would not add enough value over LuaTeX to justify the cost. Tags: scripts
Lengths Skip to questions, Wiki by user werner The calc package is typically used in length calculations, allowing users to do \newlength{\mylen} \setlength{\mylen}{2pt-3em+5pc}% 29.14992pt under 11pt font similar to plain TeX’s \dimexpr 2pt-3em+5pc\relax. In pure LaTeX, the equivalent would require \newlength{\mylen} \setlength{\mylen}{2pt} \addtolength{\mylen}{-3em} \addtolength{\mylen}{5pc}
Questions Q: LuaLaTeX: Calculate length in Lua Tags: lengths I apologize if this a rookie question, but I ind it extremely hard to ind a solution to my Lua problem using online searches and browsing reference manuals. 1273
I would like to calculate a length: Divide \linewidth by \baselineskip, take the floor, and inally multiply with \baselineskip. The result should be returned in pt. I already fail with getting \baselineskip into Lua such that I can do a calculation with it: Skip code block
\documentclass{article} \begin{document} \begin{enumerate} \item Linewidth works this way: \directlua{tex.sprint(tex.dimen['linewidth'] / 655 \item and this way: \directlua{tex.sprint(tex.dimen.linewidth / 65536)tex.sprint(' \item \directlua{tex.sprint(tex.dimen['baselineskip'])} \item \directlua{tex.print(tex.skip['baselineskip'].width)} \item \directlua{tex.print(tex.skip['baselineskip'].stretch)} \item \directlua{tex.sprint(tex.baselineskip)} \end{enumerate} \end{document} So the questions are: How do I get \baselineskip into Lua, and how can I calculate and output the length I described above. If someone happens to know a ”real” beginner’s guide to LuaLaTeX that also discusses such problems, I would appreciate a hint. Thanks!
Solution With the help of the answers below, the length above can be calculated as: \directlua{tex.sprint(math.floor(tex.dimen.linewidth / tex.baselineskip.width) * tex.baselineskip.width / tex.sp('1pt') ..'pt')} Tags: lengths User: lorianl Answer by david-carlisle 1274
You can use tex.baselineskip in Lua to get the baselineskip but a skip is a Lua userdata object (as it has stretch and shrink components as well as a natural length) so you can not directly use it in inline arithmetic Lua expressions with / \documentclass{article} \begin{document} \directlua{ print('baseline is ' } \end{document}
..tex.baselineskip.width)
produces terminal output: baseline is 786432 Tags: lengths
AUCTeX Skip to questions, Wiki by user torbjørn-t. AUCTeX is an emacs/XEmacs package for writing documents with LaTeX, TeX, ConTeXt, docTeX or Texinfo. It gives you syntax highlighting, code completion, and also includes preview-latex, which lets you generate and view PNG previews of parts the code directly (e.g. math) in the Emacs bufer. For working with citations and cross-references AUCTeX works very well with reftex. One can get a hint of AUCTeX’s capabilities by reading Useful shortcuts or key bindings or predeined commands for emacs+AUCTeX. 1275
Questions Q: AUCTeX changes name of pdf ile when compiling with LuaTeX Tags: auctex I’m using AUCTeX with emacs 24.1 on Ubuntu 11.10. I have the TeX Command set to compile using LuaTeX and to produce pdfs. Everything works except that the name of the pdf changes from the ile name to textput.pdf. Not a super big deal but the same thing happens with the index and I have to rename it to the ile name in order to get the document to compile with an index (defeating somewhat the purpose of the convenience of having the Index command available in AUCTeX). I’ve seen reports of this issue elsewhere on the internet but not being very knowledgeable about the inner workings of emacs I have been unable to igure out how to ix this behavior. I had been compiling everything with XeLaTeX and it all worked as expected with respect to the resulting ile names, so this appears to be a problem with LuaTeX or how AUCTeX deals with LuaTeX. Tags: auctex User: bfootdav Answer by andrew-swann This is indeed a bug in AUCTeX. To ix it you need to customize TeX-command-list so that the LaTeX entry has the associated command equal to %`%l --jobname=%s %(mode)%' %t which includes an explicit setting of jobname to match that of your current ile. The relevant part of the customize bufer looks like this (you need to have opened a tex ile, before this option becomes available):
1276
I have been using this regularly for sometime now without problems. Tags: auctex
Database Questions Q: Extract data from excel ile with lualatex Tags: database I have an Excel ile that I use as a database. Of course, there are a lot of entries (more than 4000) and I don’t want to use all the data to create my PDF. So I was thinking of using LuaLaTeX to create a script to use only the data I need. 1277
But I don’t know how to access to my Excel ile with my script. Is there a proper way or not? Tags: database User: romain-picot Answer by stefan-pinnow When you follow the advice of Joseph Wright and Andrew you could also use the pgfplotstable package to print your CSV ile. Because you didn’t provide an example, I just copied the code from this answer. To see the result, see there. Skip code block \documentclass[margin=5mm,preview]{standalone} \usepackage{siunitx} % Formats the units and values \sisetup{ % setup siunitx ... round-mode = places, % rounds numbers round-precision = 2, % to 3 places per-mode = symbol, % kg/dm^3 instead kgm^{-3} group-four-digits = true, % for 1 234,567 } \usepackage{booktabs} % for table rules \usepackage{pgfplotstable} \usepackage{filecontents}
% Generates table from .csv % , rounded corners, semithick] \graph[ % LAYERED layered layout, %level distance = 2cm, %sibling sep = 1cm, %sibling distance = 1cm % CIRCULAR %simple necklace layout, grow' = left, %node sep = 1em, ]{% #1; }; \end{tikḶpicture}} \expandafter\ḶḶ\expandafter{\directlua{tex.print(str)}} 1283
\end{document} Tags: trees
PDF Skip to questions, Wiki by user stefan-kottwitz pdf is speciically about the PDF ile format, with topics such as bookmarks, links and meta information. If your question is about producing PDF output, choose an appropriate tag such as pdftex or ps2pdf. If your question concerns PDF reader software, also use viewers or a reader speciic tag such as acrobat, evince or okular.
Questions Q: LuaLaTeX and \pdfminorversion Tags: pdf I need to build a PDF 1.6 with LuaLaTeX, and I can’t get \pdfminorversion command to work: \pdfminorversion=6 \documentclass{article} \begin{document} This is a test 1284
\end{document} The result is Undefined control sequence. \pdfminorversion PdfLaTeX builds the PDF, but I need to use LuaLaTeX (I need the fontspec package). Tags: pdf User: zé-cláudio Answer by joseph-wright As of LuaTeX v0.87, the pdfTeX-derived extension primitives are renamed. Here, you want \pdfvariable minorversion The details of emulation are given in the LuaTeX manual, or you can load the luatex85 package which wraps up this emulation for the transition. Answer by henri-menke You can also set the minor version on the Lua end. \directlua{pdf.setminorversion(6)} \documentclass{article} \begin{document} This is a test \end{document} $ pdfinfo test.pdf Creator: TeX Producer: LuaTeX-1.ḷ.4 [...] PDF version: 1.6 Tags: pdf 1285
TexMaker Skip to questions, Wiki by user doncherry texmaker is about the LaTeX editor Texmaker. If your question is about its fork TexMakerX, which is now called TeXstudio, please use the tag texstudio.
Questions Q: How do you conigure Texmaker to use LuaTeX? Tags: texmaker I’m extending my use from pdfLaTeX to LuaLaTeX. However, LuaTeX does not seem to come pre-conigured in the Texmaker editor. How does one conigure Texmaker to use LuaTeX on a document-todocument basis? (I am using ubuntu 10.4, but this question should be a priori platform independent.) Tags: texmaker User: meduz Answer by mpg If you want to permanently switch from pdlatex to lualatex, see Joseph’s answer. If, however, you want to be able to use both, you need to add a userdeined command. From the menu, User -> User commands -> Edit user
1286
commands opens a dialog box. Choose a name (eg ”LuaLaTeX” for the command) and use lualatex --interaction=nonstopmode % for the command itself. This command is now available form the menu or as Alt+Shift+F1. Normally, lualatex should be in your command search path (given by the PATH environment variable), but if it isn’t, you need to specify the full path to lualatex. Check the path for pdlatex in the preferences: lualatex is most probably in the same directory. Answer by joseph-wright From the Preferences menu entry (location platform-dependent), you should be able to change the ’PdfLaTeX’ line changing /pdflatex to /lualatex. Usually, will be something like /usr/local/texlive/2ḷ1ḷ/bin, or /usr/texbin on the Mac. Answer by torbjørn-t. Another way is to use arara. It is included in TeX Live from version 2012, so those with recently updated TeX Lives will have it available. Other users will have to install it manually. To use arara from Texmaker see Integration of arara in Texmaker. Having installed it, and conigured Texmaker, one just has to add for example % arara: lualatex at the beginning of your ile, and compile with arara. See Tools for automating document compilation for another example. Tags: texmaker
1287
Pdfcrop Questions Q: pdfcrop using luatex engine minimal setup Tags: pdfcrop I want to try the great pdfcrop.pl script by Heiko Oberdiek (http://www. ctan.org/pkg/pdfcrop) with LuaTeX engine. Unfortunately my knowledge about LaTeX tools like LuaTeX is non existent. I’m looking for miniamalist setup instructions to make it work (on Windows 7 OS). I downloaded miminal LuaTeX engine iles from: contextgarden.net/current/bin/luatex/mswin/bin/
http://minimals.
I’m using --luatex --luatexcmd switches for the script but it throws errors. I’ve made a lot of cobbling it together at that point (like copying missing .fmt and other iles from other distributions like MikTeX, LeXlive etc..) but I guess it doesn’t make sense to describe that exactly as I didn’t really know what I was doing ;) Best would be to start fresh So given the pdfcrop.pl script and the miminalist LuaTeX engine iles - Coould somebody outline steps to make it work? Thanks a lot! UPDATE When i’m running this with --debug and --ini switches:
pdfcropn.pl --debug --hires --gscmd="C:\Program Files\gs\bin\gswin32c.exe" --l it gives me this: ‘PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek. • Restricted mode: disabled • Option ‘pdfversion’: auto • Input ile: CTGov PS model.pdf 1288
• Output ile: CTGov PS model.crop2.pdf • Margins: 0 0 0 0 • Input ile name ‘CTGov PS model.pdf’ contains special characters. • Copy input ile to temporary ile ‘tmp-pdfcrop-11176-img.pdf’. • PDF header: %PDF-1.5 • Using PDF minor version: 5 • Running ghostscript for BoundingBox calculation ... • Ghostscript call: ”C:\Program Files\gs\bin\gswin32c.exe” sDEVICE=bbox -dBATCH -dNOPAUSE -c save pop -f tmppdfcrop-11176-img.pdf GPL Ghostscript 9.10 (2013-08-30) Copyright (C) 2013 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the ile PUBLIC for details. Processing pages 1 through 1. Page 1 Substituting font Helvetica for ArialMT. Loading NimbusSanL-Regu font from %rom%Resource/Font/NimbusSanLRegu... 3590604 2239077 5213760 3919818 4 done. %%BoundingBox: 32 199 555 644 %%HiResBoundingBox: 32.430022 199.070080 554.069936 643.009902 • Page 1: 32.430022 199.070080 554.069936 643.009902 • Running LuaTeX ... • LuaTeX call: C:\PDFcrop\Luatex\luatex.exe -no-shell-escape --ini -etex -interaction=nonstopmode tmp-pdfcrop-11176
warning: kpathsea: coniguration ile texmf.cnf not found in these directories: C:/PDFcrop/Luatex;C:/PDFcrop/Luatex/share/texmflocal/web2c;C:/PDFcrop/Luatex/share/texmf-dist/web2c;C:/PDFcrop/Luatex/share/texmf/web2 local/web2c;C:/PDFcrop/Luatex/texmf-dist/web2c;C:/PDFcrop/Luatex/texmf/web2c;C:/PDFcro 1289
local/web2c;C:/PDFcrop/share/texmf-dist/web2c;C:/PDFcrop/share/texmf/web2c;C:/PDFcrop/t local/web2c;C:/PDFcrop/texmf-dist/web2c;C:/PDFcrop/texmf/web2c;C://texmflocal/web2c;C:/;C://share/texmf-local/web2c;C://share/texmf-dist/web2c;C://share/texmf/web2 local/web2c;C://texmf-dist/web2c;C://texmf/web2c. This is LuaTeX, Version beta-0.78.2 (TeX Live 2013/W32TeX) (rev 4774) (INITEX) ! I can’t ind ile ‘tmp-pdfcrop-11176’. tmp-pdfcrop-11176 Please type another input ile name ! Emergency stop. tmp-pdfcrop-11176 No pages of output. Transcript written on texput.log. • Cleanup • Temporary iles: tmp-pdfcrop-11176-img.pdf tmp-pdfcrop-11176.tex tmp-pdfcrop-11176.log !!! Error: LuaTeX run failed with value 1¡ I can see tmp-pdfcrop-5448.tex has been created in the directory where original PDF is. Moreover by manually re-running luatex command with full path to the tex ile it goes further but still breaks:
C:\PDFcrop>C:\PDFcrop\Luatex\luatex.exe -no-shell-escape --ini --etex -interaction=nonstopmode c:\pdfcrop\tmp-pdfcrop-5448 warning: kpathsea: configuration file texmf.cnf not found in these directories: C:/PDFcrop/Luatex;C:/PDFcrop/Luatex/share/texmf-local/web2c;C:/ This is LuaTeX, Version beta-ḷ.78.2 (TeX Live 2ḷ13/W32TeX) (rev 4774) (INITEX) (c:/pdfcrop/tmp-pdfcrop-5448.tex !LuaTeX error (file tmp-pdfcrop-12368-img.pdf): cannot find image
1290
file 'tmp-pdfc rop-12368-img.pdf' ==> Fatal error occurred, no output PDF file produced! Tags: pdfcrop User: msciwoj Answer by heiko-oberdiek pdfcrop also works without format iles (iniTeX mode), if option --ini is given: pdfcrop --luatex --ini Or with specifying the binary: pdfcrop --luatex --ini --luatexcmd=/some/where/luatex Tags: pdfcrop
Typein Skip to questions, Wiki by user arun-debray typein is for questions related to the \typein command, which allows the user to read in a command from the terminal at compilation time. There are two possible ways to use \typein: • Using \typein[\command]{message} displays message to the user when it’s reached during compilation, and stores the user’s input in \command. • Using \typein{message} displays message to the user when it’s reached, and then replaces itself with the user’s input.
1291
For the related \typeout command, which allows one to write to the terminal, see the terminal-output tag.
Questions Q: incompatibilities between LuaLaTeX and \typein ? Tags: typein The following ecm compiles ine with LaTeX and XeLaTeX, but doesn’t work with LuaLaTeX : \documentclass{minimal} \begin{document} \typein{test} \end{document} And here is the error : Invalid \endlinechar. \@M l.4 \typein{test} ? Tags: typein User: matsaya Answer by philipp You probably have to patch the kernel (untested): \def\@xtypein[#1]#2{% \typeout{#2}% \@tempcnta\endlinechar \endlinechar\m@ne 1292
\read\@inputcheck to#1% \endlinechar\@tempcnta \@typein} This should be done at format generation time; you might report it at the LaTeX mailing list ([email protected]). Answer by matsaya I’ve submitted the bug to LaTeX bugs database and this is now ixed in TeXLive. Tags: typein
Pgfmath Skip to questions, Wiki by user peter-jansson The pgfmath tag concerns the pgfmath library in TikZ-pgf. pgfmath enables computations in TikZ-pgf but can also be used independently. The library enables features which are much more powerful than the similar ones in the calc package. Another packages with similar features is fp. See the TikZ-pgf manual section on the pgfmath library for details.
Questions Q: Lua reimplementations of PGF math? Tags: pgfmath 1293
I was looking around in the texmf-dist tree for TeXLive 2016 on my system and found an implementation of the pgfmath functions in Lua, bundled in the (undocumented) PGF library luamath in this directory 2ḷ16/texmf-dist/tex/generic/pgf/libraries/luamath. Using that library instead of fpu or pgfmath seems to work, and it produces the correct answers to a much higher precision, but there’s no mention of it anywhere in the documentation. EDIT here’s a code snippet from the document I’m working on: \pgfplotstablecreatecol[% create col/assign/.code={% \pgfluamathparse{ln(\thisrow{vtitre})} \pgfkeyslet{/pgfplots/table/create col/next content}\pgfmathresult }, ]{lnvtitre}\titretable Is this library ready for use, or an experimental new feature? Luatex is itself still considered experimental, but I’ve been using it for the last year without issues. Tags: pgfmath User: robbie Answer by christian-feuersänger The luamath library is actively used in pgfplots: if you write \pgfplotsset{compat=1.12} (or newer) and translate the document with lualatex, pgfplots will shift lots of its arithmetics to lua (higher precision, much faster). The reference documentation for this part is in the pgfplots manual keyword lua backend. The standalone version of the library is also available as \usepgflibrary{luamath}. This enables \pgfluamathparse{} as you found out on your own. In addition, it allows to say \pgfkeys{luamath=parser} in which case it will substitute \pgfmathparse.
1294
The luamath parser support all (or almost all?) math functions known to pgf. In order to also support TeX register- and dimension arithmetics (like \countḷ or 1ḷpt), it supports a TeX fallback: it tries to compute it in LUA, if that turns out to be impossible, it computes it in TeX. It also supports \pgfkeys{luamath/output format=fixed|float} where float is the format understood by \usepgflibrary{fpu} (also by \pgfmathprintnumber). There is also a LUA API which does not need the TeX macro as entry point, but that is somewhat beyond the scope of this answer. The library will become part of the oicial documentation eventually. There are other choices (like luamath=only computation) which are untested and experimental. Tags: pgfmath
Forward Inverse Search Skip to questions, Wiki by user guilherme-zanotelli SyncTeX is a utility written by Jérôme Laurens which enables synchronization between your source document and the PDF output. Mostly this Feature is Editor/Viewer dependent, to see a list of Editors which support this Feature in Comparison of TeX editors under the Inverse Search column. If your editor/viewer supports it, then you can click in your source and jump to the equivalent place in the PDF or click in the PDF and it will jump to the appropriate place in your source document. In TeXShop, for example, Command-click does the Navigation, in TexStudio right-click the source or PDF in built-in Viewer and select Go To 1295
PDF/Go To Source. Other editor/viewer pairs may implement the exact commands slightly diferently. The iles that it creates store all of the synchronization data that make this magic possible. Gzipped versions of these iles are created if you pass the --synctex=1 option to e.g. the pdflatex command (and other engines similarly); non-zipped versions can be created with --synctex=-1, although for a large document these iles can be quite large, so the zipped ones are generally to be preferred. See • Why does LaTeX gzip the synctex ile? Usually this is part of the default setting for the compilation command within most TeX-aware editors.
Questions Q: When is Synctex ile written? Tags: forward-inverse-search When is the syncTeX ile written and is there a way to get a callback in to lua after it occurs? I would like to read it at the end of the compilation process rather than have to compile twice to get at it. I could potentially run an external script or wrap the compilation process to accomplish this task but that is much more work than necessary. inish_pdile occurs before synctex is written so it is no good ;/ Here is a list of all the callbacks, I believe, I don’t see anything that will help. Skip code block local callbacktypes = callbacktypes or { find_read_file = exclusive, find_write_file = exclusive, find_font_file = data, find_output_file = data, find_format_file = data, 1296
find_vf_file = data, find_map_file = data, find_enc_file = data, find_sfd_file = data, find_pk_file = data, find_data_file = data, find_opentype_file = data, find_truetype_file = data, find_type1_file = data, find_image_file = data, open_read_file = exclusive, read_font_file = exclusive, read_vf_file = exclusive, read_map_file = exclusive, read_enc_file = exclusive, read_sfd_file = exclusive, read_pk_file = exclusive, read_data_file = exclusive, read_truetype_file = exclusive, read_type1_file = exclusive, read_opentype_file = exclusive, find_cidmap_file = data, read_cidmap_file = exclusive, process_input_buffer = data, process_output_buffer = data, process_jobname = data, contribute_filter = simple, buildpage_filter = simple, pre_linebreak_filter = list, linebreak_filter = list, append_to_vlist_filter = list, post_linebreak_filter = list, hpack_filter = list, vpack_filter = list, hpack_quality = list, vpack_quality = list, pre_output_filter = list, process_rule = list, 1297
}
hyphenate = simple, ligaturing = simple, kerning = simple, insert_local_par = simple, mlist_to_hlist = list, pre_dump = simple, start_run = simple, stop_run = simple, start_page_number = simple, stop_page_number = simple, show_error_hook = simple, show_warning_message = simple, show_error_message = simple, show_lua_error_hook = simple, start_file = simple, stop_file = simple, finish_pdffile = data, finish_pdfpage = data, define_font = exclusive,
I’m also not sure of a pure lua way or if the synctex ile is written after all lua code is inished. Tags: forward-inverse-search User: abstractdissonance Answer by david-carlisle Looking at the source the synctex ile is closed as the really last thing after all callbacks Skip code block
/* Close {\sl Sync\TeX} file and write status */ synctexterminate(log_opened_global); /* Let the {\sl Sync\TeX} controlle free_text_codes(); free_math_codes(); if (log_opened_global) { 1298
}
}
wlog_cr(); selector = selector - 2; if ((selector == term_only) && (callback_id == ḷ)) { tprint_nl("Transcript written on "); tprint_file_name(NULL, texmf_log_name, NULL); print_char('.'); print_ln(); } lua_a_close_out(log_file);
which is the end of close_files_and_terminate and the only thing called after that is do_final_end(); which just sets the error status and stops. So I don’t think the synctex data is reliably available during the current run. Tags: forward-inverse-search
OCG Skip to questions, Wiki by user martin-schröder LaTeX packages which help implementing this are ocgx, ocgx2 and ocg-p.
Questions Q: How to use ocg-p with LuaLaTeX (TeXlive 2015)? Tags: ocg If I compile the following MWE 1299
\documentclass{scrartcl} \usepackage{ocg-p}%Layers \begin{document} \end{document} with luaLaTeX, it stops with the following error: ! Package ocg-p Error: pdfeTeX, version >= 1.2ḷ, required. The ocg-p package is supported only for pdlatex and xelatex, but in the past (TeXLive 2014) I had no problems to use it in combination with luaLaTeX. I need the combination of ocg-p and luaLaTeX. The ocg-p-package itself is unchanged since 2013, so this check for pdfeTeXversion already existed in the previous version. Tags: ocg User: knut Answer by alexg Package ocgx2 serves as a drop-in replacement for ocg-p, ocg and ocgxpackages. See README for ixes and additions in comparison with the other packages. Skip code block \documentclass{scrartcl} %\documentclass[dvipdfmx]{scrartcl} \usepackage{ocgx2} %pdflatex, lualatex, xelatex, latex+dvips+ps2pdf \begin{document} %same interface as ocg.sty, ocg-p.sty, ocgx.sty \begin{ocg}{hello}{hello}{1} \strut Hello! \end{ocg} \begin{ocg}{good bye}{good bye}{ḷ} 1300
\strut Good bye! \end{ocg} \toggleocgs{hello {good bye}}{\fbox{Toggle visibility}} %ocg-p %\switchocg{hello {good bye}}{\fbox{Toggle visibility}} %ocgx \end{document} Answer by knut Quick help: Set the pdftexversion-number to the expected value. \documentclass{scrartcl} \def\pdftexversion{12ḷ} \usepackage{ocg-p}%Layers \begin{document} \end{document} Background: ocg-p makes the following checks: Skip code block \RequirePackage{ifpdf} \RequirePackage{ifxetex} [...] \ifpdf \ifnum\pdftexversion= 1.2ḷ, required% }{% Install a newer version!% }% \fi \else \ifxetex %already ok \else 1301
% dvips \@ocgp@ifpstrue \PackageWarningNoLine{ocg-p}{% Only XeLaTeX and pdfLaTeX are supported% }% \fi \fi In the past lualatex 79 set pdftexversion 200. Since TeXlive 2015 the value is set to the value of lualatexversion (actually 80). So this check fails and you get the error. In the future pdftexversion will not be deined. In case somebody has a similar problem in another package. The version check could be modiied to: Skip code block \RequirePackage{ifpdf} \RequirePackage{ifxetex} \RequirePackage{ifluatex} %.... \ifluatex %already ok (tested with luatexversion ...) \else \ifpdf \ifnum\pdftexversion= 1.2ḷ, required% }{% Install a newer version!% }% \fi \else \ifxetex %already ok 1302
\else % dvips \@ocgp@ifpstrue \PackageWarningNoLine{ocg-p}{% Only XeLaTeX and pdfLaTeX are supported% }% \fi \fi \fi Tags: ocg
LilyPond Skip to questions, Wiki by user user13907 LilyPond is a music engraving program, devoted to producing the highestquality sheet music possible. It brings the aesthetics of traditionally engraved music to computer printouts. LilyPond is free software and part of the GNU Project. Questions about the lilypond-book program, which incorporates LilyPond and (Xe)LaTeX fall under this tag as well as other questions about interactions between LilyPond and TeX programs.
Questions Q: Getting lilyglyphs working in LuaTeX Tags: lilypond
1303
The package lilyglyphs provides a set of macros for incorporating Lilypond fonts easily into XeLaTeX iles. That package is available here. I am using TeXLive 2013. With the following MWE it works as expected with XeLaTeX: \documentclass{memoir} \usepackage{fontspec} \usepackage{lilyglyphs} \begin{document} \lilyTimeC \end{document} Running it with LuaLaTeX results in the following error: ! Undefined control sequence. \lilyGetGlyph #1^^@-\XeTeXglyph \XeTeXglyphindex "#1" I traced this back to the core/genericAccess.inp ile which contains the following line: \newcommand*{\lilyGetGlyph}[1]{\XeTeXglyph\XeTeXglyphindex"#1" } OK, that’s a XeTeX-speciic command. I need the LuaTeX version in order to make this work with LuaLaTeX. I found this answer which suggests something like this: \def\lilyGetGlyph#1{\directlua{fonts.otf.char("#1")}} But when I run LuaLaTeX on the MWE I get the following error:
! LuaTeX error [string "\directlua "]:1: attempt to index field 'otf' (a nil value stack traceback: [string "\directlua "]:1: in main chunk. \lilyGetGlyph ...\directlua {fonts.otf.char("#1")} I have no idea what that means but neither do I understand the syntax of my attempted ix (I just keep putting in words and symbols hoping something will work). So what I’m looking for is the LuaTeX version of that XeLaTeX bit of code that will allow the package lilyglyphs to work with LuaLaTeX. Assuming, of course, that’s the proper way to ix this. 1304
Tags: lilypond User: bfootdav Answer by bfootdav OK, so apparently the \directlua{fonts.otf.char is no longer supported in LuaTeX according to this answer. Fortunately they (@phg) supplied a solution as well: Skip code block \usepackage{luaotfload,luacode} \begin{luacode} documentdata = documentdata or { } local stringformat = string.format local texsprint = tex.sprint local slot_of_name = luaotfload.aux.slot_of_name documentdata.fontchar = function (chr) local chr = slot_of_name(font.current(), chr, false) if chr and type(chr) == "number" then texsprint (stringformat ([[\char"%X"]], chr)) end end \end{luacode} \def\lilyGetGlyph#1{\directlua{documentdata.fontchar "#1"}} Which I added to the core/genericAccess.inp ile and now everything works as it should. I added some tests to check for LuaTeX vs. XeTeX to the original code and will send all of this to the author of the package. Tags: lilypond
1305
Etextools Questions Q: etextools throws error when run with LuaLaTex Tags: etextools I was trying to use the etextools package with LuaLaTeX and ran into the following error ! String contains an invalid utf-8 sequence. l.233 \csdef{ettl@ifdef#2}##1#1##2/End Meaning/{\ettl@nbk##2//\rmn@firstoft... The error can be reproduced by running the following simple document in LuaLaTeX: \documentclass{article} \usepackage{etextools} \begin{document} Some text \end{document} Is there a workaround for using etextools together with LuaLaTeX or am I simply missing something here? Tags: etextools User: arno-mittelbach Answer by egreg The deinition of \ettl@ifd@f contains two instances of ^^a7 that is an invalid UTF-8 sequence. That character is made active in the documentation part, but it should be irrelevant. I guess the intention was to provide a “non standard” delimiter for the purpose of the macro, but of course it’s a wrong decision. \def\ettl@ifd@f#1#2{% 1306
}
\csdef{ettl@ifdef#2}##1#1##2/End^^a7Meaning/{\ettl@nbk##2//\rmn@firstoftwo\rmn@ \csedef{ifdef#2}##1{\noexpand\romannumeral\noexpandafter% \noexpandcs{ettl@ifdef#2}\noexpand\meaning##1#1/End^^a7Meaning/}%//{##2}{##3
A better programming style should be assigning a non standard category code to, say Q and Z and use such safer characters as delimiters, say
\begingroup\catcode`Q=3 \catcode`Z=3 \gdef\ettl@ifd@f#1#2{% \csdef{ettl@ifdef#2}##1#1##2/EndQZMeaning/{\ettl@nbk##2//\rmn@firstoftwo\rmn@se \csedef{ifdef#2}##1{\noexpand\romannumeral\noexpandafter% \noexpandcs{ettl@ifdef#2}\noexpand\meaning##1#1/EndQZMeaning/}%//{##2}{##3}/ } \endgroup However, I can’t reproduce the bug with TeX Live: Skip code block This is LuaTeX, Version beta-ḷ.79.1 (TeX Live 2ḷ14) (rev 4971) restricted \write18 enabled. (./arnobug.tex LaTeX2e Babel and hyphenation patterns for 79 languages loaded. (/usr/local/texlive/2ḷ14/texmf-dist/tex/latex/base/article.cls Document Class: article 2ḷ14/ḷ9/29 v1.4h Standard LaTeX document class (/usr/local/texlive/2ḷ14/texmf-dist/tex/latex/base/siḶe1ḷ.clo)) (/usr/local/texlive/2ḷ14/texmf-dist/tex/latex/etextools/etextools.sty (/usr/local/texlive/2ḷ14/texmf-dist/tex/latex/etex-pkg/etex.sty) (/usr/local/texlive/2ḷ14/texmf-dist/tex/latex/etoolbox/etoolbox.sty) (/usr/local/texlive/2ḷ14/texmf-dist/tex/latex/oberdiek/letltxmacro.sty) Package etextools Warning: \pdfstrcmp primitive not found (etextools) Macro \xifempty has been replaced by \xifstrempty (etextools) It is not purely expandable on input line 381. Package etextools Warning: \pdfstrcmp primitive not found (etextools) Macro \ifstrcmp has been replaced by \ifstrequal 1307
(etextools)
It is not purely expandable on input line 4ḷ3.
Package etextools Warning: \pdfstrcmp primitive not found (etextools) Macro \xifstrcmp has been replaced by \xifstrequal (etextools) It is not purely expandable on input line 4ḷ9. ) (./arnobug.aux) [1{/usr/local/texlive/2ḷ14/texmf-var/fonts/map/pdftex/updmap/p dftex.map}] (./arnobug.aux)) 264 words of node memory still in use: 2 hlist, 1 vlist, 1 rule, 2 glue, 4ḷ glue_spec, 1 write nodes avail lists: 1:4,2:13,3:2,4:23,6:15,7:1,9:6