latex

Highlighting a Chunk of Code within a lstlisting

二次信任 提交于 2019-12-20 09:48:31
问题 I have a bunch of code in a lstlisting environment. How can I highlight (color background) just a particular chunk of code within the environment? 回答1: You can use \colorbox and an escape character inside your listing: Add to your preamble \usepackage{color} \definecolor{light-gray}{gray}{0.80} then use it like this in your document: \begin{lstlisting}[escapechar=!] def mult(m: Matrix[Int], n: Matrix[Int]) { val p = !\colorbox{light-gray}{new MatrixInt}!(m.rows, n.cols) } \end{lstlisting} 回答2

Sync Emacs AUCTeX with Sumatra PDF

江枫思渺然 提交于 2019-12-20 09:47:29
问题 With these lines in my init.el I am able to sync the Emacs LaTeX buffer with Sumatra: (setq TeX-source-correlate-mode t) (setq TeX-source-correlate-method 'synctex) (setq TeX-view-program-list '(("Sumatra PDF" ("\"C:/bin86/SumatraPDF/SumatraPDF.exe\" -reuse-instance" (mode-io-correlate " -forward-search %b %n ") " %o")))) (setq TeX-view-program-selection '(((output-dvi style-pstricks) "dvips and start") (output-dvi "Yap") (output-pdf "Sumatra PDF") (output-html "start"))) To set a double

How do I change the axis tick font in a matplotlib plot when rendering using Latex?

血红的双手。 提交于 2019-12-20 09:17:03
问题 The font of the axis tick mark labels produced from the following code isn't Helvetica, but is still the default serif Computer Modern. Any suggestions are greatly appreciated. from matplotlib import rc, font_manager from numpy import arange, cos, pi from matplotlib.pyplot import figure, axes, plot, xlabel, ylabel, title, \ grid, savefig, show sizeOfFont = 12 fontProperties = {'family':'sans-serif','sans-serif':['Helvetica'], 'weight' : 'normal', 'size' : sizeOfFont} ticks_font = font_manager

Reduce space between code chunks and code output in rmarkdown beamer presentation

假如想象 提交于 2019-12-20 09:16:55
问题 I'm building a presentation using rmarkdown and LaTeX/Beamer. I would like to reduce the spacing between the displayed R-commands and R-output. I believe this is related to the paragraph spacing options in LaTeX/Beamer. Is this something I should do in rmarkdown (chunk options, knit_hooks, or something else?), in the pandoc Yaml header (some pandoc option?), or in the LaTeX beamer template file? I feel like it should be in the LaTeX template file. Below is a working example of a minimal

Include *.sty file from a super/subdirectory of main *.tex file

空扰寡人 提交于 2019-12-20 09:15:28
问题 I want to share a latex document via git with many other people. Therefore we decided to put all the special sty files, that are not present in everyones latex-installation, into a resources directory. It would be cool, if this dir would be a superdir. of the actual working directory How exactly can I import those style files? It is important that even the dependencies of those remote styles are resolved with other remote styles. 回答1: You can import a style file ( mystyle.sty ) into your

Emacs: automatically replace LaTeX to Unicode symbols

扶醉桌前 提交于 2019-12-20 09:02:23
问题 In Emacs I frequently use math symbols when I write my theory summaries of math textbooks. I use org-mode to structure information and I know about at least two methods of entering special symbols: Using embedded LaTeX: enter its representation in the form \land then press C-c C-x \ ( org-toggle-pretty-entities ) to view it literally; Using C-x 8 RET ( insert-char ). I want it however to behave the following way: I enter the LaTeX representation, and it is automatically converted into the

Convert LaTeX to MediaWiki syntax

孤人 提交于 2019-12-20 08:57:48
问题 I need to convert LaTeX into MediaWiki syntax. The formulas should stay the same, but I need to transform, for example \chapter{something} into = something =. Although this can be obtained with a bit of sed, things get a little dirty with the itemize environment, so I was wondering if a better solution can be produced. Anything that can be useful for this task? 回答1: Pandoc should be able to do it: $ pandoc -f latex -t mediawiki << END > \documentclass{paper} > \begin{document} > \section

LaTeX: Prevent line break in a span of text

空扰寡人 提交于 2019-12-20 08:19:15
问题 How can I prevent LaTeX from inserting linebreaks in my \texttt{...} or \url{...} text regions? There's no spaces inside I can replace with ~ , it's just breaking on symbols. Update : I don't want to cause line overflows, I'd just rather LaTeX insert linebreaks before these regions rather than inside them. 回答1: \mbox is the simplest answer. Regarding the update: TeX prefers overlong lines to adding too much space between words on a line; I think the idea is that you will notice the lines that

LaTeX sometimes puts too much or too little space after periods

笑着哭i 提交于 2019-12-20 08:04:35
问题 LaTeX tries to guess whether a period ends a sentence, in which case it puts extra space after it. Here are two examples where it guesses wrong: I watched Superman III. Then I went home. (Too little space after "Superman III.".) After brushing teeth etc. I went to bed. (Too much space after "etc.".) Note that it doesn't matter how much whitespace you use in the LaTeX source since LaTeX ignores that. 回答1: I found the answer here: http://john.regehr.org/latex/. Excerpt: When a non-sentence

LaTeX sometimes puts too much or too little space after periods

一曲冷凌霜 提交于 2019-12-20 08:00:10
问题 LaTeX tries to guess whether a period ends a sentence, in which case it puts extra space after it. Here are two examples where it guesses wrong: I watched Superman III. Then I went home. (Too little space after "Superman III.".) After brushing teeth etc. I went to bed. (Too much space after "etc.".) Note that it doesn't matter how much whitespace you use in the LaTeX source since LaTeX ignores that. 回答1: I found the answer here: http://john.regehr.org/latex/. Excerpt: When a non-sentence