Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I seem to have messed up the encoding of my tex document in TexShop and I wonder if anyone can explain to me what's going on?

I had a short document which was fine, until I needed to add some Japanese, so I added

%!TEX encoding = UTF-8 Unicode

at the top line and then

\documentclass[a4paper,12pt]{article}

% Packages
\usepackage{CJKutf8}

\begin{document}
\begin{CJK}{UTF8}{goth} % for gothic (sans serif) font
\CJKnormal

% Cite English reference
\cite{UK2013}

% Cite Japanese reference
\cite{Japan2012}

\bibliographystyle{custom}
\bibliography{references}

\end{CJK}
\end{document}

After doing this, all my backslashes changed to yen signs, and any backslash I typed came up in the editing window as a yen sign.

Now when I compile it has an error

"Missing \begin{document}"

and shows an error

DOT documentclass[a4paper,12pt]{article}

where DOT is literally a dot.

So it's clear that the backslashes have all been lost.

Can anyone explain to me what's going on with the encoding, and how I can fix it?

I am aware of XeTeX, but I heard that by adding lines from the package CJKutf8 as I have done above, it is possible to avoid having to install another huge Latex implementation just for the use of Japanese characters.

share|improve this question
    
Welcome to TeX.SX. Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. –  Claudio Fiandrino Feb 3 '13 at 14:25
    
To me this sounds very much like a problem TeXShop is having, as I am able to compile your source code without any problems. I have experienced that TeXShop somehow does not like you changing the file’s encoding afterwards (e. g. by adding %!TEX encoding = UTF-8 Unicode after you have saved it for the first time). One solution I have found is opening the corrupt file in an editor which lets you choose the file’s encoding in the opening dialog (TextWrangler, SublimeText 2, …) and then saving/exporting it again with the correct encoding. I am not sure if this answers your question ;) –  brian-ammon Feb 3 '13 at 19:21
1  
The change from backslash to the yen symbol seems to be characteristic of the Shift-JIS encoding. I tried changing the encoding in TeXShop, but I didn't succeed in reproducing the problem. –  egreg Feb 3 '13 at 21:08
1  
Thanks for the suggestions. Following your hints I switched from Texshop (to vim), and now there are no encoding problems. –  Tetsuo Feb 19 '13 at 8:22
    
FYI, XeTeX should already be included in your distribution, and would allow you to use much nicer Japanese fonts. Try changing the typesetting engine in TeXShop, or just add %!TEX TS-program = xelatex to your file header. –  erik Apr 11 '13 at 3:55
show 1 more comment

closed as off-topic by Joseph Wright Aug 6 '13 at 7:28

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.