Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
来自src块的多行latex标头_Latex_Org Mode_Org Babel - Fatal编程技术网

来自src块的多行latex标头

来自src块的多行latex标头,latex,org-mode,org-babel,Latex,Org Mode,Org Babel,我有几行应该在\begin{document}之前添加。通常,我使用#+LATEX_头:来实现这一点。但是,#+LATEX_头:无法计算引用(例如noweb)或组织宏。我能看到的唯一解决方案是在每一行之前添加#+LATEX_标题:。有没有更优雅的方法 我的“理想”组织文件(不工作): #+标题:标题 #+作者:某人 #+类别:文章 #+胶乳U头: *第一节 Lorem Ipsum只是印刷和排版的虚拟文本 工业。Lorem Ipsum一直是业界标准的虚拟文本 从16世纪开始,当一个不知名的印刷商在

我有几行应该在
\begin{document}
之前添加。通常,我使用
#+LATEX_头:
来实现这一点。但是,
#+LATEX_头:
无法计算引用(例如noweb)或组织宏。我能看到的唯一解决方案是在每一行之前添加
#+LATEX_标题:
。有没有更优雅的方法

我的“理想”组织文件(不工作):

#+标题:标题
#+作者:某人
#+类别:文章
#+胶乳U头:
*第一节
Lorem Ipsum只是印刷和排版的虚拟文本
工业。Lorem Ipsum一直是业界标准的虚拟文本
从16世纪开始,当一个不知名的印刷商在一个厨房里打印
把它拼凑成一本样本书。
*标题:noexport:
#+姓名:headerthings
#+开始使用橡胶
\somemacro{
莫比·鲁特鲁姆·厄罗斯
卢克图斯。梅塞纳斯n
nunc nec vulputate
直径(单位:urna.Susp)
怀孕妇女
乌兰科珀索达莱酒店
每科努比亚诺斯特拉酒店
爱神,在莫利斯艾尔
康瓦利斯·拉奥里特。
效价
}
#+结束(src)
非优雅工作解决方案:

#+TITLE: Title
#+AUTHOR: Someone

#+LATEX_CLASS: article

#+LATEX_HEADER: <<headerthings>>

* First Section
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. 

* header things                                                    :noexport:
#+LATEX_HEADER: \somemacro{
#+LATEX_HEADER: Morbi rutrum eros 
#+LATEX_HEADER: luctus. Maecenas n
#+LATEX_HEADER: nunc nec vulputate
#+LATEX_HEADER: diam in urna. Susp
#+LATEX_HEADER: gravida nisl a lor
#+LATEX_HEADER: ullamcorper sodalet
#+LATEX_HEADER: per conubia nostra
#+LATEX_HEADER: eros. In mollis el
#+LATEX_HEADER: convallis laoreet.
#+LATEX_HEADER: efficitur aliquet 
#+LATEX_HEADER: }
#+标题:标题
#+作者:某人
#+类别:文章
#+胶乳U头:
*第一节
Lorem Ipsum只是印刷和排版的虚拟文本
工业。Lorem Ipsum一直是业界标准的虚拟文本
从16世纪开始,当一个不知名的印刷商在一个厨房里打印
把它拼凑成一本样本书。
*标题:noexport:
#+LATEX\u头:\somemacro{
#+乳胶头:Morbi rutrum eros
#+LATEX_标题:luctus.Maecenas n
#+乳胶头:nunc nec vulputate
#+乳胶_头:urna.Susp中的直径
#+乳胶头:孕妇nisl a lor
#+乳胶头:ullamcorper sodalet
#+乳胶头:根据conubia nostra
#+LATEX_标题:莫利斯埃尔的厄洛斯
#+LATEX_标题:convallis laoreet。
#+乳胶_头:efficitur aliquet
#+LATEX_头:}
这对我很有用(组织模式版本9.1.2)

导出的LaTeX文件是(使用我的配置)

您可以删除源块,然后将生成的文件用作包:

#+TITLE: Title
#+AUTHOR: Someone

#+LATEX_CLASS: article

#+LATEX_HEADER: \usepackage{headerthings}

* First Section
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. 

\somemacro

* header things                                                    :noexport:
#+name: headerthings
#+begin_src latex :tangle headerthings.sty
\newcommand{\somemacro}{
Morbi rutrum eros 
luctus. Maecenas n
nunc nec vulputate
diam in urna. Susp
gravida nisl a lor
ullamcorper sodalet
per conubia nostra
eros. In mollis el
convallis laoreet.
efficitur aliquet 
}
#+end_src
在导出之前,您需要执行
C-C-v C-t
以纠结,但您只需要在更改源块时进行纠结。或者,您可以通过修改
org export before process hook
,安排在导出之前发生纠缠:

(在处理hook#'org-babel-tangle之前添加hook'org导出)
这样你就不用担心了

#+TITLE: Title
#+CALL: my_latex_header()

* Your section 1
* Your section 2 
* Configuration                                                    :noexport:
#+NAME: my_latex_header
#+BEGIN_SRC emacs-lisp :results drawer 
(mapconcat (function (lambda(x) (format "#+LATEX_HEADER: %s" x)))
       '( 
         "% line_1"
         "% line_2"
         "% line_3"
         )
       "\n")
#+END_SRC
% Created 2020-07-02 Thu 06:17
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
% line_1
% line_2
% line_3
\author{picaud}
\date{\today}
\title{Title}
\hypersetup{
 pdfauthor={picaud},
 pdftitle={Title},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 26.1 (Org mode 9.1.2)}, 
 pdflang={English}}
\begin{document}

\maketitle
\tableofcontents
    
\section{Your section 1}
\label{sec:orgcfaa171}
\section{Your section 2}
\label{sec:orgead0a5c}
\end{document}
#+TITLE: Title
#+AUTHOR: Someone

#+LATEX_CLASS: article

#+LATEX_HEADER: \usepackage{headerthings}

* First Section
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. 

\somemacro

* header things                                                    :noexport:
#+name: headerthings
#+begin_src latex :tangle headerthings.sty
\newcommand{\somemacro}{
Morbi rutrum eros 
luctus. Maecenas n
nunc nec vulputate
diam in urna. Susp
gravida nisl a lor
ullamcorper sodalet
per conubia nostra
eros. In mollis el
convallis laoreet.
efficitur aliquet 
}
#+end_src