New answers tagged

2

You can define a new environment in different ways according to the engine: \ifdefined\HCode \documentclass{book} \else \documentclass[11pt,a4paper]{book} \usepackage{longtable} \usepackage{tabu} \fi \ifdefined\HCode \newenvironment{maybelongtable} {\begin{tabular}{|l|l|}\hline A&B \\\hline} {\end{tabular}} \else \newenvironment{...


2

Here's a minimal example featuring customised tracking for all italic fonts: \documentclass{article} \usepackage{fontspec} \usepackage[tracking]{microtype} % 1. Enable tracking \DeclareMicrotypeSet*[tracking]{italics} % 2. Declare which fonts should { encoding = *, shape = it* } % receive tracking adjustment \SetTracking ...


0

Ok, i have found a working solution with xparse package: \usepackage{xparse} and then using \NewDocumentCommand{\myprint}{v} { \directlua{myprint([[#1]])} } The v means verbatim, that makes it work!


2

Tell fontspec to select the bold variant by appending /B. Just for reference, there is also /I for italic and /BI for bold-italic. \documentclass{article} \usepackage{fontspec} \setmainfont[BoldFont={Latin Modern Roman/B}]{CMU Concrete} \begin{document} Hello \textbf{World!} \end{document}


2

If you pass \newcommand{\home}{$HOME} in the command line, then the shell will interpret the variable, but in a TeX file it would not work. You can use catchfile and kpsewhich that, I believe, also works in MiKTeX. \documentclass{article} \usepackage{catchfile} \CatchFileEdef{\home}{|"kpsewhich -var-value=HOME"}{\endlinechar=-1 } \begin{document} \...


1

I can't really believe that $HOME works, but on windows you can use something like this (to avoid problems with the backslash in pathes, one should print the path with another catcode table): \documentclass{article} % \usepackage{graphicx} %log all values of os.env: \directlua{for k, v in pairs( os.env ) do texio.write_nl ("key: "..k .. " value: ".. v)...


1

There is os.getenv function provided by Lua, so I would use that: \documentclass{article} \newcommand\home{\directlua{tex.print(-2,os.getenv("HOME"))}} \begin{document} this is home: \home \end{document}


1

If you want to use xelatex + luatex and unicode chars above position 256 you must add them to the process letter list. See The 'listings' package and UTF-8. In the case of the lambda you should add ^^^^03bb: \documentclass{standalone} %\usepackage{luatex85} %needed with newer luatex % allow unicode characters in listings \RequirePackage{fontspec} \...


1

Steven should take full credit; I add some considerations about the problem. The separator between initials and surname seems to be controversial and you may be requested to use a normal space instead of the thin space. So it's much better to define a macro that will take care of the issue: just changing its definition will modify the global behavior. ...


5

Add \usepackage{luatex85} or \usepackage{graphicx} (assuming that you have the newest luatex).


3

In general, size feature refers to: Tag: 'size' Friendly name: Optical size Function: This feature stores two kinds of information about the optical size of the font: design size (the point size for which the font is optimized) and size range (the range of point sizes which the font can serve well), as well as other information which ...


2

The fontfeature "size" is used as information about design size, recommended range of sizes, and subfamily ID, which is shared for all font files in given family with various optical sizes. This parameter is read-only. An application can read it and do implement an intelligence based on such information. For example automatically selection of the font file ...


4

You are expanding \\ to its newline meaning before calling lua. Use tex.sprint("\string\\include{ same issue in your added babel example, you are expanding " too early as a babel shorthand. You can disable all Tex expansion of the argument via: \directlua{\detokenize{ for i=1,2,1 do tex.sprint("\\include{text/", i, "} ") end }}


2

The fastest way I have found to import relative packages in lualatex is require(package.searchpath('test', './?.lua:./code/?.lua')) which will find test.lua by searching ./ and ./code. It is hacky, but also clear and quick. Adding the path loader as in http://tex.stackexchange.com/a/219228/2891 is the more thorough solution, but that code did not ...


8

A trick learned from egreg. If you put \nobreak\hspace{0pt} between the nonbreakable space and the last name, the last name will be reevaluated as its own entity for hyphenation. Below, I codify that as \? to place the small unbreakable space and reset the "hyphenability" of the following word. \documentclass{article} \newcommand\?{\,\nobreak\hspace{0pt}} ...


2

I think you can use the stop_run callback: \documentclass{article} \def\fileID{Z} \begin{document} A random number: \directlua{ luatexbase.add_to_callback( 'stop_run', function () texio.write_nl("renaming output to " .. "\jobname" .. "\fileID.pdf") os.rename("\jobname" .. ".pdf", "\jobname" .. "\fileID.pdf") end, "renamepdf" ) } \end{document}


4

The implementation of \mathaccent and \cdot are very different in legacy LaTeX and unicode-math. \documentclass{article} \usepackage{unicode-math} \newcommand{\cdotaccent}{\Umathaccent fixed "7 "2 `⋅ } \newcommand{\dotcup}{\mathbin{\cdotaccent\cup}} \begin{document} $a \dotcup b$ \end{document} Of course \ensuremath is useless, whereas \mathbin gives ...


3

The usage is very odd (\mathaccent takes a number not a character as the specifier) although it sort of works if you give it a \mathchardef token as it re-interprets the mathcode as a mathaccent. unicode-math changes the definition of \cdot (and most symbols) to be \let to the unicode character rather than a \mathchardef defined token, so it is not a valid ...


2

you could use ...\begin{quote}\linespread{0.9}\finob} ... to reduce the baseline spacing to 90% of its previous value within the environment, although if you reduce it too much (to less than the actual space taken by the characters in the font) then TeX will not preserve equal spacing, and lines with descenders or capitals or accented letters etc will ...


5

This has to do with the redefinition of \em performed by fontspec, which doesn't take into account the context, but only nesting of \em inside \em. The following workaround should work: \documentclass{article} \usepackage{fontspec} \usepackage{polyglossia} \usepackage{mathtools, amsthm} \usepackage{unicode-math} \setdefaultlanguage{english} \...


3

Sorry I fixed this earlier but it seems I never pushed the fix to the public distribution. You can extend the testing to be luatex aware as shown below. \documentclass{ltjarticle} \usepackage{luatexja} \usepackage{bm} \makeatletter \def\bm@test@token#1{% \let\bm@next\@empty \ifx#1\@@end \else\ifx#1\mathchoice \let\bm@next\bm@mathchoice \else\...


3

In many programming languages, it is possible to detect the name by which an executable is invoked. In C this is by examining the field args[0], in Bash this is given by $0, and in TeX a similar thing is \jobname (see, e.g. this answer). The program can thus be designed to behave differently depending on how it is called. An extreme example of this is ...


1

Not really an answer to your question but a comment to your "clarify why you need it". In one of my projects I used the standalone package too and also had to handle the problem that \input and \includegraphics needed different pathes if the master was compiled or if a child was compiled. The solution I implemented was to add in every folder a small config-...


3

The problem is triggered, if the redefinition of \mathchoice in package mathstyle meets LuaTeX's \mathstyle, from package mathstyle: \def\mathchoice{% \relax\ifcase\mathstyle \expandafter\@firstoffour % Display \or \expandafter\@firstoffour % Cramped display \or \expandafter\@secondoffour % Text \or \expandafter\@secondoffour % ...


5

To have the text font in math mode, you might want to use the mathastext package. To use this package with LuaLaTeX you also have to load fontspec with the no-math option. Because fontspec is loaded internally by Alegreya we do \PassOptionsToPackage{no-math}{fontspec} \usepackage[osf]{Alegreya} \usepackage[italic]{mathastext} Instead of saving and ...


1

It's not clear why using LuaLaTeX, but here it is. \begin{filecontents*}{\jobname.bib} @article{test, author={Günter Frö}, title = {Wörter}, journal = {Wörter in Österreich}, year = {2013} } \end{filecontents*} \documentclass{article} \usepackage[utf8]{luainputenc} \usepackage[T1]{fontenc} \usepackage[ngerman]{babel} \usepackage[ backend=biber, ...


5

You want to print using catcode table -2: all catcode 12 or 10: \documentclass{article} \IfFileExists{luatex85.sty}{\usepackage{luatex85}}{} \ifdefined\HCode% detect tex4ht \usepackage[utf8]{luainputenc} \usepackage[T1]{fontenc} \else \usepackage{fontspec} \fi \usepackage{luacode} \begin{luacode*} require 'lfs' -- first LUA function function ...


6

Hyphen character is made active by \ScriptEnv command, which means that it calls a command when it is encountered in the environment defined with it. The ScriptEnv definition is little bit cryptic: \bgroup \catcode`\-=13 \catcode`\(=1 \catcode`\)=2 \catcode`\/=0 \catcode`\{=12 \catcode`\}=12 \catcode`\\=12 /gdef/ScriptEnv#1(% /expandafter/...


5

The convertor from DVI to HTML doesn't support OpenType fonts, which is automatically selected when the Fontspec package is loaded. This is well known tex4ht bug and also one which is hardest to fix. There are two possible workarounds, both of them require modification of the document, unfortunately. First is to use conditionally luainputenc package: \...


4

If I compile the following example with LuaLaTeX from TeX Live 2015 \documentclass{beamer} \begin{document} \begin{frame} \begin{itemize} \item \'Angel \item Ángel \item Pedro Rodr\'{\i}guez \item Pedro Rodríguez \end{itemize} \end{frame} \end{document} I get which is expected. If I add also \usepackage[T1]{fontenc}, the output is but it is ...



Top 50 recent answers are included