LaTeX Table Background Color for TeXit

Problem

In my previous post about LaTeX tables, I used \cellcolor{white} to override the \rowcolor{cyan} in a cell in the leftmost column, which was the column type name.

On Discord, that cell became black because TeXit inverted black and white.

LaTeX table with TeXit problem

Discussion

I first tried blending black and white, and I found that black!27 and black!28 give a good approximation to Discord’s background color.

Thanks to this Discord Color Palette and a bot command channel on a server, I’ve observed that the desired color is RGB(54,57,62).

[Read More]
LaTeX  TeXit 

LaTeX Multirow Multicol Table Coloring

Inspiration

Number of two-digit numbers not containing the digit ‘8’.

Code

  • The standalone class can’t be used with \caption.
  • *{8}{c} means 8 c.
  • >{\columncolor{cyan}}c gives the column color. It \usepackage[table]{xcolor}.
  • \rowcolor{cyan} overrides the column colors.
  • \cellcolor{white} overrides the above two commands. It has to be carried out one-by-one without any fancy package.
  • \multicolumn{n}{<alignment>}{content} defines a multi-column cell.
  • \multirow{n}{*}{content} defines a multi-row cell. It \usepackage{multirow}. It can’t contain \multicolumn.
  • \cline{i-j} draws a horizontal line above the row from column i to column j.
  • No fancy way of coloring multirow cells without fancy packages.
  • \multirow{-9} at the last row creates a cell spanning nine rows from bottom to above, so that its content won’t be covered by colors of former rows.
  • \rotatebox[origin=[clr]]{angle}{content}: rotate content by angle anticlockwise with [clr] as the rotation center.
\documentclass[12pt]{article}
\usepackage{multirow}
\usepackage[table]{xcolor}
\usepackage{tikz}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Sample \LaTeX{} multirow table}
\vspace*{1ex}
\label{multiprogram}
\begin{tabular}{|c|c|*{8}{c}>{\columncolor{cyan}}cc|}
\hline
\multicolumn{2}{|c|}{\multirow{2}{*}{}} & \multicolumn{10}{c|}{unit digit} \\\cline{3-12}
\multicolumn{2}{|c|}{} & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 \\\hline
& 1 & &  &  &  &  &  &  &  &  &  \\
& 2 & &  &  &  &  &  &  &  &  &  \\
& 3 & &  &  &  &  &  &  &  &  &  \\
& 4 & &  &  &  &  &  &  &  &  &  \\
& 5 & &  &  &  &  &  &  &  &  &  \\
& 6 & &  &  &  &  &  &  &  &  &  \\
& 7 & &  &  &  &  &  &  &  &  &  \\
\rowcolor{cyan} \cellcolor{white}
& 8 & &  &  &  &  &  &  &  &  &  \\
\multirow{-9}{*}{\rotatebox[origin=c]{90}{tens digit}}
& 9 & &  &  &  &  &  &  &  &  &  \\\hline
\end{tabular}
\end{table}
\end{document}

Result:

[Read More]
LaTeX  table 

Dvisvgm's Issue With Fill Pattern

Goal

Generate SVG file for TikZ graphics.

Method

  1. TeX → PDF with PDFLaTeX
  2. PDF → SVG with dvisvgm -P filename

Example: I generated a PGF plot from the source code on my personal template.

working SVG
working PDF
Git Bash for PDF
Git Bash for SVG

Problem

When I applied this method to the following TeX code in my previous post, dvisvgm -P returns a blank SVG.

\documentclass[tikz,border=2pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.6}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{axis}[axis lines=center,legend style={at={(0.7,0.7)},anchor=south west}]
\addplot [domain=-3:3, thick, smooth, yellow] { 1/sqrt(2*pi)*exp(-x^2/2) };
\addlegendentry{$y = \frac{1}{\sqrt{2\pi}} e^{-x^2/2}$};
\addplot [dashed, yellow] coordinates {(1.5,0) (1.5,0.14)};
\addlegendentry{99th percentile};
\addplot[domain=-3:1.5, pattern=north east lines,draw=none, fill opacity=0.3]
  { 1/sqrt(2*pi)*exp(-x^2/2) } \closedcycle;
\end{axis}
\end{tikzpicture}
\end{document}

This code passes the compiler.

[Read More]
LaTeX  dvisvgm  SVG 

First Experience with ASP.NET Core MVC & PostgreSQL

Goal

To build an ASP.NET Core 5 MVC web app linked with a PostgreSQL.

Motivation

  1. SQL Server is proprietary.
  2. SQLite used in Microsoft’s ASP.NET Core 5 MVC tutorial isn’t made for web apps.
  3. MySQL doesn’t perform well with concurrent read-writes. It’s dual-licensed like GitLab.
  4. Some users find PostgreSQL cost-effective.

Useful tutorials

  1. MS’s tutorial in item 2 above.
  2. Wes Doyle’s YouTube video goes through the steps
  3. MS’s tutorial for Razor Pages with EF Core migrations

Steps

  1. Create a superuser in the database.

    [Read More]

GIMP w'ont Start after Ubuntu Distro Upgrade

Problem

After upgrading to Ubuntu 20.04 form 18.04, I wasn’t able to start GIMP 2.10. The message was in the same format as that in a related Ask Ubuntu question, except that the version numbers were greater.

I attempted installing the package gegl, which was irrelavant to the problem.

Analysis

I found the answers mentioning the package libgegl helpful.

$ dpkg -l | grep gegl
ii  gegl                                       0.4.22-3                         
     amd64        Generic Graphics Library Test Program
ii  libgegl-0.4-0:amd64                        1:0.4.18+om-0ubu18.04.18~ppa     
     amd64        Generic Graphics Library
ii  libgegl-common                             1:0.4.18+om-0ubu18.04.18~ppa     
     all          Generic Graphics Library - common files

Despite deletion of ppa:otto-kesselgulasch/gimp by ppa-purge, that leaves a trace in /etc/apt/sources.list.d.

[Read More]
Ubuntu  GIMP 

Recover Mysql Root Password

Just a little linklog to a relevant page on How to Forge. Root privileges are needed.

  1. Stop service: service mysql stop

  2. Start MySQL server w/o password: mysqld_safe --skip-grant-tables &

  3. Connect to CLI client as root: mysql -u root

  4. Reset root password. Here’s the syntax for ≥v.5.7.6.

    mysql> use mysql;
    mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("newpass");
    mysql> flush privileges;
    mysql> quit
    
  5. Repeat step 1, or killall mysqld if it doesn’t work. Output can be different on different Linux distro.

    [Read More]
MySQL 

Pandoc LaTeX Mermaid on GitLab CI

Goal

To provide an open-source alternative to the Docker image escalope/pandoc-mermaid-plantuml, whose Dockerfile isn’t available.

The rationale behind these difficult setup is simple: construct informative Mermaid diagram with intuitive Markdown syntax in an open-source and economic way.

This newly constructed Docker image is entirely on GitLab. No Docker Hub account is needed. For sample usage, consult .gitlab-ci.yml in my test project.

Difficulties

  1. issues raghur/mermaid-filter#51 and #52
  2. issue gitlab-org/gitlab-runner#4566

Useful code/articles

  1. time-machine-project/requests-for-comments@470b0c5 Dockerfile
  2. Reduce Docker Image Sizes Using Alpine
  3. Best practices for building docker images with GitLab CI with the accompanying gist
  4. The code block in the highlighted comment in item 2 of the above section
  5. pandoc installation for Docker
  6. Sample Dockerfile for Alpine Linux in the troubleshooting of Puppeteer
  7. sc250024/docker-mermaid-cli@3c9ddb5 src/puppeteerConfigFile.json
  8. raghur/mermaid-filter project README’s section about Puppeteer config file

Network Interface Name Detection in Conky

Once-off Conky config for network graphs

When one changes connection type (say, from ethernet to Wi-Fi), the interface name changes (e.g. eth0wlan1). To avoid changing Conky config file all the time, here’s a little Lua function for finding the network interface name.

function findInterface()
    local handle = io.popen('ip a | grep "state UP" | cut -d: -f2 | tr -d " "')
    local result = handle:read('*a'):gsub('\n$','')
    handle:close()
    return result
end
  1. ip a gives everything about connection info. Each entry looks like

     3: wlp3s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    
  2. Grep the “state UP” and extract the second field, using : as a delimiter. Trim off the spaces around.

    [Read More]
Conky  Lua 

CPU Temperature Display in Conky

Background

I’m using Conky for monitoring the system. After a system upgrade, the CPU temperatures were gone. Conky’s standard error showed the following.

Conky: can't open '/sys/class/hwmon/hwmon0/temp3_input': No such file or
directory please check your device or remove this var from Conky...

Source of message: https://bbs.archlinux.org/viewtopic.php?id=82231

An easy fix would be to adjust the following lines in .conkyrc according to the number N in /sys/class/hwmon/hwmonN containing the file temp3_input. (You may adjust the number 3 according to the number of CPU of your device.) The number of CPU can be found using grep -c ^processor /proc/cpuinfo.

[Read More]
Conky  CPU  Linux 

Animated GIF Screenshots on Ubuntu

Background

I’ve to take screenshots to demonstrate Conky’s visual output.

animated GIF screenshot taken by Byzanz

I’ve chosen Byzanz after reading this answer on Ask Ubuntu.

Peek is more user-friendly, but I prefer CLI’s precision. That’s feasible thanks to a comment mentioning xwininfo.

After typing xwininfo, click on the target window. Switching to adjacent workplace is possible.

$ xwininfo
xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x1c0000a "Desktop"

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1920
  Height: 1080
  Depth: 32
  Visual: 0x1a7
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x1c00009 (not installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  -0+0  -0-0  +0-0
  -geometry 1920x1080+0+0

The --x and --y parameters below correspond to the absolute upper-left position of the window.

[Read More]