using a basic version of MacTex, when building tex file on sublime, i got:
Errors:
/usr/local/texlive/2015basic/texmf-dist/tex/latex/fontspec/fontspec.sty:43: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! [ }]
my tex file:
documentclass{article} usepackage{fontspec} title{Title} author{me} begin{document} maketitle{} section{Introduction} This is where you will write your content. end{document}
Is there more of an error message you can provide?
Fontspec has recently been updated; you might want to try upgrading to the latest version if you haven’t already.
The row of !!! makes me suspect you are seeing a truncated message, the full text of which is
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Fatal fontspec error: "cannot-use-pdftex"
!
! The fontspec package requires either XeTeX or LuaTeX to function.
!
! You must change your typesetting engine to, e.g., "xelatex" or "lualatex"
! instead of plain "latex" or "pdflatex".
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
in which case, the problem is that you are using pdflatex (or latex) rather than xelatex or lualatex.
I think you are right about truncated message, in fact, line 41 in fontspec.sty is msg_fatal:nn {fontspec} {cannot-use-pdftex}.
However, I’ve changed the typesetting engine from
pdflatex = ["pdflatex", "-interaction=nonstopmode", "-synctex=1"]
to
pdflatex = ["xelatex", "-interaction=nonstopmode", "-synctex=1"]
in sublme latex building file already.
pressed the wrong button, sorry…
If fontspec thinks it’s running under pdflatex then my guess is that it is, I know nothing about sublime but can you check the first line of the log file from your document
It should say (modulo version/time differences)
This is XeTeX, Version 3.14159265-2.6-0.99991 (TeX Live 2014) (preloaded format=xelatex 2014.7.15) 29 JUL 2015 14:58
not
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex 2015.1
you are right, again.
the first line of the log file says:
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015) (preloaded format=pdflatex 2015.7.29) 29 JUL 2015 21:24
so I guess it’s a sublime issue rather than fontspec?
so I guess it’s a sublime issue rather than fontspec?
Definitely not a fontspec issue (in this case).
I’ve figured it out in sublime building file, not a fontspec issue indeed
Hi @Cescfangs,
I’m having the same issue here. How did you solve it?
@totuta I’am really sorry for the late reply, no matter what you use(Sublime Text for me) to build tex when involving fontspec, always be sure you use XeTeX or lualatex instead of «latex» or «pdflatex», for me, I simply modified building settings in Sublime and restart.
hi. how can i change typesetting engine from Pdflatex to Xetex on linux?
Hi. Use preferences (or anything on your editor) to set the Default Compiler to your choice.
Hi. Use
preferences(or anything on your editor) to set theDefault Compilerto your choice.
Hi, I have set from PdfLaTex to XeLaText in ‘Default Compiler’, but it still didn’t solve the problem and then I checked the first line of the log file from my document which is ‘This is pdfTeX…’ instead of ‘This is XeTeX…’
Содержание
- Error when using fontspec #204
- Comments
- XeLaTex and TexMaker «cannot-use-pdftex»
- 2 Answers 2
- Use XeLaTeX in Texmaker instead of pdfLaTeX
- 1 Answer 1
- LaTeX.org
- LaTeX.org on Twitter — follow us
- LaTeX forum ⇒ Document Classes ⇒ preamble not working for a new document
- preamble not working for a new document
- preamble not working for a new document
- preamble not working for a new document
- preamble not working for a new document
- preamble not working for a new document
- preamble not working for a new document
- LyX cannot output to pdflatex for a specific file
Error when using fontspec #204
using a basic version of MacTex, when building tex file on sublime, i got:
The text was updated successfully, but these errors were encountered:
The row of . makes me suspect you are seeing a truncated message, the full text of which is
in which case, the problem is that you are using pdflatex (or latex) rather than xelatex or lualatex.
I think you are right about truncated message, in fact, line 41 in fontspec.sty is msg_fatal:nn .
However, I’ve changed the typesetting engine from
pdflatex = [«pdflatex», «-interaction=nonstopmode», «-synctex=1»]
to
pdflatex = [«xelatex», «-interaction=nonstopmode», «-synctex=1»]
in sublme latex building file already.
pressed the wrong button, sorry.
If fontspec thinks it’s running under pdflatex then my guess is that it is, I know nothing about sublime but can you check the first line of the log file from your document
It should say (modulo version/time differences)
you are right, again.
the first line of the log file says:
so I guess it’s a sublime issue rather than fontspec?
so I guess it’s a sublime issue rather than fontspec?
Definitely not a fontspec issue (in this case).
I’ve figured it out in sublime building file, not a fontspec issue indeed
I’m having the same issue here. How did you solve it?
@totuta I’am really sorry for the late reply, no matter what you use(Sublime Text for me) to build tex when involving fontspec, always be sure you use XeTeX or lualatex instead of «latex» or «pdflatex», for me, I simply modified building settings in Sublime and restart.
hi. how can i change typesetting engine from Pdflatex to Xetex on linux?
Hi. Use preferences (or anything on your editor) to set the Default Compiler to your choice.
Hi. Use preferences (or anything on your editor) to set the Default Compiler to your choice.
Hi, I have set from PdfLaTex to XeLaText in ‘Default Compiler’, but it still didn’t solve the problem and then I checked the first line of the log file from my document which is ‘This is pdfTeX. ‘ instead of ‘This is XeTeX. ‘
Источник
XeLaTex and TexMaker «cannot-use-pdftex»
I would like to use the CV template provided by this link.
In the .tex file 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
-> Now I can compile. Another error came out:
EDIT 2 I installed texlive-lang-italian package
Now the error is:
! Font XeTeXLink@font=pzdr at 0.00002pt not loadable: Metric (TFM) file or ins
2 Answers 2
The package required to compile using XeLaTeX was not installed on my linux ditribution. Solved with:
If you compile with XeLaTeX and have the Fontin fonts installed on your system it works fine after some modifications to the preamble and the very beginning of the file.
The main modifications consisted in deleting some obsolete options or packages, and the fb switch-font command defined just after begin; re-defining it with fontspec and using Latin Modern rather than Computer Modern since the former exists in Opentype format.
Источник
Use XeLaTeX in Texmaker instead of pdfLaTeX
I use TeX Live 2010 and my editor is Texmaker Bidi. It was working probably good but from 2 months ago I’ve encountered with the error:
when I’m trying to load xepersian LaTeX. but I do not know how can I change pdfLaTeX to XeLaTeX.
This is the second edit of my question . the code is :
but the output does not include the shapes .
1 Answer 1
Added Update to the existing answer:
For those using Texmaker Version’s > 3.5.1
From Texmaker Version 3.5.1 onwards xelatex support has been added . Download Latest version of Texmaker: 4.1.1 dated Jan 3 2014 that has xelatex support in standard commands like shown below.
xelatex has been added to the standard commands (with a new «quick compilation» mode : xelatex + view pdf)
Hence there might be no need of Configuring Texmaker for xelatex with `User Commands.
Note: From Texmaker Version 4.1 onwards LuaLaTeX support also has been added
For those using Texmaker Version’s 3.5
You will have to define a custom command in Texmaker — it’s fairly simple.
Open the User → User Commands menu and select Edit User Commands. This will bring up a dialog box like so:
Add a menu item name and set the command to xelatex %
Hit okay and you will now be able to run the newly created command from the User → User Commands menu or by hitting alt-shift-Fn where n is the number of the command. So, for instance, alt-shift-F1 will run the command I have defined here. This may be Windows specific. It will also appear on the build menu in the toolbar, underneath everything else.
Источник
LaTeX.org
We love good questions
LaTeX.org on Twitter — follow us
LaTeX forum ⇒ Document Classes ⇒ preamble not working for a new document
preamble not working for a new document
Post by josephcampbell » Wed Sep 26, 2018 5:36 pm
I was using this preamble and I wanted to use it again for my next document. It works for my previous document but now that I want to make a new, empty document it is not working. I will paste my entire code below. Whats wrong with it?
Recommended reading 2021:

preamble not working for a new document
Post by Stefan Kottwitz » Wed Sep 26, 2018 7:03 pm
posting the entire code makes testing easy, thanks!
You need to compile with XeLaTeX, but I guess you are already doing it.
The only issue here is that both wasysym and amsmath/amssymb define integral symbols with the same name. You can fix it, preferring amsmath integral symbols, by adding the [nointegrals] option to wasysym:
preamble not working for a new document
Post by Johannes_B » Wed Sep 26, 2018 7:06 pm
Package wasysymb defines a symbol which is also defined by package amsmath, which is loaded by several of your packages. Easiest solution would be not to load package wasysymb. Chances are pretty high, you don’t need it.
Same goes for many of the other packages you load. Are you sure you really need them? Some are obsolete for over twenty years.
preamble not working for a new document
Post by josephcampbell » Wed Sep 26, 2018 8:28 pm
I got ride of wasysymb entirely, but my code is still not working. I am using overleaf.com. Here is my code now.
preamble not working for a new document
Post by Stefan Kottwitz » Wed Sep 26, 2018 8:33 pm
please post error messages or details.
Specifically, the code is working, also with Overleaf. Click on «Open in Overleaf» in the code box above. (please mark code using the code button — mark, click — that produces the code box in the post with syntax highlighting and Overleaf link). It shows that it works on Overleaf.
preamble not working for a new document
Post by josephcampbell » Thu Sep 27, 2018 5:21 am
I get an error message that looks exactly like this. I am confused because this exact preamble works for other documents.
Источник
LyX cannot output to pdflatex for a specific file
A friend gave me a copy of his thesis template (which works for him), but when I try to use it myself, most of the LaTeX ‘view’ options are grayed out:
Strangely enough, the options aren’t grayed out for any of my other documents, and I can compile all of my other files (including, for example, the LyX documentation files).
I have tried Reconfiguring and restarting, but it makes no difference, which is not surprising given that if I have my own files open in different tabs of the same instance of LyX, they can still be viewed.
He does use a custom layout and style in his document, which is included in the same directory. However if I switch the document class to the standard Book class, the view options remain grayed out — although there is a warning then that some of his custom environments are not found in the new layout, so that might be causing problems as well.
He includes a number of chapter lyx files inside the main document, they’re all accessible, but they suffer from the same problem.
@Torbjørn-T Your comment was correct, and after making the chance I can now attempt to render to pdflatex.
Following on from @scottkosty’s comment, when I try to render any of the files that are using my friend’s (apparently faulty?) style/layout files, I get the message «Error while exporting format: PDF (pdflatex)» in the status bar, but no dialog boxes. In the message pane, it says the following:
When I execute «pdflatex minimal.tex» from the lyx buffer directory in /tmp, I get the same output (up to the Babel line) and exit code.
I’ve managed to cut the offending file down to the barest minimum (just «foo» in Standard mode, but using the custom layout) and it’s still happening, so it’s almost certainly some problem with his custom layout/style, which I’m still teasing out. Still, LyX should probably give a dialog saying that pdflatex failed with no output, rather than only flashing an error in the status bar.
Okay, I figured out what it was: the custom .sty was using usepackage , and if you remove the batchmode in the resulting .tex file, it gives this error when you run pdflatex:
which is all fair enough. Here is a minimal lyx document that reproduces this — it’s a brand new, empty lyx file with usepackage in the preamble.
Источник
I’m trying to use the font Arial in my document and convert from markdown to latex. I included the following in my latex template:
usepackage{fontspec}
setmainfont{Arial}
This works and changes the font to Arial when I use it normally, but when I use Pandoc to convert to PDF, I get the error:
Error producing PDF.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! Fatal fontspec error: "cannot-use-pdftex"
!
! The fontspec package requires either XeTeX or LuaTeX.
!
! You must change your typesetting engine to, e.g., "xelatex" or
! "lualatex"instead of plain "latex" or "pdflatex".
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................
l.28 msg_fatal:nn {fontspec} {cannot-use-pdftex}
It says that the package requires XeTeX or LuaTex. I’ve tried many things to change the font to Arial, but nothing so far has worked.
I use OS X.
asked Apr 30, 2018 at 1:10
0
To use LuaTex when creating a pdf with Pandoc:
pandoc test.txt --pdf-engine=lualatex -o test.pdf
Apply accordingly for XeTex:
pandoc test.txt --pdf-engine=xelatex -o test.pdf
From the Pandoc Manual:
—pdf-engine=pdflatex|lualatex|xelatex|wkhtmltopdf|weasyprint|prince|context|pdfroff
Use the specified engine when producing PDF output. The default is
pdflatex. If the engine is not in your PATH, the full path of the
engine may be specified here.
Have a look at the Demo Section of the manual — most use cases are covered there.
answered Apr 30, 2018 at 8:19
rktarkta
3,6867 gold badges27 silver badges36 bronze badges
2
Emacs LaTeX mode quick start guide
We are trying use AUCTEX. Apparently AUCTEX mode is given by):
and shows as LaTeXP in when we do C-h m.
Emacs hooks are based on commands like this:
(add-hook 'LaTeX-mode-hook 'linum-mode)
Run emacs
C-c C-c and then followed by typing *mk so that it “compiles” with
LaTeXmk. C-c C-a does everything without any prompt.
Folding
Tab does folding.
Keybindings
C-c C-e –> add environment
C-c ret –> add macros such as item etc…
Error fontspec cannot use pdf-tex engine
ERROR: Fatal fontspec error: "cannot-use-pdftex"
--- TeX said ---
!
! The fontspec package requires either XeTeX or LuaTeX.
!
! You must change your typesetting engine to, e.g., "xelatex" or
! "lualatex"instead of plain "latex" or "pdflatex".
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
Please add the following to the end of the file and reopen it.
MUST REOPEN THE FILE, THESE THINGS ARE READ ONCE AT THE BEGINNING
C-x C-v.
From here.
%%% Local Variables:
%%% coding: utf-8
%%% mode: latex
%%% TeX-engine: xetex
%%% End:
Check version of auctex by
C-h v AUCTEx-version
Another possibility
https://tex.stackexchange.com/a/26387/97901
(setq-default TeX-engine 'xetex)
(setq-default TeX-PDF-mode t)
in the init file. NOT TESTED!
Goal
I would like to write my resume and cover letter in Emacs. With this
post I want to log what all I did to setup Emacs and how to get Latex
working.
I would I ideally want a pdf on the right (within or not within
Emacs), and left side to have the text.
How to easily install auctex?
How to manage packages within auctex?
How to display the pdf output?
how do make a simple document with hello world.
Info
The AUCTeX package provides more advanced features for editing TeX
and its related formats, including the ability to preview TeX
equations within Emacs buffers. Unlike BibTeX mode and the RefTeX
package, AUCTeX is not distributed with Emacs by default.
AUCTeX also provides auto-completion for TeX commands.
AUCTeX provides some LaTeX specific commands which you should learn,
make sure to checkout the commands for creating macros, C-c Enter,
and environments, C-c C-e, LaTeX-math-mode and the RefTeX commands
for inserting citations and cross-references
Apprently there is this thing called YASnippet as described in
Working with templates.
Compiling
When it comes to compiling you can use latexmk as described above but
you can also use AUCTeX built-in compiling method which is quite good
(C-c C-c). To view the output of the current buffer simply do C-c
C-v.
Latex for linux
I started with this simpletons guide, which was not
really simple.
If you’re using a distro which packages LaTeX (almost all will do)
then look for texlive or tetex. TeX Live is the newer of the two, and
is replacing tetex on most distributions now. -stack
Latex for linux stack website suggests the use of texlive
package. This allows for the use of latex in all its glory. There are
different packages/types of installations such as:
texlive-full
texlive-latex-base
texlive-latex-extra
texlive-latex-recommended
texlive-generic-extra
texlive-full probably has everything. texlive-latex-base contains
essential packages and so on.
You can always just start with texlive-latex-base and then just
install the collections you need. (To find a collection with a
package in useapt-cache search pacakge) There is no good way yet to
install individual packages in Ubuntu, astlmgrwill run in user mode
(installing packages only for one user). — stack
Point being that I might run into problems later if I need this for
more than one user. Unlikely to be my case. If that is what happens
then I can always remove and install the full thing. For now I see
this as an opportunity to understand and install what I need, to get
knowledge regarding this.
So I think I did
sudo apt-get install texlive-latex-base
To check if a package is installed use
apt list --installed texlive-latex-base
output:
texlive-latex-base/xenial-updates,xenial-updates,xenial-security,xenial-security,now 2015.20160320-1ubuntu0.1 all [installed]
N: There is 1 additional version. Please use the '-a' switch to see it
Configuring emacs to work with AUCTeX
How this whole thing will look is shown as in the video here, it is a good start to
get a feel of what is happening!
Apparently you need latexmk
sudo apt-get install latexmk
But it is a package in emacs? I thought and I removed it along with
dependencies using
sudo apt-get purge latexmk
sudo apt-get purge --auto-remove latexmk
But it turns out you need latexmk (latex make)
LatexMk is a Perl script for running LaTeX the correct number of
times to resolve cross references, etc; it also runs auxiliary
programs (bibtex, makeindex if necessary, and dvips and/or a
previewer as requested) — emacswiki on latexmk
So I don’t know any more about it other than that it is needed for
something and everyone seems to be using it. In case I had bib or
something, it would take care of running Latex the necessary number of
times.
So
sudo apt-get install latexmk
Add to init file based on the git repo. Install auctex-latexmk
and then
(require 'auctex-latexmk)
(auctex-latexmk-setup)
In the case of my init file this is accomplished by adding
auctex-latexmk to the list of packages to be installed and then
adding (auctex-latexmk-setup) to the packages-init.el.
Running emacs
This seems to be the basic setup that you need to type C-c C-c and
start with latexmk to make all the necessary files. And then C-c with
C-cView to display PDF. Viewing is only done once to open a PDF.
souce
Hooks
-
Line number
(add-hook 'LaTeX-mode-hook 'linum-mode) -
folding
(add-hook 'TeX-mode-hook (lambda () (TeX-fold-mode 1))); Automatically activate ; TeX-fold-mode.
There are a lot of hot keys to remember if you want to fold using
TeX-mode-hook as mentioned here
-
folding like
org-modewithoutline-minor-modeorLatex-extra
as explained here(add-hook ‘LaTeX-mode-hook #’latex-extra-mode)
(add-hook ‘LaTeX-mode-hook #’outline-minor-mode)
The keybinds it defines are a little hard to use for outline-minor-mode, so you might want to change some of them.
C-c @ C-a show-all
C-c @ C-c hide-entry
For Latex-extra
Similar to how org-mode hides and displays of subtrees, if you hit
TAB on a section header latex-extra will hide the contents of that
section for you. Hitting tab twice will expand it again. This will
not interfere with whatever with other keybinds you have set for TAB,
such as yasnippet or auto-completion. Shift-TAB will do the same for
the entire buffer. Of course, the same goes for chapters,
subsections, etc.
This is what I want!
preview-latex
AUCTeX already comes with preview-LaTeX apparently. The power of
it can be seen in this video. It apprently can preview within the
editor how say equations will acutally look, how plots will actually
look.
Info- engines/ compilers
Engines: TeX, pdfTeX, XeTeX, LuaTeX, … These are the actual
executable binaries which implement the different TeX dialects. The
LaTeX format is implemented with both the pdfTeX (pdflatex) and
XeTeX (xelatex) engines, for example. When someone says “TeX can’t
find my fonts”, they usually mean an engine.
Formats: LaTeX, plain TeX, pdfLaTeX, … These are the TeX-based
languages in which you actually write documents. When someone says
“TeX is giving me this mysterious error”, they usually mean a
format.At a high level, the output format that gets used depends on the
program you invoke. If you run latex (which implements the LaTeX
format), you will get DVI; if you run pdflatex (which also
implements the LaTeX format), you will get PDF.
pdflatex is a terminal command that tells the pdfTeX engine to use
the LaTeX format.
— stack
According to the source mentioned below, you can choose engine by
M-x customize-variable RET
TeX-engine RET
Also you can check which engine is being used now:
Source
Diff type of engines and meanings and usage in emacs
Source
How to choose other engines/compilers
Resume
1 page academic CV’s
https://www.quora.com/What-are-some-elegant-serious-LaTeX-templates-for-an-academic-CV
Widely known 1 column CV 1 page
MIT format
https://github.com/sb2nov/resume
Error handling with latexmk
Dealt with as and when the need arises! After a compile if you get errors.
Look for error online and then go
finding things in a package
On http://packages.ubuntu.com/ you can search for packages containing
some file.
Source
Instead of using the website it is also possible to do it in the
terminal
apt-file find kpfonts.sty
Check if the suggested package is already installed
apt list --installed texlive-fonts-extra
If not install it.
sudo apt-get install texlive-fonts-extra
Package missing
-
marvosymmissing,sudo apt-get install texlive-fonts-recommended
Source
-
fonstpec.stynot foundFound that it was in
texlive-latex-recommendedfrom
http://packages.ubuntu.com/. and installed it.apt list --installed texlive-latex-recommended sudo apt-get install texlive-latex-recommended -
At this point I get an error :
“Latex: problems after [0] pages”
No use searching online. So I changed to luatex with C-h v and then I got these and followed the same way as above.
TeX-engine
-
luaotfload.styis missinginstalled
texlive-luatex -
xunicode.styis missinginstall
texlive-xetex??? but it worksSource
No PDF display
So usually when you hit C-c C-c the second time you will see the
View: TeX-evince-sync-view or something very similar. But I saw some
.dvi stuff written. PDF did not get updated except that it got
created the first time. but that is that. What helped–and I don’t
know why– is this stack answer. Jesus man I don’t know WTF if
happening but it helped.
With the latest version of AUCTeX, if should be sufficient to
customize the variable TeX-PDF-from-DVI as described in the
manual. Try M-x customize-variable RET TeX-PDF-from-DVI RET , click
on Value Menu and choose dvips — ps2pdf sequence, hit Apply and Save
and you should be done.
documentclass[10pt,a4paper]{article}
begin{document}
foobar
end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% TeX-PDF-mode: t
%%% TeX-PDF-from-DVI: "Dvipdfmx"
%%% End:
There is some explanation but the thing is if you do C-c C-c
repeatedly all is good, PDF works and everything displays as
expected. Or just to C-c C-a.
Peace
bib
Currently I have nothing setup for it. Read here for more info:
https://tex.stackexchange.com/questions/25701/bibtex-vs-biber-and-biblatex-vs-natbib
*.bib file is what we need with the bib info which is then converted
by Latex appropriately with the appropriate commands!
Reflection
I probably spend too much time just trying to understand things too
well (parkinsons law). I am making notes, if I have to do this
again. I suspect I might have to do this every 5 years once I loose
the LTS of ubuntu. I am trying to understand on a high level what
exactly I am doing. I suspect it to be useful in debugging and keeping
track of what I have done to my pc, adding packages and removing them
in case of conflicts as and when necessary. Learning in some sense,
just-enough and possibly also more than just-enough.
I look at these notes after 3 months and I feel like I am on track,
all knowledge is saved in a seemingly clear format to pick up
from. Although maybe I could regain this knowledge, but also I think
it is painful to search your ass off and start again.
References
Emacs-wiki
Guide to emacs, as stack question
auctex key-bindings
quick start to Auctex by GNU
AucTeX extension for TikZ
my init file / config
Appendix: What is memoir, beamer and tix
I see this word appearing now and then in the Guide to emacs, as
stack question, “memoir”. A quick investigation shows that it
is a document class which is more flexible in terms of chapter styles,
than ‘report’ or ‘book’.
Beamer is for creating powerful presentations.
Tikz is for creating graphics elements. Such as adding plot
details legends etc.. with data points or, even just creating and
drawing lines as necessary.






