inputenc 的首字母缩写在 latin10 和 utf8 之间变化

inputenc 的首字母缩写在 latin10 和 utf8 之间变化

[编辑] 完成 OK MWE

这是mwe.dtx

% \iffalse    (METACOMMENT)
%%
%% ---------------------------------------------------------------------
%%
%% Document class `mwe' to use with LaTeX 2e.
%%
%% ---------------------------------------------------------------------
%%
% \fi
%
% \CheckSum{419}
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
% ^^A \MakeShortVerb{\|}
% \section{Internals}
%
%    \begin{macrocode}
%<class>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%    \end{macrocode}
%
% \iffalse (Don't show this in the doc).
%<*driver>
         \ProvidesFile{mwe.drv}
%</driver>
% \fi
%    \begin{macrocode}
%<class>\ProvidesClass{./mwe}
        [2012/05/24 v1.0
%<class>        A mwe class]
%    \end{macrocode}
% \iffalse (Omitted from the doc)
%<*driver>
]
%</driver>
% \fi
%
% \subsection{Driver for this document}
%
% This program will extract the following driver from this file:
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
%\DisableCrossrefs % Say \DisableCrossrefs if index is ready
\RecordChanges
%\OnlyDescription % Comment out for implementation details
\CodelineIndex
\begin{document}
  \DocInput{mwe.dtx}
\end{document}
%</driver>
%    \end{macrocode}
% \begin{macro}{\my@op@n}
% \begin{macro}{\my@s@ut}
% \begin{macro}{\protected@write@immediate}
% \begin{macro}{\immediateaddtocontents}
% \begin{macro}{\addtocontentsline}
% \begin{macro}{\my@readwrite@line}
% \begin{macro}{\my@docum@nt}
% \begin{macro}{\my@end@docum@nt}
% \begin{environment}{document}
% \begin{macro}{\my@sym@def}
% \begin{macro}{\my@sym@LANG@def}
% \begin{macro}{\my@s@l@ctl@ngu@g@}
% \begin{macro}{\selectlanguage}
% \begin{macro}{\my@ch@pt@r@}
% \begin{macro}{\@chapter}
% \begin{environment}{symbols}
%    \begin{macrocode}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage[T1]{fontenc}%%%%
\RequirePackage[utf8]{inputenc}%
\RequirePackage{xargs}%%%%%%%%%%
\RequirePackage{acronym,suffix,xargs,xifthen,xspace}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\LoadClass[a4paper,10pt,twoside,openright]{report}[2007/10/19]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommandx\my@op@n[3][addprefix=\global,1=template,2=.txt,3=.tex]{%
  \newread\my@file%
  \immediate\openin\my@file=#1\myLANG#2%
  \newwrite\my@fil@%
  \immediate\openout\my@fil@=#1\myLANG#3%
}

\newcommandx\my@s@ut[0][addprefix=\global]{%
  \immediate\closein\my@file%
  \immediate\closeout\my@fil@%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Code borrowed from `multitoc.dtx' of CTAN /macros/latex/contrib/ms
%% Copyright (c) [1998..1999]  Martin Schr\"oder. All rights reserved.

\newcommand*{\protected@write@immediate}[3]{%
      \begingroup
       \let\thepage\relax
       #2%
       \let\protect\string
       \edef\reserved@a{\immediate\write#1{#3}}%
       \reserved@a
      \endgroup
      \if@nobreak\ifvmode\nobreak\fi\fi
   }

\newcommand*{\immediateaddtocontents}[2]{%
  \protected@write@immediate\@auxout
      {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
      {\string\@writefile{#1}{#2}}}

%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\addcontentsline#1#2#3{%
  \immediateaddtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}}}

\newcommandx\my@readwrite@line[2][addprefix=\global\protect,1=-1,2=to]{%
  \catcode`\\=12\catcode`\{=12\catcode`\}=12\catcode`\$=12%
  \catcode`\#=12\catcode`\^=12\catcode`\_=12\catcode`\%=12%
  \let\my@var\endlinechar%
  \endlinechar=#1%
  \immediate\read\my@file#2\my@lin@%
  \endlinechar=\my@var%
  \catcode`\%=14\catcode`\_=8\catcode`\^=7\catcode`\#=6%
  \catcode`\$=3\catcode`\}=2\catcode`\{=1\catcode`\\=0%
  \protected@xdef\my@line{\my@lin@}%
  \ifthenelse{\equal{\my@line}{}}{}{%
  \protected@write@immediate\my@fil@{\relax}{\my@line\@backslashchar\@backslashchar}}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\let\my@docum@nt\document
\let\my@end@docum@nt\enddocument
\renewenvironmentx{document}[2][1=pre,2]{%
  \my@op@n%
  \my@docum@nt%%%%%
  \input{#1.tex}%
  \ifx\\#2\\\else\selectlanguage{#2}\fi%
  \ignorespaces%%%%%%%%%
}{\my@end@docum@nt%
  \ignorespacesafterend%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommandx\my@sym@def[1][addprefix=\global]{%
  \expandafter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \newcommandx\csname#1\endcsname[4][addprefix=\global,3,4]{%
    \ifthenelse{\isempty{##3}%
    }{\ifthenelse{\isempty{##4}%
      }{\acro{##1}{{##2}}%%%%%%%%%
      }{\acro{##1}[{##2}]{{##4}}}%
    }{\ifthenelse{\isempty{##4}%
      }{\acro{##1}{{##2}\acroextra{{##3}}}%%%%%%%%
      }{\acro{##1}[{##2}]{{##4}\acroextra{{##3}}}%
    }}%
    \expandafter\gdef\csname##1\endcsname{\acl{##1}\xspace{}}%%
    \expandafter\gdef\csname##1*\endcsname{\acs{##1}\xspace{}}%
  }%
}

\newcommandx\my@sym@LANG@def[2][addprefix=\global]{%
  \expandafter%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \newcommandx\csname#1#2\endcsname[4][3,4]{%
    \ifthenelse{\isempty{##3}%%%%%%%%%%%%%%%%%%%%%%%
    }{\@nameuse{#1}{##1}{\@nameuse{#2}{##2}}[][##4]%
    }{\@nameuse{#1}{##1}{\@nameuse{#2}{##2}}%%%%%%%%
                        [\@nameuse{#2}{##3}][##4]%%%
    }%
  }%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\let\my@s@l@ctl@ngu@g@\selectlanguage
\renewcommand\selectlanguage[1]{%%%%%%%%%%%
\my@s@l@ctl@ngu@g@{#1}\@nameuse{do\myLANG}}

\let\my@ch@pt@r@\@chapter
\renewcommandx\@chapter[3][1,2,3]{%
  \ifthenelse{\isempty{#1}}{%
    \GenericError{}{empty chapter name}{%%%
      stop}{%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      here.}}%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \ifx\\#3\\\else\selectlanguage{#3}\fi%
  \my@ch@pt@r@[#1]{#1}%
  \addcontentsline{lof}{chapter}{\thechapter\nobreakspace#1}%
  \addcontentsline{lot}{chapter}{\thechapter\nobreakspace#1}%
  \ifx\\#2\\\else\label{chp:#2}\fi%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newenvironmentx{symbols}[1][1]{%
  \pagestyle{empty}%%%%%%%
  \thispagestyle{empty}%%%
  \chapter*{Symbols}%
  \addcontentsline{toc}{section}{Symbols}%
  \begin{acronym}[{#1}]%
}{\end{acronym}%%%%%%%%%
  \clearpage%
}

%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{environment}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{environment}

这是mwe.ins

\def\batchfile{mwe.ins}
\input docstrip.tex
\keepsilent
\generateFile{mwe.cls}{t}{\from{mwe.dtx}{class}}

这是ltxdoc.cfg

\PassOptionsToClass{a4paper}{article}
\AtEndOfPackage{%
\hyphenation{tocprelim semifinal draft}
\RequirePackage{indentfirst}%
\RequirePackage{hyperref}%
}

这是mwe.tex

% -*- mode: latex; unibyte: nil; coding: utf-8 -*-

\documentclass{./mwe}

\usepackage[romanian]{babel}
\usepackage{newunicodechar}

\newunicodechar{ș}{\c{s}}\newunicodechar{Ș}{\c{S}}
\newunicodechar{ț}{\c{t}}\newunicodechar{Ț}{\c{T}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand\RO[1]{\foreignlanguage{romanian}{#1}\xspace{}}
\newcommand\doRO{\relax}
\xdef\myLANG{RO}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter

\my@sym@def{sym}
\@expandtwoargs\my@sym@LANG@def{sym}{\myLANG}

\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\title{Minimal Working Example}
\author{acronym}

\begin{document}[preamble][romanian]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%--------------------------------------------------------------------%

\inputencoding{latin10}

\makeatletter

\newcounter{my@cnt}%
\setcounter{my@cnt}{0}%

\@whilenum\arabic{my@cnt}<24\do{%
  \my@readwrite@line%
  \stepcounter{my@cnt}%
}

\my@s@ut%

\makeatother

\noindent%
\input{templateRO}

\inputencoding{utf8}

%--------------------------------------------------------------------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter[Oscilații][osc][romanian]

\HZO~e formula pentru \HZO*.

\end{document}

这是preamble.tex

% -*- mode: latex; unibyte: t; coding: utf-8 -*-

\maketitle

\begin{symbols}[WORD]

  \symRO{HZO}{Apă}[\hfill făcută din 3 elemente și 2 molecule][$H_2O$]

\end{symbols}

\tableofcontents

顺序为:latex mwe.ins; pdftex -shell-escape mwe.tex #twice

templateRO.txt此处指定的文件——http://en.wikipedia.org/wiki/Romanian_alphabet#Unicode_and_HTML-- 包含带有逗号(而不是变音符)的 8 位字母。

Thesis
Submitted in Partial Fulfillment of the Requirements for
the Degree of Doctor of Philosophy
in Computer Science
to the Faculty of Engineering of the
University of Rome
by

Conducător științific
Referenți științifici

Ziua susținerii tezei

Acest document este în domeniul public.

Acknowledgements

Dedicație

Keywords

Lista de acronime
Lista de teoreme
Lista de demonstrații

谢谢。

答案1

主文件不应该有它们禁用的 catcode 更改inputenc

\documentclass[a4paper,10pt]{report}

\usepackage[T1]{fontenc}
\usepackage[latin10,utf8]{inputenc}
\usepackage[romanian]{babel}
\usepackage{newunicodechar}
\usepackage{acronym}

\newunicodechar{ș}{\c{s}}\newunicodechar{Ș}{\c{S}}
\newunicodechar{ț}{\c{t}}\newunicodechar{Ț}{\c{T}}

\begin{document}

\selectlanguage{romanian}

\inputencoding{latin10}


\input{symbols}



\inputencoding{utf8}

\chapter{Oscilații}

\end{document}

您需要删除该.aux文件,这样 Latex 才会写入一个正确的文件,其格式应如下所示:

\relax 
\reset@newl@bel
\select@language{romanian}
\@writefile{toc}{\select@language{romanian}}
\@writefile{lof}{\select@language{romanian}}
\@writefile{lot}{\select@language{romanian}}
\select@language{romanian}
\@writefile{toc}{\select@language{romanian}}
\@writefile{lof}{\select@language{romanian}}
\@writefile{lot}{\select@language{romanian}}
\newacro{Ap\u a}[\AC@hyperlink{Ap\u a}{Ap\u a}]{f\u acut\u a din 3 elemente \tex
tcommabelow si 2 molecule}
\@writefile{toc}{\contentsline {chapter}{\numberline {1}Oscila\c {t}ii}{2}}
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}

请注意,辅助文件字符永远不会被写成字符,而是使用 latex 命令,因此即使文件此时使用不同的编码,它们也可以被读回。

相关内容