-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlatex_and_lyx.html
995 lines (890 loc) · 32.3 KB
/
latex_and_lyx.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>Lyx Commands</title>
<script src="site_libs/header-attrs-2.28/header-attrs.js"></script>
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<style>h1 {font-size: 34px;}
h1.title {font-size: 38px;}
h2 {font-size: 30px;}
h3 {font-size: 24px;}
h4 {font-size: 18px;}
h5 {font-size: 16px;}
h6 {font-size: 12px;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<script src="site_libs/jqueryui-1.13.2/jquery-ui.min.js"></script>
<link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/default.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<link href="site_libs/font-awesome-6.4.2/css/all.min.css" rel="stylesheet" />
<link href="site_libs/font-awesome-6.4.2/css/v4-shims.min.css" rel="stylesheet" />
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">code{white-space: pre;}</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<link rel="stylesheet" href="styles.css" type="text/css" />
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
details > summary > p:only-child {
display: inline;
}
pre code {
padding: 0;
}
</style>
<style type="text/css">
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #adb5bd;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
border-radius: 6px 0 6px 6px;
}
</style>
<script type="text/javascript">
// manage active state of menu based on current page
$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');
// mark the anchor link active (and if it's in a dropdown, also mark that active)
var dropdown = menuAnchor.closest('li.dropdown');
if (window.bootstrap) { // Bootstrap 4+
menuAnchor.addClass('active');
dropdown.find('> .dropdown-toggle').addClass('active');
} else { // Bootstrap 3
menuAnchor.parent().addClass('active');
dropdown.addClass('active');
}
// Navbar adjustments
var navHeight = $(".navbar").first().height() + 15;
var style = document.createElement('style');
var pt = "padding-top: " + navHeight + "px; ";
var mt = "margin-top: -" + navHeight + "px; ";
var css = "";
// offset scroll position for anchor links (for fixed navbar)
for (var i = 1; i <= 6; i++) {
css += ".section h" + i + "{ " + pt + mt + "}\n";
}
style.innerHTML = "body {" + pt + "padding-bottom: 40px; }\n" + css;
document.head.appendChild(style);
});
</script>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "\e259";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "\e258";
font-family: 'Glyphicons Halflings';
border: none;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
<style type="text/css">
#TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
position: relative;
width: 100%;
}
}
@media print {
.toc-content {
/* see https://github.com/w3c/csswg-drafts/issues/4434 */
float: right;
}
}
.toc-content {
padding-left: 30px;
padding-right: 40px;
}
div.main-container {
max-width: 1200px;
}
div.tocify {
width: 20%;
max-width: 260px;
max-height: 85%;
}
@media (min-width: 768px) and (max-width: 991px) {
div.tocify {
width: 25%;
}
}
@media (max-width: 767px) {
div.tocify {
width: 100%;
max-width: none;
}
}
.tocify ul, .tocify li {
line-height: 20px;
}
.tocify-subheader .tocify-item {
font-size: 0.90em;
}
.tocify .list-group-item {
border-radius: 0px;
}
</style>
</head>
<body>
<div class="container-fluid main-container">
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-3">
<div id="TOC" class="tocify">
</div>
</div>
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-bs-toggle="collapse" data-target="#navbar" data-bs-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">Paul Rougieux</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">
<span class="fa fa-home"></span>
Home
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<span class="fa fa-wrench"></span>
Tools
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="bash.html">Bash</a>
</li>
<li>
<a href="communication.html">Communication</a>
</li>
<li>
<a href="debian.html">Debian</a>
</li>
<li>
<a href="docker.html">Docker</a>
</li>
<li>
<a href="git.html">Git</a>
</li>
<li>
<a href="latex_and_lyx.html">Latex and Lyx</a>
</li>
<li>
<a href="markdown.html">Markdown</a>
</li>
<li>
<a href="mysql.html">MySQL</a>
</li>
<li>
<a href="postgresql.html">PostgreSQL</a>
</li>
<li>
<a href="publish.html">Publish</a>
</li>
<li>
<a href="python.html">Python</a>
</li>
<li>
<a href="R.html">R</a>
</li>
<li>
<a href="vim.html">Vim</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<span class="fa fa-microchip"></span>
Algos
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="carbon_budget_model.html">Carbon Budget Model</a>
</li>
<li>
<a href="musical_scales.html">Musical scales</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<span class="fa fa-line-chart"></span>
Data
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="explore.html">Explore</a>
</li>
<li>
<a href="datasources.html">Sources</a>
</li>
</ul>
</li>
<li>
<a href="events.html">
<span class="fa fa-users"></span>
Events
</a>
</li>
<li>
<a href="publications.html">
<span class="fa fa-book"></span>
Publications
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<div id="header">
<h1 class="title toc-ignore">Lyx Commands</h1>
</div>
<div id="introduction" class="section level1">
<h1>Introduction</h1>
<p>This page describes how to use Latex and Lyx to edit scientific
publications.</p>
</div>
<div id="bibliography" class="section level1">
<h1>Bibliography</h1>
<p><a
href="https://tex.stackexchange.com/questions/373754/how-to-add-page-numbers-to-book-related-bibliographic-entries/373777">How
to add a page number to a bibliographic entry.</a></p>
<blockquote>
<p>“Try using <span class="citation">@inbook</span> instead of <span
class="citation">@book</span>. The .bst file of this journal has several
definitions for citing books. When using <span
class="citation">@book</span> in your .bib file you are implying that
you are citing the whole book, and therefore there is no need for page
numbergs. When using <span class="citation">@inbook</span> you mean to
say that you are citing a certain part of the book. If you use <span
class="citation">@inbook</span> the bibliography will show both pages
and chapter of the book you are citing.”</p>
</blockquote>
<p>In the bst file, you can also check for chapter entries.</p>
<div id="bibtex-special-character" class="section level2">
<h2>Bibtex special character</h2>
<p>bib file have an old encoding format. It’s possible to use utf8 in
bibtex, but for compatibility reason I stick with the old format.</p>
<p><a href="https://tex.stackexchange.com/a/57745/44254">How to write
“ä” and other umlauts and accented letters in bibliography?</a></p>
<pre><code>{\"a} {\aa}
{\c c}
{\^e} {\`e} {\'e}
{\u g}
{\`i} {\.I}
{\l}
{\~n}
{\o} {\H o}
{\'u}
{\v r} {\ss}</code></pre>
</div>
<div id="sample-bib-file-content" class="section level2">
<h2>Sample bib file content</h2>
<p>An article citation can usually be copied from the journal website or
from a search engine</p>
<pre><code>@article{,
title = {},
journal = {},
volume = {},
pages = {},
year = {},
issn = {},
doi = {},
url = {},
author = {},
keywords = {},
}</code></pre>
<p>A website entry</p>
<pre><code>@www{,
title = {},
author = {},
journal = {},
year = {},
url = {},
}</code></pre>
</div>
<div id="compilation-errors" class="section level2">
<h2>Compilation errors</h2>
<p><a href="https://tex.stackexchange.com/a/561933/44254">Error: LaTeX
Error: Something’s wrong–perhaps a missing</a></p>
<blockquote>
<p>“In case the error keeps presenting even you already added a
<code>\cite{something}</code> in your paper, then you have to clear the
auxiliary files. In details, delete any files ended with .log .aux .bbl
.blg.”</p>
</blockquote>
<p>Error message:</p>
<pre><code>! Argument of \UTFviii@two@octets has an extra }.</code></pre>
<p>Tex.stackexchange <a
href="https://tex.stackexchange.com/a/372332/44254">answer</a> Change ü
to {"u} in Düsseldorf in the bibliography.</p>
</div>
<div id="merge-and-filter-bibliographies" class="section level2">
<h2>Merge and filter bibliographies</h2>
<p>Answers to a question on merging 2 bibtex file recommend using Jabref
file / import into current database.</p>
<p>Create a shorter bibliography with only cited documents from another
bibliography Extracting only the BibTex records relevant to the paper.
Answers recommend using bibtool or bibexport.</p>
<p>I have written an article in Lyx which cites 2 bibliographies and a
colleague asked to have a .tex version of this article. Here is my
recipe:</p>
<pre><code>Use Jabref to merge two bibliographies.
Export Lyx file to LaTeX (PDFLaTeX).
Edit the .tex file to insert a link to the merged bibliographies.
\phantomsection\addcontentsline{toc}{section}{\refname}\bibliography{long.bib}
Compile the .tex with TeXstudio.
Used bibexport to extract a short bibliography corresponding only to the citations used in one article.
bibexport -o short.bib article.aux
Replace long.bib by short.bib in the .tex file.</code></pre>
<p>I have done it 3 times already. Could I create a script that does all
this automatically?</p>
</div>
</div>
<div id="latex" class="section level1">
<h1>Latex</h1>
<ul>
<li><a
href="http://www.utc.fr/~jlaforet/Suppl/latex-cheatsheet.pdf">Latex
cheat sheet</a></li>
</ul>
<div id="diff" class="section level2">
<h2>Diff</h2>
<p>Install Latex diff on Debian:</p>
<pre><code>sudo apt install latexdiff</code></pre>
<div id="latexdiff-and-git" class="section level3">
<h3>Latexdiff and git</h3>
<div id="latexdiff-git" class="section level4">
<h4>Latexdiff-git</h4>
<p>Latexdiff can handle files in version control systems. I didn’t know
this and checked out the old file by hand before performing the
comparison. First I describe the way I should have done it as explained
in man latexdiff-vc</p>
<pre><code>latexdiff-git -r rev1 -r rev2 eutr_impact.tex
mv eutr_impact-diff*.tex eutr_impact.tex
latexmk -pdf -bibtex -f template.tex</code></pre>
<p>You can also use <code>--flatten</code>:</p>
<blockquote>
<p>“The generic usage of this function is :”latexdiff-vc –flatten -r
rev1 [-r rev2] master.tex” where master.tex is the project file
containing the highest level of includes etc.”</p>
</blockquote>
<pre><code> latexdiff-git --flatten -r 5445bfd -r b47fefa template.tex
latexmk -pdf -bibtex -f template-diff5445bfd-b47fefa.tex</code></pre>
<p>But that document didn’t compile for some reason. So I used the
solution above with the diff made on the sub-document subsequently moved
to another document.</p>
<p><a
href="https://tex.stackexchange.com/questions/15121/error-when-trying-to-generate-a-pdf-from-a-latexdiff-document">You
may need to add some definiotniosn in the Latex preamble of the main
document</a></p>
<pre><code>%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF</code></pre>
</div>
<div id="without-latexdiff-git" class="section level4">
<h4>Without latexdiff-git</h4>
<p>Old way of doing things without using the latexdiff-vc helper.
Generate diff version of latex files. In the instructions below, the
manuscript was made of 2 documents <code>template.tex </code> which
called <code>\input{content.tex}</code>.</p>
<p>Checkout contents from commit 9ce6b9 on 2020 December 1st and prepare
the diff in the /tmp dir:</p>
<pre><code># Delete and re-create a temp dir and copy everything in it
rm -rf /tmp/article_diff/
cp -r ~/repos/article_pub /tmp/article_diff
# Copy the old and new versions of the manuscript to the tmp folder
cd ~/repos/article_pub/latex_template
git show 9ce6b9:./content.tex > /tmp/article_diff/latex_template/content_before_review.tex
git show 9ce6b9:./template.tex > /tmp/article_diff/latex_template/template_before_review.tex
cp content.tex /tmp/article_diff/latex_template/content_now.tex
cp template.tex /tmp/article_diff/latex_template/template_now.tex</code></pre>
<p>Generate the diff</p>
<pre><code>cd /tmp/article_diff/latex_template
latexdiff template_before_review.tex template_now.tex > template.tex
latexdiff content_before_review.tex content_now.tex > content.tex</code></pre>
<p>Compile the diff document, enter quiet mode with “Q” if there are
error messages</p>
<pre><code> latexmk -pdf -bibtex -use-make template.tex</code></pre>
</div>
</div>
</div>
<div id="fancy-headers" class="section level2">
<h2>Fancy Headers</h2>
<p><a href="https://tex.stackexchange.com/a/598241/44254">Fancy header
on cusom page widths</a></p>
<blockquote>
<p>“<code>\fancyhfoffset{0pt}</code> makes fancyhdr recalculate for each
page, based on the then current .”</p>
</blockquote>
<pre><code> \fancyhfoffset{0pt}</code></pre>
</div>
<div id="makefile" class="section level2">
<h2>Makefile</h2>
<p>Make can be use to automate the compilation of the latex file, place
the supporting figures and documents in a zip archive and subsequently
remove the intermediate files.</p>
<pre><code># Usage:
# make # Generate the pdf and zip files for the submission.
# make render # Render the pdf, keep all automatically generated files for Latex diagnostics.
# make clean # Keep a copy of the pdf one level above and remove automatically generated files.
# make zip # Generate the zip archive of the article and figures for the submission process.
#
all: render clean zip
render:
latexmk -pdf -bibtex -use-make forests-1032372-proofreading.tex
clean:
cp forests-1032372-proofreading.pdf ../manuscript.pdf || echo "forests-1032372-proofreading.tex not there."
git clean -xf
zip: # Remove the zip archive otherwise deleted files will remain in the archive and it will be simply updated
rm ../manuscript.zip ../figures.zip || echo "No existing zip archive to delete."
zip ../manuscript.zip -r *
zip ../figures.zip -r figures/*
echo "Verify that the pdf and zip archives have been updated by checking their update time."
ls -lh ../*.zip
ls -lh ../*.pdf</code></pre>
</div>
<div id="math" class="section level2">
<h2>Math</h2>
<div id="equation-numbering" class="section level3">
<h3>Equation numbering</h3>
<p>Equations written in the format below are numbered automatically.
It’s possible to set the counter to 8 so that equation numbering starts
at 9.</p>
<pre><code>\setcounter{equation}{8}
\begin{equation}
\sumᵢ\ cₒₙᵢfₑᵣₒᵤₛ{Fᵢ︐dᵗ} + \sumᵢ\ bᵣₒₐdₗₑₐᵥₑₛ Fᵢ︐dᵗ = 1
\end{equation}</code></pre>
</div>
<div id="spacing" class="section level3">
<h3>Spacing</h3>
<p>Overleaf <a
href="https://www.overleaf.com/learn/latex/Spacing_in_math_mode">spacing
in math mode</a> > Description of spacing commands</p>
<pre><code>LaTeX code Description
\quad space equal to the current font size (= 18 mu)
\, 3/18 of \quad (= 3 mu)
\: 4/18 of \quad (= 4 mu)
\; 5/18 of \quad (= 5 mu)
\! -3/18 of \quad (= -3 mu)
\ (space after backslash!) equivalent of space in normal text
\qquad twice of \quad (= 36 mu) </code></pre>
</div>
</div>
<div id="multicol" class="section level2">
<h2>Multicol</h2>
<p><a
href="https://ftp.gwdg.de/pub/ctan/macros/latex/required/tools/multicol.pdf">Documentation
of the Latex multicol package</a></p>
<pre><code>\begin{multicols}{⟨number ⟩}
⟨multicolumn text⟩
\end{multicols}</code></pre>
<blockquote>
<p>“It is often convenient to spread some text over all columns, just
before the multicolumn output, without any page break in be- tween. To
achieve this the multi- cols environment has an optional second argument
which can be used for this purpose. For exam- ple, the text you are now
reading was started with”</p>
</blockquote>
<pre><code>\begin{multicols}{3}
[\section{The User
Interface}] ...</code></pre>
</div>
</div>
<div id="lyx" class="section level1">
<h1>Lyx</h1>
<p>The Lyx “What You See is What You Mean” editor is available at Lyx
and from your package manager. Citations</p>
<p>Lyx nicely integrates with a bibtex bibliography. You can create a
shortcut such as CTRL+SHIFT+C to insert a reference. A small menu will
pop-up to choose from the references.</p>
<p>Unfortunately “BibTeX does not support files encoded in UTF-8”. To
get characters such as “é” encoded correctly latin1 has to be used.This
can be set as the database property in Jabref.</p>
<div id="shortcuts" class="section level2">
<h2>Shortcuts</h2>
<p>Under Tools / preferences / Editing / Shortcuts / Stackoverflow
question on how to find the command name for a shortcut. I mapped:</p>
<pre><code>citation-insert to Ctrl+Alt+C
href-insert to Ctrl+K
label-insert to Ctrl+Alt+L
statistics to Ctrl+Alt+T</code></pre>
<p>See also the Lyx wiki page on shortcuts.</p>
<p>Lyx shortcuts are storred in bind files. The default bind file is
called cua. To restore default bind file, one can simply delete the user
directory, as explained on this <a
href="https://latex.org/forum/viewtopic.php?t=21551">forum post</a></p>
<p>See also the setup directory where I saved a bind file.</p>
</div>
<div id="encoding" class="section level2">
<h2>Encoding</h2>
<p>Lyx wiki <a href="https://wiki.lyx.org/LyX/Unicode">unicode</a></p>
<blockquote>
<p>Since version 1.5, LyX uses Unicode internally; the LyX file is
always encoded in utf8.</p>
</blockquote>
<blockquote>
<p>The Menu Document>Settings>Language offers the Tab Encoding to
specify the encoding of the LaTeX-file LyX produces. It is described in
the UserGuide in Attachment A.6 “The Document Menu”: The encoding
specifies how the document content is exported to LaTeX</p>
</blockquote>
</div>
<div id="conversion-from-lyx-to-markdown" class="section level2">
<h2>Conversion from lyx to Markdown</h2>
<p>I use the encoding option mentionned above to convert to latex,
exported from lyx using the pdflatex format option. Then used pandoc to
convert from latex to markdown. It keeps the citation references which
is the most important thing I wanted to keep.</p>
</div>
<div id="install-dependencies" class="section level2">
<h2>Install dependencies</h2>
<div id="tex-packages" class="section level3">
<h3>Tex packages</h3>
<p>Tex packages are located at CTAN. Most of the time it’s sufficient to
install them from the Debian repository. Some times the debian
repository version is outdated. In that case you can try to install the
packages from the backports:</p>
<pre><code>sudo vim /etc/apt/sources.list
# Add deb http://ftp.debian.org/debian stretch-backports main
# Or a mirror, for example
# deb http://ftp.it.debian.org/debian stretch-backports main
sudo apt update
sudo apt-get -t stretch-backports install texlive-bibtex-extra</code></pre>
</div>
</div>
<div id="spell-checker" class="section level2">
<h2>Spell checker</h2>
<p>A spell checker can be activated under Tools / preferences / language
settings / spellchecker. On my system the only spell check engine
available is Enchant, “a wrapper that provides automatic access to many
spell checking libraries (ispell, aspell, hspell, hunspell, etc.)”.</p>
<p>The button displaying a red-underlined A can be activated to spell
check continuously. Language of document</p>
<p>Under Document / Settings / Language, it’s possible to change the
document language, which will have an impact on the language used for
spell checking. In my system compiling a document in French returned an
error:</p>
<pre><code>"Package babel Error: Unknown option `french'."</code></pre>
<p>This stackexchange post suggest installing the texlive-lang-french
Debian package. This fixed the error. Math mode</p>
</div>
<div id="encoding-1" class="section level2">
<h2>Encoding</h2>
<p>This question on “how do I prevent Lyx from loading inputenc?”
explains where this part of the Latex preamble is defined.</p>
<p>In Document > Settings…, under Language > Encoding, choose
“Other” and select “Language Default (no inputenc)”.</p>
<p>Instead I replaced Latin1 by utf8 as input encoding. This works for
the moment.</p>
<p>Instead I replaced Latin1 by utf8 as input encoding. This works for
the moment.</p>
</div>
<div id="math-1" class="section level2">
<h2>Math</h2>
<p>Press CTRL+M at the cursor or on highlighted text to enter math mode.
Latex syntax “”, “x_t” can be used to enter equations and is displayed
directly as math symbols. Change input encoding</p>
<p><a
href="https://tex.stackexchange.com/questions/153615/help-me-input-a-column-vector">How
to enter a column vector</a> Has recommendations on how to enter matrix
operations with sub-variables.</p>
</div>
<div id="fonts" class="section level2">
<h2>Fonts</h2>
<div id="icons" class="section level3">
<h3>Icons</h3>
<p>Font-awesome is available in the Debian Package
“texlive-fonts-extra”. It can be used in Lyx by insterting
<code>\usepackage{fontawesome}</code> in the Latex preamble. Then insert
an icon with:</p>
<pre><code>\faComments
\faWrench</code></pre>
</div>
</div>
<div id="encoding-issues-and-greek-symbols-used-outside-math-mode"
class="section level2">
<h2>Encoding issues and Greek symbols used outside math mode</h2>
<p>“Encoding file ‘lgrenc.def’ not found” was fixed by installing the
debian package texlive-lang-greek (as explained here on stackoverflow).
Other errors appeared related to the use of beta signs outside math
mode. As one user explained on stackoverflow, placing signs in math mode
usually fixes the issue. Hyperlinks in PDF</p>
</div>
<div id="how-to-change-hyperlink-colors-in-lyx" class="section level2">
<h2>How to change hyperlink colors in Lyx</h2>
<pre><code>Document &gt; Settings &gt; PDF Properties under the Additional options field. For example, a custom set of instructions may be the following: linkcolor=black, urlcolor=blue, citecolor=green, pdfstartview={FitH}, hyperfootnotes=false, unicode=true </code></pre>
<p>I changed marineblue to blue, as my system complained that marineblue
was not available.</p>
<p>The lyx function that creates hyperlinks is called href-insert. You
can create a CTRL+K shortcut that inserts hyperlink under Tools /
preferences / Editing / Shortcuts / “Cursor, Mouse and Editing
functions” by inserting the function name: href-insert. Presentation
template, called beamer</p>
<p>The beamer theme and color theme can be changed by inserting this in
Document / Seetings / Latex preamble:</p>
<pre><code>\usetheme{Boadilla}
\usecolortheme{orchid}</code></pre>
<p>An overview of themes is available in the beamer theme matrix.</p>
<p>Here is an explanation on how to change to any other RGB colour.
Beware the definition of RGB colours are unusual in Latex, divide values
by 255.</p>
<pre><code>\definecolor{darkgreen}{rgb}{.2,.4,.2}
\usecolortheme[named=darkgreen]{structure}</code></pre>
<p>Slide numbering can be added to the beamer template. By inserting
this code block in Document / Settings / latex preamble:</p>
<pre><code>\addtobeamertemplate{navigation symbols}{}{%
\usebeamerfont{footline}%
\usebeamercolor[fg]{footline}%
\hspace{1em}%
\insertframenumber/\inserttotalframenumber
}</code></pre>
<p>Tables too wide for a slide can be resized by placing the table
between the following ERT. If there is a table float, this instruction
has to be placed inside the table float.</p>
<pre><code>\resizebox{\linewidth}{!}{%
} </code></pre>
</div>
<div id="elsevier-article-template" class="section level2">
<h2>Elsevier article template</h2>
<p>Elsevier provides a latex template for articles called elsarticle
which is usable in Lyx. However compiling with this template doesn’t
seem to work when using the hyperref package with the general option
“automatically fill header”. After deactivating this option, compilation
works again.</p>
<p>The elsarticle template uses numerical references by default. it is
possible to activate author year reference according to this stack
exchange answer. Tips</p>
<pre><code>CTRL+D uses yap, a faster (on windows) previewer than the default PDF one. There is no noticeable difference on Linux.</code></pre>
</div>
<div id="other-templates" class="section level2">
<h2>Other templates</h2>
<p>To produce a meeting report with a wider template than the default
article.</p>
<pre><code>I would have liked to find an overview of the templates with screenshots of PDF results. But I couldn't find such overview online. LyX wiki has a list of examples and a list of layouts.
In fact all that was needed was to edit the Document \ Settings \ Page margins, I set the inner and out margins to 2 cm and was happy with the result.</code></pre>
</div>
<div id="knitr-and-lyx" class="section level2">
<h2>knitr and Lyx</h2>
<pre><code>Yihui Xie: Using knitr and Lyx
Krishna Devulapalli: Creation of research papers with embedded R results using LyX</code></pre>
<p>My Lyx file uses many packages and formatting options. Export to RTF
didn’t work and returned the error:</p>
<pre><code>"An error occurred while running: latex2rtf" </code></pre>
<p>I made a copy in a temporary directory (/tmp) and removed external
packages and options in the latex preamble, before performing the
conversion. Then the conversion to RTF worked.</p>
<p>Compare different versions of a document</p>
<p>Use Tools/Compare to highlight differences between a new and an old
document. Then show changes in output to show changes in red and blue in
the PDF output.</p>
<p>Alternatively, you can export the Lyx files to Latex and use
Latexdiff as such:</p>
<pre><code>latexdiff draft.tex revision.tex > diff.tex</code></pre>
<p>Avoid complex tables or figures in the diff, as they can cause
issues. I had to create a fake old documents with final figures and
table for latexdiff to return a usable output.</p>
</div>
</div>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open');
});
});
</script>
<!-- code folding -->
<script>
$(document).ready(function () {
// temporarily add toc-ignore selector to headers for the consistency with Pandoc
$('.unlisted.unnumbered').addClass('toc-ignore')
// move toc-ignore selectors from section div to header
$('div.section.toc-ignore')
.removeClass('toc-ignore')
.children('h1,h2,h3,h4,h5').addClass('toc-ignore');
// establish options
var options = {
selectors: "h1,h2,h3",
theme: "bootstrap3",
context: '.toc-content',
hashGenerator: function (text) {
return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
},
ignoreSelector: ".toc-ignore",
scrollTo: 0
};
options.showAndHide = true;
options.smoothScroll = true;
// tocify
var toc = $("#TOC").tocify(options).data("toc-tocify");
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>