First of all, what's the difference between utf8 and utf8x in
\usepackage[utf8]{inputenc}
\usepackage[utf8x]{inputenc}
when used in LaTeX?
Secondly, what packages are required when writing an article in Icelandic using LaTeX? I found:
\usepackage[icelandic]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
after experimenting a bit but I have a feeling some part of the code may be redundant. And even with them the aforementioned packages, the code inside
\begin{lstlisting}
...
\end{lstlisting}
isn't rendered with Icelandic characters when outputted through pdflatex in Ubuntu, although it works on my friend's computer (who's running Debian). What's missing?
[UTF8] is "supported" by the LaTeX team and covers a fairly specific/limited range of unicode input characters. It only defines those symbols that are known to be available with the current font encoding.
[UTF8x], AFAIK, is no longer supported, but covers a much broader range of input symbols. I would recommend only trying it if [UTF8] doesn't do what you need.
Secondly, the listings package (and most other related packages that do character scanning) does not support UTF8 input. (If it's working on a friend's machine they must be using an 8-bit input encoding instead.) The listingsutf8 package provides a UTF8-compatible replacement for \lstinputlisting but not for the main lstlisting environment. Using XeLaTeX might help you here, however.
Related
I am typesetting a LaTeX document with some Greek symbols, using the xelatex engine.
For some reason, the \chi command creates a different symbol than I would expect:
versus
They are close, but not exactly the same, and I would like to obtain the second.
Is there a special package that I should invoke?
Thanks in advance for any hint,
Adrian
Remove any font changing packages from the preamble.
In this case it turned out that the offending one was mathptmx.
I'm trying to build a service that accepts some string with LaTeX formatting and then returns a string with the LaTeX bits as pngs, or whatever else.
So, the idea is:
client sends a request containing: the point is that $sum_{n=1}^5 f(x)$ is a good estimate
server sends back the string: the point is that FORMULAS_HERE is a good estimate
I really have no idea where to begin getting the LaTeX converted. Naively, I assume I would just parse out the LaTeX bits and then do something to get a png/jpeg/etc... and then insert that into the response.
Googling around really reveals minimal information.
Currently, my simple server is built on node, but that's not really important. I can change languages if there's some magic solution out there. I honestly wish I could magically transform LaTeX into unicode and have it be perfectly seamless.
Question: How do I handle LaTeX on the server side?
- The goal is to then spit it back to the client so the text can be inlined relatively naturally (i.e. I could text my buddy Hey, what if $\chi(n)$ was considered independently? and it would be received formatted on the other end without begin a weird big picture blob).
Any advice on just a direction or set of packages/technologies/etc.. would be useful here.
Prepare your latex document with math and convert it using the excellent open-source ImageMagick
pdflatex formula.tex
convert -density 300 formula.pdf -quality 90 formula.png
The convert command used above is one of the ImageMagick tools. See documentation and numerous online resources for many options. The software has versions for all major platforms.
The input latex file should be prepared so that there is no background, margins, etc. For discussion of how to do that, see this post, and the source for it. The example above ultimately comes from there.
This is one way to write the formula.tex file used above, from the linked source.
\ifdefined\formula
\else
\def\formula{E = m c^2}
\fi
\documentclass[border=2pt]{standalone}
\usepackage{amsmath}
\usepackage{varwidth}
\begin{document}
\begin{varwidth}{\linewidth}
\[ \formula \]
\end{varwidth}
\end{document}
There are other converters out there but you need not bother if you can use this.
I have to mention MathJax. It runs in a browser, via one-line JavaScript snippet. Should you ever migrate to a browser/mobile service this would be a perfect solution. Here is their one page tutorial.
I'm currently trying to save a stress vs. strain curve using Octave. On this plot, I want to include text showing the equation for calculating engineering stress and engineering strain. Both of these require greek letters (\sigma and \epsilon respectively) as well as subscripts for the formulae.
Currently, using print with -deps, -dpng, or any other device, it creates a file, however the greek letters appear as the words "sigma" and "epsilon", and wherever I have a subscript, such as 0, it just appears as "_0". This looks very unprofessional.
Since I'm generating some 25 graphs, I don't want to have to go through and do a screenshot for each one. Does octave support saving the generated figure as displayed? I intend to use the generated files in a LaTeX document later (preferably as png so I can email them separately too).
I've also tried changing the "graphics_toolkit" option between fltk and gnuplot however it doesn't seem to help.
Attached to this post is a screenshot of the desired results and the actual results.
I am currently "not allowed" to post images, so I'll link them:
http://i.imgur.com/Tjt5Ecn.png (screenshot, desired result) and http://i.imgur.com/SP3hekd.png (directly saved, actual result)
Does anyone know a good way to print a figure from Octave which includes greek characters and subscripts in the titles?
Since you plan to use your graph in a Latex document, generating the graphs with -depslatex and converting them to pdf is a good idea . (Results look slightly better than direct -dpdflatex).
With -depslatex, you can include Latex code in your figures that will be written to a separate tex file.
Note that you need to use double backslashes \\ to export a single backslash.
graphics_toolkit("gnuplot");
...
legend("$\\varepsilon$");
print(sprintf("graph%s_%d.eps", name, type), '-depslatex', '-S200,270', '-F:9');
system(sprintf("epstopdf graph%s_%d.eps", name, type));
On the Latex side, you then \input the tex file generated by Octave. On the plus side, since you need 25 graphs, you can automatize this process on both sides Octave and Latex.
\newcommand{\mygraph}[1]{%
\graphicspath{{./figures/}}
\resizebox{0.495\linewidth}{!}{\relscale{1.0}\small%
\input{./figures/#1.tex}
}%
}
\mygraph{graph1_1}
Here, a Latex command \mygraph is defined to scale and include a figure located in a subfolder.
(I am using Octave 4.0.0 with gnuplot 4.4 on Ubuntu 12)
I want to make the angstrom symbol in my r markdown document. Normally in latex you can just do \AA for the angstrom symbol. However, I am trying the simple $\AA$ in my r markdown file and it is not rendering. I have tried \AA{}, \Aa, \aa, and
$$
\AA
$$
as well with no luck.
UTF8 has the angstrom, the font is problematic though.
Another approach is to use overset.
These are not perfect as LaTeX, but still acceptable (at least for me).
$$1Å=10^{−10}m$$
$$1\overset{\circ}{A}=10^{-10}m$$
The rmarkdown package uses Pandoc, which in turn uses MathJax, to render math expressions in HTML. It is known that \AA does not work in MathJax (at least at this moment); see its issue #795, and you will also see alternative approaches there.
You can write the Unicode for angstrom, but you have to convert to decimal from hex. The hex for angstrom is 212B, so this is 8491 in decimal. Thus Å will work
You could inline unicode into R Markdown using asis_output :
# Inlined unicode - Angstrom : `r knitr::asis_output('\U212B')`
I develop it to fit this
$\overset{\circ}{\mathbb{C}}$
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Does LaTeX handle situation when a .bib file has different encoding than .tex file? For instance, .tex is in ISO-8859-2 and .bib in UTF-8. Can the encoding be converted on the fly by LaTeX? Or the only way is to do is manually?
First of all, according to the LyX wiki BibTeX can't use UTF-8:
BibTeX does not support files encoded in UTF-8 (i.e., Unicode), which is nowadays the default file encoding on most OSes. The reason is that current BibTeX (v. 0.99c) was released in 1988 and thus predates the advent of unicode. Unless the long-announced BibTeX v. 1.0 or one of the many planned potential successing applications are ready, latin1 (ISO-8859-1) or another 8-bit encoding has to be used for the bib file (this does not affect the LaTeX encoding, which still can be utf8).
Usually, whatever is inside a BibTeX file gets copied verbatim to the LaTeX source code (with some formatting maybe and case changings, &c.), such as book titles, authors, &c.
So your BibTeX file encoding has to match the one used by your LaTeX file, otherwise things get funny. You also can't use babel-provided commands in BibTeX (such as "a for ä, provided by n?german) unless your document includes the right packages.
The canonical way is to make BibTeX files agnostic of any encoding or package issues by always specifying special characters with their appropriate commands.
This basically means that instead of writing ä you would have to use {\" a} if you want to be absolutely sure that it works. Seems to be fairly standard practice.
The BibTeX manual BibTeXing by Oren Patashnik also details this:
BibTeX now handles accented
characters. For example if you have an
entry with the two fields
author = "Kurt G{\"o}del",
year = 1931,
and if you're using the alpha
bibliography style, then BibTeX will
construct the label [Göd31] for this
entry, which is what you'd want. To
get this feature to work you must
place the entire accented character in
braces; in this case either {\"o} or
{\"{o}} will do. Furthermore these
braces must not themselves be enclosed
in braces (other than the ones that
might delimit the entire field or the
entire entry); and there must be a
backslash as the very first character
inside the braces. Thus neither
{G{\"{o}}del} nor {G\"{o}del} will
work for this example. This feature
handles all the accented characters
and all but the nonbackslashed foreign
symbols found in Tables 3.1 and 3.2 of
the LaTeX book. This feature behaves
similarly for "accents" you might
define; we'll see an example shortly.
For the purposes of counting letters
in labels, BibTeX considers everything
contained inside the braces as a
single letter.
You can change the input encoding on the fly:
\inputencoding{latin2}
\bibliography{mybib}
\inputencoding{utf8}
The \inputencoding command is provided by the inputenc package.
BibTeX has huge problems with non-ASCII characters, even in the newest version. If you prefer a modern system, I'd like to recommend the combination of biblatex and biber. Both are still in beta stage, but they work quite well even in production environments. With this combination, most problems related to LaTeX bibliographies will vanish. As a side note, the biblatex documentation also contains a section about encoding issues with traditional BibTeX (§ 2.4.3).
Bibtex has random support for any non-standard character encodings -- essentially sometimes it works, most of the time it doesn't and officially it is not supported (More details ).
Personally, in .bib, I stick to the basic ASCII and LaTeX magic like \"o. For .tex, if I don't write in English, I keep .tex in UTF-8 with \usepackage[utf8]{inputenc} .