add some config

1. init add new org-mode version load path
2. add org-mode lib
3. init-custom add fullscreen
4. init-org add export pdf with chinese article
This commit is contained in:
邵静 2024-07-08 20:15:42 +08:00
parent 8f4a452d41
commit 0e31e404a6
5 changed files with 184 additions and 1 deletions

View File

@ -1,6 +1,7 @@
;;; init.el -- 初始化配置
;;; Commentary:
;;; Code:
(add-to-list 'load-path "~/.emacs.d/org-mode/lisp")
(add-to-list 'load-path "~/.emacs.d/lisp")
(require 'init-package) ; 配置包管理器

View File

@ -15,6 +15,9 @@
;; 关闭自动保存,自动备份文件
(setq auto-save-mode nil)
(setq make-backup-files nil)
;; 全屏
(custom-set-variables
'(initial-frame-alist (quote ((fullscreen . maximized)))))
;; 字体
(cond
;; 如果是windows系统, 设置Consolas字体

View File

@ -1,6 +1,175 @@
;;; init-org.el -- org配置
;;; Commentary:
;;; Code:
(add-hook 'org-mode-hook
(lambda () (setq truncate-lines nil)))
(require 'ox-latex)
;; 使用xelatex一步生成PDF
(setq org-latex-pdf-process
'("xelatex -interaction nonstopmode -output-directory %o %f"
"xelatex -interaction nonstopmode -output-directory %o %f"
"xelatex -interaction nonstopmode -output-directory %o %f"))
;; code执行免应答Eval code without confirm
(setq org-confirm-babel-evaluate nil)
;; Auctex
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(defun org-mode-article-modes ()
(reftex-mode t)
(and (buffer-file-name)
(file-exists-p (buffer-file-name))
(reftex-parse-all)))
(add-hook 'org-mode-hook
(lambda ()
(if (member "REFTEX" org-todo-keywords-1)
(org-mode-article-modes))))
(unless (boundp 'org-export-latex-classes)
(setq org-export-latex-classes nil))
;; 导出路径设置
(defun my-org-export-directory ()
"Set the export directory based on the operating system."
(if (eq system-type 'windows-nt)
"C:/workspace/org-export"
"~/org-export"))
(setq org-export-directory (my-org-export-directory))
;; latex-classes 配置
(setq org-latex-classes nil) ;; 初始化变量,以防止冲突
(add-to-list 'org-latex-classes
'("cn-article"
"\\documentclass[10pt,a4paper]{article}
\\usepackage{graphicx}
\\usepackage{xcolor}
\\usepackage{xeCJK}
\\usepackage{lmodern}
\\usepackage{verbatim}
\\usepackage{fixltx2e}
\\usepackage{longtable}
\\usepackage{float}
\\usepackage{tikz}
\\usepackage{wrapfig}
\\usepackage{soul}
\\usepackage{textcomp}
\\usepackage{listings}
\\usepackage{geometry}
\\usepackage{algorithm}
\\usepackage{algorithmic}
\\usepackage{marvosym}
\\usepackage{wasysym}
\\usepackage{latexsym}
\\usepackage{natbib}
\\usepackage{fancyhdr}
\\usepackage[xetex,colorlinks=true,CJKbookmarks=true,
linkcolor=blue,
urlcolor=blue,
menucolor=blue]{hyperref}
\\usepackage{fontspec,xunicode,xltxtra}
\\usepackage{ifplatform}
\\ifwindows
\\setmainfont{Consolas}
\\setsansfont{Consolas}
\\setmonofont{Consolas}
\\else
\\setmainfont{Ubuntu Mono}
\\setsansfont{Ubuntu Mono}
\\setmonofont{Ubuntu Mono}
\\fi
\\setCJKmainfont[BoldFont=SimHei]{SimSun} % 设置仿宋字体
\\setCJKmonofont{SimSun} % 设置仿宋字体为等宽字体
\\hypersetup{unicode=true}
\\geometry{a4paper, textwidth=6.5in, textheight=10in,
marginparsep=7pt, marginparwidth=.6in}
\\definecolor{foreground}{RGB}{220,220,204}%浅灰
\\definecolor{background}{RGB}{62,62,62}%浅黑
\\definecolor{preprocess}{RGB}{250,187,249}%浅紫
\\definecolor{var}{RGB}{239,224,174}%浅肉色
\\definecolor{string}{RGB}{154,150,230}%浅紫色
\\definecolor{type}{RGB}{225,225,116}%浅黄
\\definecolor{function}{RGB}{140,206,211}%浅天蓝
\\definecolor{keyword}{RGB}{239,224,174}%浅肉色
\\definecolor{comment}{RGB}{180,98,4}%深褐色
\\definecolor{doc}{RGB}{175,215,175}%浅铅绿
\\definecolor{comdil}{RGB}{111,128,111}%深灰
\\definecolor{constant}{RGB}{220,162,170}%粉红
\\definecolor{buildin}{RGB}{127,159,127}%深铅绿
\\punctstyle{kaiming}
\\title{}
\\fancyfoot[C]{\\bfseries\\thepage}
\\chead{\\MakeUppercase\\sectionmark}
\\pagestyle{fancy}
\\tolerance=1000
[NO-DEFAULT-PACKAGES]
[NO-PACKAGES]"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}")))
(setq org-export-latex-listings t)
(setq org-export-latex-listings-options
'(
("basicstyle" "\\color{foreground}\\small\\ttfamily") ; 源代码字体样式
("keywordstyle" "\\color{function}\\bfseries\\small\\ttfamily") ; 关键词字体样式
("identifierstyle" "\\color{doc}\\small\\ttfamily")
("commentstyle" "\\color{comment}\\small\\itshape") ; 批注样式
("stringstyle" "\\color{string}\\small") ; 字符串样式
("showstringspaces" "false") ; 字符串空格显示
("numbers" "left") ; 行号显示
("numberstyle" "\\color{preprocess}") ; 行号样式
("stepnumber" "1") ; 行号递增
("backgroundcolor" "\\color{background}") ; 代码框背景色
("tabsize" "4") ; TAB等效空格数
("captionpos" "t") ; 标题位置 top or bottom(t|b)
("breaklines" "true") ; 自动断行
("breakatwhitespace" "true") ; 只在空格分行
("showspaces" "false") ; 显示空格
("columns" "flexible") ; 列样式
("frame" "single") ; 代码框:阴影盒
("frameround" "tttt") ; 代码框:圆角
("framesep" "0pt")
("framerule" "8pt")
("rulecolor" "\\color{background}")
("fillcolor" "\\color{white}")
("rulesepcolor" "\\color{comdil}")
("framexleftmargin" "10mm")
))
;; 在导出 LaTeX 文档时插入字体设置代码
(setq org-latex-packages-alist
'(("AUTO" "ifplatform" t)
("AUTO" "fontspec" t)
("AUTO" "xunicode" t)
("AUTO" "xltxtra" t)
;; 以下代码插入字体设置部分
("" "\\ifwindows
\\setmonofont{Consolas}
\\else
\\setmonofont{Ubuntu Mono}
\\fi" t)))
;; 使用 ido 完成 Org Mode 的提示
(setq org-completion-use-ido t)
;; 启用 Org Babel 对多种编程语言的支持
(org-babel-do-load-languages
'org-babel-load-languages
'((R . t) ; 支持 R 语言
(emacs-lisp . t) ; 支持 Emacs Lisp
(matlab . t) ; 支持 Matlab
(C . t) ; 支持 C 语言
(perl . t) ; 支持 Perl
(shell . t) ; 支持 Shell 脚本
(ditaa . t) ; 支持 ditaa 图形
(python . t) ; 支持 Python
(haskell . t) ; 支持 Haskell
(dot . t) ; 支持 Graphviz dot 语言
(latex . t) ; 支持 LaTeX
(js . t) ; 支持 JavaScript
))
;;; org-roam org-mode笔记管理
(use-package org-roam
@ -14,6 +183,13 @@
(require 'org-roam-protocol)
)
;; 打印选项
(setq ps-paper-type 'a4
ps-font-size 16.0
ps-print-header nil ; 不打印页眉
ps-landscape-mode nil ;纵向
)
;; 取org-mode中C-,快捷键的绑定
(add-hook 'org-mode-hook (lambda ()
(local-unset-key (kbd "C-,"))

View File

@ -3,7 +3,9 @@
;;; Code:
;; 配置镜像
(setq package-archives '(("gnu" . "https://mirrors.ustc.edu.cn/elpa/gnu/")
("melpa" . "https://mirrors.ustc.edu.cn/elpa/melpa/")
;;("melpa" . "https://mirrors.ustc.edu.cn/elpa/melpa/")
("melpa" . "https://melpa.org/packages/")
("melpa-stable" . "https://stable.melpa.org/packages/")
("nongnu" . "https://mirrors.ustc.edu.cn/elpa/nongnu/")
))
;; 激活配置

1
org-mode Submodule

@ -0,0 +1 @@
Subproject commit d38d53a1783dde6ad672473fce7286faf1527462