Own set of LaTeX documents cheat mode

  Here LaTeX documents recording mode for personal use in a memo.

surroundings:

  Operating System: Ubuntu 18.04.3
  Compile way: LuaLaTeX

Directory Structure:

Directory Description:

  1, database storage directory is a project, how many items will be how many of these folders. Here is a project called comprehensive information;
  2, Package Penalty for custom storage area LaTeX macro packages, classes;
  3, District Resource is material, stored images, audio, video and so on;
  4, tool_lib is a tool area, mainly lua source Code, c / c ++ written link libraries.

The main source code file:

  1, comprehensive information .tex

\documentclass{book}%
%
% 注意宏包顺序,有可能会报错
\usepackage{ctex}% 中文支持
\usepackage{geometry}% 用于页面设置
\usepackage[dvipsnames, svgnames, x11names]{xcolor} % 颜色支持
\usepackage{graphics}% 图形支持
\usepackage[colorlinks,linkcolor=blue]{hyperref}
\usepackage{enumerate}% 枚举支持
\usepackage{listings}% 代码显示支持
\usepackage{tabularx}% 表格支持
\usepackage{lakeside-cover}% 自定义封面包
%
% 设置为A4纸,并设置四周边距
\geometry{a4paper, left = 3.17cm, right = 3.17cm, top = 2.54cm, bottom = 2.54cm}%
%
% 以下两行命令用于解决LuaLaTeX编译模式下listings宏包不能正常工作的问题
\newdimen\cht%
\newdimen\cdp%
%
% 代码显示样式设置
\lstset{%
  breaklines,% 自动换行
  basicstyle=\small,% 设置字体大小
  frame=single,% 单线框
  numbers=left,% 行号在左边
  numberstyle=\tiny,% 行号字体大小
  keywordstyle = \color[RGB]{0, 0, 160},% 关键字颜色
  commentstyle = \color[RGB]{160, 160, 160},% 注释颜色
  stringstyle  = \color[RGB]{0, 0, 255},% 字符串颜色
}%
%
\setlength{\parindent}{2em}% 缩进为两个字符宽度
%
\hyphenpenalty = 100% 断字设置,值越大,断字越少。
%
% 与主文件不在同一目录时,在这里以及后面的\include命令中都要指明路径
\includeonly{
  ubuntu/ubuntu,%
  git/git,%
}
%
% ------------------ 开始 -------------------
\begin{document}%
% ------------------ 封面 -------------------
\begin{titlepage}%
  \ShowCover[%
    version=1.0.0,%
    author = 搜集整理:陆巍,%
    title1 = LAKESIDE ROBOT STUDIO,%
    title2 = 综合资料集,%
  ]{December 2, 2019}{Honeydew2}{../resource/cover/hongshan02.jpg}%
\end{titlepage}
%
% ------------------ 前言 -------------------
\frontmatter% 关闭章节序号,页码使用罗马数字
\restoregeometry% 恢复导言区指定的页面布局。
\pagecolor{white}% 页面颜色
\centerline{\bfseries\Large 前\quad 言\normalsize\normalfont}%
\quad\par
略……%
%
%
% ------------------ 目录 -------------------
\tableofcontents  % 生成目录
%
%
% ------------------ 正文 -------------------
\mainmatter%
%
\include{ubuntu/ubuntu}%
%
\include{git/git}%
%
\end{document}%

  Code has been described in detail, omitted.

  2, lakeside-cover.sty

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% lakeside-cover.sty
%
% 封面包
% 生成书本封面。
%
% Copyright: free
% Author:    陆巍
% Email:     [email protected]
% Version:   1.0.0
% Date:      2019-12-02
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%
%
% 下面两行是声明类的固定格式
\NeedsTeXFormat{LaTeX2e}[2007/10/19]%
\ProvidesPackage{lakeside-cover}[2019/12/02]%
%
%
\RequirePackage{overpic}% 覆盖图片支持
\RequirePackage{lakeside-tools}%
%
%
%
%
% ====================== 定义区 ======================
%
% 封面定义命令
% 页面颜色、图片暂时还不能使用lua命令去赋值
% 封面图片尺寸为800×480像素
\newcommand{\ShowCover}[4][]{%
  \pagecolor{#3}
  \newgeometry{left = 0cm, top = 2cm, bottom = 0cm}%
  % 封面上层
  \begin{flushright}
    \Huge\LaTeX\\[0.7cm]%
    \Large\color{gray} Version \GetKey{#1}{version}{0.0.0} \\[0.2cm]
     #2\normalsize\color{black}\\[0.2cm]%
    LAKESIDE ROBOT STUDIO\\[0.2cm]%
    \GetKey{#1}{author}{作者:陆巍}\\%
  \end{flushright}
  % 在图片上加文字
  \begin{overpic}[width = 21cm]{#4}%
    \color{white}\put(70, 57){\textit{Hongshan Park, Anshun, Guizhou}}%
  \end{overpic}%
  \begin{flushright}%
    \quad\\[1.0cm]%
    %常规字体设置对英文无效
    \font\rm="Latin Modern Roman Demi" at 25pt \rm \GetKey{#1}{title1}{test}\normalsize\\%
    \heiti\Huge \GetKey{#1}{title2}{test}\\[1.5cm]%
  \end{flushright}%
  \hspace{0cm}\fcolorbox{gray}{gray}{%
    \begin{minipage}[c][2cm][s]{5cm}%
    \hfill%
    \end{minipage}%
  }%
  \hspace{0.1cm}\fcolorbox{blue!40!black}{blue!40!black}{%
    \begin{minipage}[l][2cm][c]{15.4cm}%
    \color{white}\normalsize%
    \textit{\mbox{\qquad} https://gitee.com/lakesiderobot}\\%
    \mbox{\qquad} \textit{Email: [email protected]}%
    \end{minipage}%
  }%
  \renewcommand{\baselinestretch}{1.0}%
}%

  This class LaTeX file is used to generate the document cover.

  3, lakeside-tools.sty

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% lakeside-tools.sty
%
% 工具包文件。
% 由各种小工具组成的命令集。
%
% Copyright: free
% Author:    陆巍
% Email:     [email protected]
% Version:   1.0.0
% Date:      2019-12-02
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%
%
% ====================== 环境设置区 ======================
%
% 下面两行是声明类的固定格式
\NeedsTeXFormat{LaTeX2e}[2007/10/19]%
\ProvidesPackage{lakeside-tools}[2019/12/02]%
%
% 把以下三个库加入xcolor中(调用时)
\PassOptionsToPackage{dvipsnames, svgnames, x11names}{xcolor}%
% 需求的宏包
\RequirePackage{luacode}% lua支持
\RequirePackage{xcolor}%
%
%
%
%
% ====================== 定义区 ======================
%
%
\newcommand{\GetKey}[3]{%
    \luaexec{
        require("../tool_lib/lua/string")
        local str = GetKey("#2", "#1", "#3")
        tex.sprint(str) % 不能把GetKey函数直接放在这里输出,否则会被莫名其妙地在结尾加上数字1
    }
}%

  This class offers a variety of gadgets LaTeX file command. The current content calls a function written in Lua language.

  4, string.lua

-- @brief 提取关键字内容
-- @param key 关键字
-- @param str 被提取字符串
-- @param default 默认内容
-- @return 返回关键字对应内容
function GetKey(key, str, default)
  -- 前后添加逗号,规范数据流格式
  str = ", " .. str .. ","
  -- 正是前面对输入参数流前后加入逗号保证了以下语句的适用性
  local str1 = string.gsub(str, ".*,%s*" .. key .. "%s*=%s", "")
  if (str1 == str) then
    return default
  else
    return string.gsub(str1, "%s*,.*", "")
  end
end

  This file is used to store string functions. LuaLaTeX under way will compile Lua source code compiler, written in c / c ++ source code is not generally compiled into a DLL file for calls. Another lua program I use to record track logs, LaTeX documents with nothing, this is no longer listed in the source code.

  The following release documents under cover of a compilation of this mode:


  README.md file is automatically generated code hosting site files, has nothing to do with the latex, it will not be covered. All files with git management, and establish the corresponding private warehouse to store the code in hosted Web sites.

Guess you like

Origin www.cnblogs.com/atthefirst/p/11981281.html