If you are happy with experimenting a bit, I suggest to proceed as follows. Disclaimer: I don't have a dual boot machine, I kicked Windows off my Laptop years ago.
Install texlive under windows and test it. Then boot into Linux and start the installation of texlive. Cancel the installation process after some minutes. Now, you have a TDS compliant structure, but the content is missing. EDIT: Delete all files and folders inside /texlive/2014/texmf-dist/tex/latex and /texlive/2014/texmf-dist/doc (not in your Windows folder, I'm speaking only of the Linux side!).
Then make two links:
- link from .../texlive/2014/texmf-dist/tex/latex to C:/texlive/2014/texmf-dist/tex/latex
- link from .../texlive/2014/texmf-dist/doc to C:/texlive/2014/texmf-dist/doc
I don't know whether a hard link or a symbolic link, but as Linux has this link feature, I'd check this possibility. Maybe here are some geeks who know exactly how to set a link from a Linux folder to a NTFS folder somewhere else.
Why only those two links? Because the LaTeX packages and the documents make the lions share of the texlive.
OK. Then restart the installation under Linux. I hope that tlmgr will accept the link to your windows installation and then try to install every single package and documentation, but notices they are already there.
Recently I transferred all doc and latex files to another computer and that part (start installation, abort, transfer, restart) worked. But I have no experience with linking into a windows installation.
Of course, you have to install the linux packages for writing into ntfs. And maybe you ruin your texlive installation on windows, if the installer tries something unexpected. But if you make a backup of it, why not giving it a whirl.
Portable, and consistent solution
Fandol fonts are reliable portable fonts for typesetting Simplified Chinese in TeX.
Fandol fonts are not perfect: compared to the other commercial fonts, the character set of Fandol fonts is somewhat restricted, and the puncuations need to be tuned.
Luckily, Fandol is a complete series of Chinese fonts in OpenType format, and well designed for typesetting.
% !TEX program = XeLaTeX
% !TEX encoding = UTF-8
\documentclass[UTF8,nofonts]{ctexart}
\setCJKmainfont[BoldFont=FandolSong-Bold.otf,ItalicFont=FandolKai-Regular.otf]{FandolSong-Regular.otf}
\setCJKsansfont[BoldFont=FandolHei-Bold.otf]{FandolHei-Regular.otf}
\setCJKmonofont{FandolFang-Regular.otf}
\begin{document}
\begin{tabular}{|l|l|l|l|}
\hline
& \multicolumn{3}{c|}{Series/Shape} \\ \cline{2-4}
Family & \verb=\mdseries= & \verb=\bfseries= & \verb=\mdseries\itshape= \\ \hline
\verb=\rmfamily= & 宋体 & \textbf{粗宋体} & \textit{楷体} \\
\verb=\sffamily= & \textsf{黑体} & \textsf{\textbf{粗黑体}} & \\
\verb=\ttfamily= & \texttt{仿宋体} &&\\ \hline
\end{tabular}
\end{document}
The problem is, most Chinese fonts are expensive commercial ones, you simply have little choice for free Chinese fonts. And what's more, Fandol font bundle is the only choice preinstalled in TeX Live (or MacTeX, MiKTeX) if you use XeTeX or LuaTeX. Therefore, it is now the only portable way to typesetting Simplified Chinese documents in TeX.
Yes there are also Arphic fonts, but only subfonts for CJK
package in Type1 format are provided in TeX distributions. Only two families (gbsn
and gkai
) for Simplified Chinese, or two corresponding families (bsmi
and bkai
) for Traditional Chinese are provided by Arphic.
Some sort of fallback option for rare glyphs?
No. We don't have enough fonts available for that.
Now we have some good free fonts for large character sets. For example the Souce Han Sans fonts. But they are pre-installed neither in TeX distributions, nor in operation systems.
Something native?
Yes it is possible. In the developer version (ver 2.x) of ctex
package, we defined several different font sets, and the package will detect the operation system and select a native font set if you wish.
- SinoType fonts are automatically selected for Mac.
- ZhongYi fonts are automatically selected for Windows.
- Fandol fonts are automatically selcted otherwise. (No, we don't use the incomplete Arphic fonts as default fonts, let alone WenQuanYi.)
And we do provide options to select Arphic and WenQuanYi fonts (fontset=ubuntu
option), there are also options for Adobe fonts and Founder fonts.
Best Answer
Method 1--(Preferred Method)
Install the latest TeX Live
This is for if the package is in TeX Live and you want to or are using 'vanilla' TeXLive.
If you haven't yet installed TeX Live, follow the instructions at How to install "vanilla" TeXLive on Debian or Ubuntu? (these instructions apply to Linux systems in general, not just Debian-based ones).
How you install a package via TeX Live depends on whether you installed TeX Live as a single user or you installed it system-wide. If the first, try:
If the second, you will have a small problem in that
tlmgr
might not be in the path thatsudo
automatically searches. So you need to locate it first and usesudo
to call it with the full path. If your shell has thewhich
builtin, you can findtlmgr
using the commandwhich tlmgr
. Thus:If your shell allows you to use the output of a command as a sort of variable, you can use the following command to condense the above (where we exploit the fact that
which
returns a single instance of the command regardless of how many times it appears on the path):(You can test your shell with the less risky
echo $(which tlmgr)
: this should produce the same aswhich tlmgr
.)Method 2:
Find and install the package through your package manager.
This is for if you are using the version of TeX that came with your distribution and you don't mind particularly which version of the package you install.
Linux distributions tend to include TeX as a collection of packages, but it isn't usually on as fine a level as one TeX package equals one Linux package. You therefore need to find the right distribution package containing the TeX package that you want and install it. Different package managers have different methods of searching, if all else fails there is often a website where you can search for a specific file:
Method 3
Install manually
In this situation, you have two options: to install system-wide (all users on your system) or to install just for you. System-wide means that any user on your system will be able to use it, just for you means just that: it will only be installed for your account. The difference between the two is the base location:
kpsewhich -var-value TEXMFLOCAL
in the Terminal to find the right directorykpsewhich -var-value TEXMFHOME
in the Terminal to find the right directoryOne thing to note here is that in the case of a 'package clash', i.e., the same file is found in multiple places (such as the 'system' location, the 'local' location, and/or the 'individual user' location), only the first instance of the file will be used. In this case, the order of precedence is usually: individual user (
TEXMFHOME
) > local (TEXMFLOCAL
) > system. The full list (in the right order) can be determined by runningkpsewhich --var-value TEXINPUTS
.What happens now depends a bit on the package. If it is distributed in TDS then you are in luck. Go to the directory reported by
kpsewhich
, and into thetex
subdirectory (or create it if it does not exist). Then extract the TDS file (remember to usesudo
if globally, and check that yourumask
is set to022
). Note check the TDS file first to ensure that it will extract into the right place: you may need to move up or down a directory to get it to match.If it is not distributed in TDS, then there are two options: If the package is available from TeX Live, you can get the TDS packaged version from http://mirror.ctan.org/systems/texlive/tlnet/archive/.tar.xz, and unpack it into a temporary directory. In most cases it will contain subdirectories like tex, fonts, etc. Copy these to the TEXMF tree as decided above. In case it contains a directory texmf-dist or similar, it is a package that also ships some scripts or different things outside the texmf hierarchy, in this case it is the best to contact an expert. Finally, you can also download the package from CTAN or the original distribution channel, unpack it and then there might be instructions - in which case follow them - but the general pattern is pretty similar. If it is a LaTeX package, create a directory in
<base dir>/tex/latex/<package name>
for it and extract the files (.sty
plus perhaps.cls
, etc.) there. Documentation files go in<base dir>/doc/latex/<package name>
.If you installed it globally, you will now need to run
mktexlsr
(or equivalentlytexhash
) viasudo
. Ifmktexlsr
is not in the path thatsudo
searches, you will need to locate it. You can do:Or if your shell allows it:
This isn't necessary for local installations.
Method 4:
Point to it
This is for the case where you have a
.sty
or.cls
file which you don't want to install centrally, for one reason or another. For example, it may be specific to a particular project (for example an unusual journal style file), or it may be known to clash with other packages, or you may wish to keep it alongside the source files in a repository.As described above, the TeX family of programs consult a path when looking for input files, including
.sty
and.cls
files. You can override this with theTEXINPUTS
environment variable, which (on unix) consists of a sequence of directories separated by colons; TeX searches each of these directories in turn. Thus, if you had a.sty
file in a subdirectorystyles
, thenwould cause TeX to search for the file in that directory first.
Note the trailing colon: this is followed by an empty path element, which causes TeX to insert the standard search path in that position. Thus
TEXINPUTS=:styles
would cause TeX to search the standard path before the subdirectorystyles
.As above, you can use
kpsewhich
to check things are configured correctly.Notes and Supplementary
Note on
sudo
When you add TeX Live to your path, it will not normally be added to the path for the root user, so will not be visible using
sudo
. The methods above usewhich
to findtlmgr
, etc., from the 'normal user' path and pass the correct instruction tosudo
. This works with thebash
andzsh
shells: if you use another shell you may need to provide the full path totlmgr
instead.When running
sudo
, the environment used is a mixture of the superuser's and the local user's. As well as the path mentioned above, it is important to ensure that theumask
setting is sufficiently lax: a user should have aumask
of077
but root of022
. Theumask
controls the default permissions of newly created files: with077
only root would be able to read (and thus use) them. With022
, everyone can read (and possibly execute) them.If your system does not have
sudo
installed by default, it probably has it in its package repository. If not, see How universal is sudo? for alternatives.Note on
mktexlsr
andtexhash
To speed up its searching, the
kpathsea
library uses caches in the form of files calledls-R
in various directories. These contain all the files thatkpathsea
would find if it searched properly in that directory (obeying any recursive search directives). The files are recreated by themktexlsr
command (which is short for "Make TeX's ls-R files") which has to be run manually (by someone with write access to the directory, usually root - see the note on sudo) if it is needed. This command used to be calledtexhash
and that is still an alias for this command (technically, a symlink).Note on
kpsewhich
TeX uses the
kpathsea
library for finding its files. Where this looks depends on various variable which can be set in configuration files or by the user's shell. The list of directories thatkpathsea
searches in can be displayed by typingkpsewhich --var-value TEXINPUTS
. The output is a little condensed. The following attempts to clarify it a little:$PATH
)!!
it means that thels-R
file will be consulted instead of the filesystem.//
it will be searched recursively.Thus
means that
/usr/local/texlive/2012/texmf-dist
and/usr/local/texlive/2012/texmf-var
will both be searched, in that order. Both will actually use the cache which is stored inls-R
in the base of the search (thus/usr/local/texlive/2012/texmf-dist/ls-R
, for example). And both searches will be recursive.Testing the Installation
The simplest way to check that the installed file is being found is to run
(where
<package_name>
includes the extension). If this lists the newly installed file, all should be fine. If it doesn't but does display something then it may be that there is another version of this package installed which is being found first. If that is the case, thenwill list all of the matching names so you can test to see if it is finding it at all.
If it did find it but isn't using it, you will either have to choose a location which is searched earlier than the version that is being found or remove the version(s) that are being found first.
If it did not find it at all, there are some possible reasons.
If you did a full installation of TeX Live, is the
kpsewhich
command from the new installation? Trywhich kpsewhich
to find out. If not, adjust your$PATH
and try again. (If your path is correct, it might be that your shell hasn't noticed it: tryrehash
to correct this (Bourne-Again Shells)).If you only installed a package, did you put it somewhere that TeX can find it? The full list of directories in which TeX searches can be found by running
These are searched recursively.
If it is in a directory that TeX searches, and that directory is prepended in the list by
!!
then it is one where TeX consults the cache, not the actual files on the disc. To recreate the cache, runmktexlsr
ortexhash
as super-user.Dependent packages
If you do not use the package manager to install TeX or one of its packages (i.e., you didn't use Method 1), then the package manager will not know that what you have just installed is installed. This means that installing system packages that depend on these manually installed packages will try to install them again. The simplest solution is to let them do so as it is usually the case that your manually installed things are found before the system ones. If space is tight, many distributions have "dummy" packages that can be installed to trick the package manager. See How to install "vanilla" TeXLive on Debian or Ubuntu? for more details.