diff --git a/assets/css/custom.css b/assets/css/custom.css index e69de29..c7e4884 100644 --- a/assets/css/custom.css +++ b/assets/css/custom.css @@ -0,0 +1,5 @@ +/* works okay in light or dark mode with friendly hugo chromastyle */ +.language-latex {color: gray} +.language-bash {color: gray} +.language-make {color: gray} +.language-txt {color: gray} \ No newline at end of file diff --git a/assets/css/syntax.css b/assets/css/syntax.css new file mode 100644 index 0000000..d0ff5a8 --- /dev/null +++ b/assets/css/syntax.css @@ -0,0 +1,82 @@ +/* Background */ .chroma { background-color: #f0f0f0 } +/* Other */ .chroma .x { } +/* Error */ .chroma .err { } +/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; } +/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; width: auto; overflow: auto; display: block; } +/* LineHighlight */ .chroma .hl { display: block; width: 100%;background-color: #ffffcc } +/* LineNumbersTable */ .chroma .lnt { margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f } +/* LineNumbers */ .chroma .ln { margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f } +/* Keyword */ .chroma .k { color: #007020; font-weight: bold } +/* KeywordConstant */ .chroma .kc { color: #007020; font-weight: bold } +/* KeywordDeclaration */ .chroma .kd { color: #007020; font-weight: bold } +/* KeywordNamespace */ .chroma .kn { color: #007020; font-weight: bold } +/* KeywordPseudo */ .chroma .kp { color: #007020 } +/* KeywordReserved */ .chroma .kr { color: #007020; font-weight: bold } +/* KeywordType */ .chroma .kt { color: #902000 } +/* Name */ .chroma .n { } +/* NameAttribute */ .chroma .na { color: #4070a0 } +/* NameBuiltin */ .chroma .nb { color: #007020 } +/* NameBuiltinPseudo */ .chroma .bp { } +/* NameClass */ .chroma .nc { color: #0e84b5; font-weight: bold } +/* NameConstant */ .chroma .no { color: #60add5 } +/* NameDecorator */ .chroma .nd { color: #555555; font-weight: bold } +/* NameEntity */ .chroma .ni { color: #d55537; font-weight: bold } +/* NameException */ .chroma .ne { color: #007020 } +/* NameFunction */ .chroma .nf { color: #06287e } +/* NameFunctionMagic */ .chroma .fm { } +/* NameLabel */ .chroma .nl { color: #002070; font-weight: bold } +/* NameNamespace */ .chroma .nn { color: #0e84b5; font-weight: bold } +/* NameOther */ .chroma .nx { } +/* NameProperty */ .chroma .py { } +/* NameTag */ .chroma .nt { color: #062873; font-weight: bold } +/* NameVariable */ .chroma .nv { color: #bb60d5 } +/* NameVariableClass */ .chroma .vc { } +/* NameVariableGlobal */ .chroma .vg { } +/* NameVariableInstance */ .chroma .vi { } +/* NameVariableMagic */ .chroma .vm { } +/* Literal */ .chroma .l { } +/* LiteralDate */ .chroma .ld { } +/* LiteralString */ .chroma .s { color: #4070a0 } +/* LiteralStringAffix */ .chroma .sa { color: #4070a0 } +/* LiteralStringBacktick */ .chroma .sb { color: #4070a0 } +/* LiteralStringChar */ .chroma .sc { color: #4070a0 } +/* LiteralStringDelimiter */ .chroma .dl { color: #4070a0 } +/* LiteralStringDoc */ .chroma .sd { color: #4070a0; font-style: italic } +/* LiteralStringDouble */ .chroma .s2 { color: #4070a0 } +/* LiteralStringEscape */ .chroma .se { color: #4070a0; font-weight: bold } +/* LiteralStringHeredoc */ .chroma .sh { color: #4070a0 } +/* LiteralStringInterpol */ .chroma .si { color: #70a0d0; font-style: italic } +/* LiteralStringOther */ .chroma .sx { color: #c65d09 } +/* LiteralStringRegex */ .chroma .sr { color: #235388 } +/* LiteralStringSingle */ .chroma .s1 { color: #4070a0 } +/* LiteralStringSymbol */ .chroma .ss { color: #517918 } +/* LiteralNumber */ .chroma .m { color: #40a070 } +/* LiteralNumberBin */ .chroma .mb { color: #40a070 } +/* LiteralNumberFloat */ .chroma .mf { color: #40a070 } +/* LiteralNumberHex */ .chroma .mh { color: #40a070 } +/* LiteralNumberInteger */ .chroma .mi { color: #40a070 } +/* LiteralNumberIntegerLong */ .chroma .il { color: #40a070 } +/* LiteralNumberOct */ .chroma .mo { color: #40a070 } +/* Operator */ .chroma .o { color: #666666 } +/* OperatorWord */ .chroma .ow { color: #007020; font-weight: bold } +/* Punctuation */ .chroma .p { } +/* Comment */ .chroma .c { color: #60a0b0; font-style: italic } +/* CommentHashbang */ .chroma .ch { color: #60a0b0; font-style: italic } +/* CommentMultiline */ .chroma .cm { color: #60a0b0; font-style: italic } +/* CommentSingle */ .chroma .c1 { color: #60a0b0; font-style: italic } +/* CommentSpecial */ .chroma .cs { color: #60a0b0; background-color: #fff0f0 } +/* CommentPreproc */ .chroma .cp { color: #007020 } +/* CommentPreprocFile */ .chroma .cpf { color: #007020 } +/* Generic */ .chroma .g { } +/* GenericDeleted */ .chroma .gd { color: #a00000 } +/* GenericEmph */ .chroma .ge { font-style: italic } +/* GenericError */ .chroma .gr { color: #ff0000 } +/* GenericHeading */ .chroma .gh { color: #000080; font-weight: bold } +/* GenericInserted */ .chroma .gi { color: #00a000 } +/* GenericOutput */ .chroma .go { color: #888888 } +/* GenericPrompt */ .chroma .gp { color: #c65d09; font-weight: bold } +/* GenericStrong */ .chroma .gs { font-weight: bold } +/* GenericSubheading */ .chroma .gu { color: #800080; font-weight: bold } +/* GenericTraceback */ .chroma .gt { color: #0044dd } +/* GenericUnderline */ .chroma .gl { text-decoration: underline } +/* TextWhitespace */ .chroma .w { color: #bbbbbb } diff --git a/config/_default/config.toml b/config/_default/config.toml index 7352eb5..e4aefaf 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -22,12 +22,13 @@ pygmentsCodefencesGuessSyntax = true title = "Carl Pearson" author = "Carl Pearson" # copyright = "2020-2021" -description = "University of Illinois ECE PhD Student" +description = "Postdoctoral Appointee, Sandia National Labs. All opinions are my own." profilePicture = "img/avatar.jpg" keywords = "" favicon = "favicons/" # example ["css/custom.css"] -customCss = ["css/custom.css"] +# added css/syntax.css after hugo gen chromastyles --style=mannai > assets/css/syntax.css +customCss = ["css/custom.css","css/syntax.css"] # customCss = [] # example ["js/custom.js"] customJs = [] @@ -49,7 +50,7 @@ doNotLoadAnimations = true ## Math settings [params.math] enable = false # options: true, false. Enable math support globally, default: false. You can always enable math on per page. -use = "mathjax" # options: "katex", "mathjax". default is "katex". +use = "katex" # options: "katex", "mathjax". default is "katex". ## Social links # use 'fab' when brand icons, use 'fas' when standard solid icons. diff --git a/content/post/20210103-photoprism/index.md b/content/post/20210103-photoprism/index.md index c9c55ed..c3cf5f1 100644 --- a/content/post/20210103-photoprism/index.md +++ b/content/post/20210103-photoprism/index.md @@ -155,7 +155,8 @@ To start photoprism, run `sudo docker-compose up -d` You can look at logs with `sudo docker-compose logs`. you should not see anything like "failed to connect to database" If you goof this up, you need to do something like (this will delete everything) -``` + +``` bash sudo docker-compose down sudo docker volume prune sudo rm -r storage database @@ -172,7 +173,7 @@ First, create `/etc/nginx/sites-enabled/photoprism.example.com` Put the following content in it. This is taken from the PhotoPrism instructions, except `proxy_pass http://localhost:2342;` instead of `proxy_pass http://docker.homenet:2342;` -``` +```txt # PhotoPrism Nginx config with SSL HTTP/2 and reverse proxy # This file gives you an example on how to secure you PP instance with SSL server { @@ -273,7 +274,7 @@ I guess this causes the photoprism image to be restarted unless you explicitly s ## Get updates -``` +```bash docker-compose pull photoprism docker-compose stop photoprism docker-compose up -d photoprism diff --git a/content/post/20210418-latex/index.md b/content/post/20210418-latex/index.md new file mode 100644 index 0000000..9eebf84 --- /dev/null +++ b/content/post/20210418-latex/index.md @@ -0,0 +1,198 @@ ++++ +title = "Tips for Technical Writing in Latex" +date = 2021-04-18T00:00:00 +lastmod = 2021-04-18T00:00:00 +draft = false + +# Authors. Comma separated list, e.g. `["Bob Smith", "David Jones"]`. +authors = ["Carl Pearson"] + +tags = ["latex"] + +summary = "Accumulated tips for formatting technical writing in Latex" + +# Projects (optional). +# Associate this post with one or more of your projects. +# Simply enter your project's folder or file name without extension. +# E.g. `projects = ["deep-learning"]` references +# `content/project/deep-learning/index.md`. +# Otherwise, set `projects = []`. +projects = [] + +# Featured image +# To use, add an image named `featured.jpg/png` to your project's folder. +[image] + # Caption (optional) + caption = "" + + # Focal point (optional) + # Options: Smart, Center, TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight + focal_point = "Center" + + # Show image only in page previews? + preview_only = true + + +categories = [] + +# Set captions for image gallery. + + ++++ + +I recently finished my Ph.D thesis (yay!) and accumulated a few tips related to formatting technical writing in Latex. + +## Hyphenation and Line Breaks + +Many people are familiar with the `\hyphenation` command, which tells Latex where it may hyphenate words it does not already know about to prevent lines from being too long. +Latex will not know about many technical words, or function names that are not "plain english." +In English writing, line breaks should occur at syllable boundaries only. + +```latex +\hyphenation{cuda-Memcpy-Peer-Async bi-di-rec-tion-al} +``` + +You can also allow breaks at underscores, which is convenient for certain programming languages or libraries. + +```latex +\renewcommand\_{\textunderscore\allowbreak} +``` + +You may then want to *prevent* line breaks in some places. +Use `\mbox` for that. + +```latex +\mbox{\_\_device\_\_} +``` + +## lstlisting + +The `lstlisting` environment is used to add and format code in Latex documents. +You can use `minipage` to prevent short `lstlistings` from being broken across pages. +You can also use the `\noindent` command to prevent the `minipage` from being indented if it starts a new paragraph +The + +```latex +\noindent +\begin{minipage}{\linewidth} +\begin{lstlisting} +\end{lstlisting} +``` + +## SI units + +Use the `siunit` package to automatically format numbers with SI units. + +```latex +\usepackage[binary-units, group-separator={,}]{siunitx} +\SI{512}{\byte} +``` + + +## Digit grouping and separators. + +Latex can make it hard to manually format digit grouping and separators in numbers. +The `number` package makes this easy. + +```latex +\num{242000} +``` + +## CLI spell-checking + +You can use `aspell` with the Latex filter (to reduce false positives). +The `-t` flag puts it in Latex mode. + +```bash +aspell -t -c main.tex +``` + +## Latex and Version Control +Write one latex sentence on each line, so version control diffs are easier to follow. +It feels a little unnatural at first. + +```latex +This is one sentence. +This is another sentence. +``` + +## Latex and arxiv + +Arxiv does not want a raw PDF, annoyingly. +You can defined a makefile target that will create a zip for you to upload. +You'll need to tweak this to get all the files uploaded you need. +Arxiv usually wants the pre-processed `bib` file that ends in `bbl`, so you need to run `bibtex`. + +```make +arxiv: main.tex main.bib ${FIGS} + pdflatex ${PAPER}.tex + bibtex ${PAPER}.aux + rm -f upload.zip + zip -r upload.zip main.tex main.bbl figures acmart.cls ACM-Reference* +``` + +## Tables that are too wide or too tall + +Use `resizebox` for tables that are too wide or too tall (which is almost always the case, right???) + +To match the text width: + +```latex +\label{tab:related} +\resizebox{\textwidth}{!}{% +\begin{tabular}{...} +\end{tabular} +}%resizebox +\end{table*} +``` + +To match the text height: + +```latex +\label{tab:related} +\resizebox{!}{\textheight}{% +\begin{tabular}{...} +\end{tabular} +}%resizebox +\end{table*} +``` + + +## Reducing space between captions and figures + +I think there is too much wasted space between figures and captions in some templates. +You may be able to tweak this yourself with the `caption` package. + +```latex +\usepackage{caption} +\captionsetup{skip=1pt} +``` + +## Shortcuts for repeated formatting + +You may wish to repeatedly apply formatting to a particular word. +You can define your own command for that. +The `xpsace` command will try to be smart about whether to put a space after the word. + +```latex +\newcommand{\StreamData}{\textit{StreamData}\xspace} + +Now \StreamData is in italics. + +% notice the absence of \xspace +\newcommand{\DenseData}{\textit{DenseData}} + +When I use \DenseData{} I may need to put the braces afterwords to get a space. +``` + +# Figures and text + +Use the `pifont` package, and then the `\ding` command + +```latex +\usepackage{pifont} + +This: \ding{202} will make a black circle with a white "1" in it. +You can then draw a matching object in your figure. +\ding{203} will make a 2, \ding{204} will make a 3, etc. +``` \ No newline at end of file