10

Upon discussion and examining a few printouts (by my own printer) of some pages of a document, I decided to try and change the line widths to another default value, e.g. semithick (a little increase to 0.6pt from the default 0.4pt, which equal thin). The printouts by the big commercial machines in a shop might produce satisfactory results for thin but I'd like to do it the 'rather safe than sorry'-way.

How can one do this?

MWE

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage{
tikz,
pgfplots,
}

\usetikzlibrary{
intersections,
calc
}

\begin{document}
\begin{center}
    \begin{tikzpicture}
    \draw
    (0,0) coordinate (A)
    (3,3) coordinate (B)
    (0.5,1) coordinate (C)
    (2.5,1) coordinate (D)
    ;
    \draw[thick] (A) rectangle (B);
    \draw[orange, ultra thick, ->] (C) -- (D);
    \end{tikzpicture}
\end{center}
\begin{center}
    \begin{tikzpicture}
    \begin{axis}
    \addplot {rand};
    \end{axis}
    \end{tikzpicture}
\end{center}
\end{document}
12

On page 126 in "12.2.1 Creating a Picture Using an Environment", the TikZ manual provides the following information:

/tikz/every picture (style, initially empty)

This style is installed at the beginning of each picture.

\tikzset{every picture/.style=semithick}

Note that you should not use \tikzset to set options directly. For instance, if you want to use a line width of 1pt by default, do not try to say \tikzset{line width=1pt} at the beginning of your document. This will not work since the line width is changed in many places. Instead, say \tikzset{every picture/.style={line width=1pt}}. This will have the desired effect.

For creating the the intended effect on

  • axis line width,

  • plot line width,

  • grid line width and

  • legend line width,

I implemented the relevant code in the MWE. Implied and accepted is of course that \draw commands without any further detailed line widths will adhere to these settings.

If anyone has experience with this or spotted an error please do leave a comment or a reply with improvements.

Picture of Solution

enter image description here

Solution

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage{
tikz,
pgfplots,
}

\usetikzlibrary{
calc
}

%===================================================
%SOLUTION STARTS HERE - comment out to see change
%===================================================
\newcommand{\mybasiclinewidth}{semithick}
%source is page 126 in the manual
\tikzset{
every picture/.style={
\mybasiclinewidth} %or use: "`line width=1 pt,"<-- note:if you write line width, you must use a value with unit
}
\pgfplotsset{
every axis/.append style={
\mybasiclinewidth,
grid style={
    \mybasiclinewidth,
},
tick style={
    \mybasiclinewidth,
},
},
}
%===================================================
%SOLUTION ENDS HERE - comment out to see change
%===================================================

\newcommand{\linevertspace}{-0.3cm}

\begin{document}
\begin{center}
\begin{tikzpicture}[font=\footnotesize\sffamily]
\draw
(0,0) coordinate (thinLEFT)
($(thinLEFT)+(0,\linevertspace)$) coordinate (semithicktestLEFT)
($(semithicktestLEFT)+(0,\linevertspace)$) coordinate (semithickLEFT)
($(semithickLEFT)+(0,\linevertspace)$) coordinate (thickLEFT)
%
($(thinLEFT)+(3,0)$) coordinate (thinRIGHT)
($(semithicktestLEFT)+(3,0)$) coordinate (semithicktestRIGHT)
($(semithickLEFT)+(3,0)$) coordinate (semithickRIGHT)
($(thickLEFT)+(3,0)$) coordinate (thickRIGHT)
;
\draw[thin] (thinLEFT) -- (thinRIGHT) node [right] {thin};
\draw (semithicktestLEFT) -- (semithicktestRIGHT) node [right] {$\leftarrow$ default line width!};
\draw[semithick] (semithickLEFT) -- (semithickRIGHT) node [right] {semithick};
\draw[thick] (thickLEFT) -- (thickRIGHT) node [right] {thick};
\end{tikzpicture}
\end{center}
\begin{center}
    \begin{tikzpicture}
    \begin{axis}
    \addplot {rand};
    \end{axis}
    \end{tikzpicture}
\end{center}
\end{document}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.