避免覆盖源代码

避免覆盖源代码

有没有办法保护 LaTeX 代码的某些部分以避免被覆盖?(因为我想将代码分配给不应该“接触”源代码某些部分的人。)

编辑:

% Begin: don't touch!!
\RequirePackage{fix-cm}
\documentclass[fontsize=8.5pt,DIV=calc]{scrbook}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage{helvet}

\usepackage{geometry}
\geometry{a4paper,left=15mm,right=15mm, top=26mm, bottom=17mm} 

\renewcommand{\familydefault}{\sfdefault}
\usepackage{multicol} 
\usepackage{xcolor}

\usepackage{mdframed}   
\usepackage{paralist}    

\setlength\parindent{0pt}
\setlength\columnsep{5mm}

\renewcommand\familydefault{\sfdefault}
\renewcommand{\labelitemi}{\textcolor{black!60}{\raisebox{0.5mm}{\rule{1.8mm}{1.8mm}}}}
\newcommand{\zitiert}[1]{\flqq{#1}\frqq}

\usepackage{enumitem}
\setitemize{leftmargin=*}

\addtokomafont{section}{\large}
\makeatletter
\renewcommand\sectionlinesformat[4]{%
  \ifstr{#1}{section}
    {\setlength\fboxsep{1.75mm}%
      \colorbox{black!15}{\raisebox{0pt}[\height][0pt]{%
        \parbox[b]{\dimexpr\linewidth-2\fboxsep\relax}{%
          \raggedsection\@hangfrom{\hskip#2#3}{#4}%
    }}}}
    {\@hangfrom{\hskip#2#3}{#4}}%
}
\renewcommand\sectionformat{%
  \makebox[10mm][r]{\thesection\autodot\hspace{5mm}}
}
\makeatother

% End: don't touch!!

\usepackage{lipsum}

\begin{document}
\begin{multicols}{2}
Some random text....
\lipsum[14]
\end{multicols}
\end{document}

从 '%Begin: Don't touch!!' 到 '%End: Don't touch!!' 的部分应为“只读”...

答案1

  1. % Begin: don't touch!!将和之间的内容放入% End: don't touch!!文件中myclass.cls
  2. 在中myclass.cls,替换\documentclass和。\LoadClass\usepackage\RequirePackage
  3. 在 中myclass.cls,删除\makeatletter\makeatother

现在myclass.cls看起来如下:

\RequirePackage{fix-cm}
\LoadClass[fontsize=8.5pt,DIV=calc]{scrbook}
\RequirePackage[T1]{fontenc}
\RequirePackage[ngerman]{babel}
\RequirePackage[utf8]{inputenc}
\RequirePackage{helvet}

\RequirePackage{geometry}
\geometry{a4paper,left=15mm,right=15mm, top=26mm, bottom=17mm} 

\renewcommand{\familydefault}{\sfdefault}
\RequirePackage{multicol} 
\RequirePackage{xcolor}

\RequirePackage{mdframed}   
\RequirePackage{paralist}    

\setlength\parindent{0pt}
\setlength\columnsep{5mm}

\renewcommand\familydefault{\sfdefault}
\renewcommand{\labelitemi}{\textcolor{black!60}{\raisebox{0.5mm}{\rule{1.8mm}{1.8mm}}}}
\newcommand{\zitiert}[1]{\flqq{#1}\frqq}

\RequirePackage{enumitem}
\setitemize{leftmargin=*}

\addtokomafont{section}{\large}
\renewcommand\sectionlinesformat[4]{%
  \ifstr{#1}{section}
    {\setlength\fboxsep{1.75mm}%
      \colorbox{black!15}{\raisebox{0pt}[\height][0pt]{%
        \parbox[b]{\dimexpr\linewidth-2\fboxsep\relax}{%
          \raggedsection\@hangfrom{\hskip#2#3}{#4}%
    }}}}
    {\@hangfrom{\hskip#2#3}{#4}}%
}
\renewcommand\sectionformat{%
  \makebox[10mm][r]{\thesection\autodot\hspace{5mm}}
}
  1. 将原始文档更改为

    \documentclass{myclass}
    \usepackage{lipsum}
    \begin{document}
    \begin{multicols}{2}
    Some random text....
    \lipsum[14]
    \end{multicols}
    \end{document}
    

然后告诉你的同事不要更改myclass.cls,或者不要使用他的副本,而要使用你的副本。

相关内容