Author Archive

Word Makros aus Powershell aufrufen

Hier ein Code-Schnipsel, um aus Powershell Word heraus zu starten und das Makro „Uwe“ auszuführen:

$Word = New-Object -Com Word.Application
$Word.Visible = $true
 
$oMissing = [System.Reflection.Missing]::Value
$Document = $Word.Documents.Add($oMissing, $oMissing, $oMissing, $oMissing)
$Word.Run("Uwe")

Hier noch als kleine Erweiterung die Speicherung des Dokuments im docm-Format mit Makros:

$Word = New-Object -Com Word.Application
$Word.Visible = $true
 
$oMissing = [System.Reflection.Missing]::Value
$Document = $Word.Documents.Add($oMissing, $oMissing, $oMissing, $oMissing)
 
# http://msdn.microsoft.com/en-us/library/bb238158%28v=office.12%29.aspx
$formatDOCM = [ref] 13
$Document.SaveAs([ref] "C:\testdoc.docm",$formatDOCM)
$Word.Run("Uwe")
 
$a = $Word.Quit()

Hinweis: Dieser Code wurde mit Word 2010 ausprobiert, Word 2007 beschwerte sich über die [ref] Konstrukte in den letzten Zeilen. Wenn man diese löscht, funktioniert es auch mit Word 2007.

Hinweis: Am 10.08.2017 angepasst, dank an Paula!

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Powershell: Lange Dateipfade ermitteln

Folgendes Skript gibt alle Dateien in eine Datei aus, deren Pfad länger als 240 Zeichen ist.

cd c:\
clear-host
$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size (600, 25)
gci -Recurse | ? { $_.fullname.length -gt 240} | Select-Object FullName | Out-File "c:\longfilenames-20110614.txt" -Width 350

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

XeLaTeX und Biolinum

Unter http://www.mrunix.de/forums/archive/index.php/t-64354.html findet man ein komplettes Beispiel, um die Biolinum Schrift unter XeLaTeX zu nutzen.

\documentclass[10pt]{scrreprt}
\usepackage{xltxtra} % für XeLaTeX
\setromanfont{Linux Libertine O} % Serifenschrift
\setsansfont{Linux Biolinum O} % serifenlose Schrift
\setmonofont{Courier New} % Schriftart für Code
\usepackage[ngerman]{babel} % Sprache
\usepackage[babel,german=guillemets]{csquotes} % Französische Anführungszeichen
 
\begin{document}
\enquote{text}
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

LaTeX im Word-Style

Es soll ja vorkommen, dass ein LaTeX Dokument aussehen soll, als wäre es mit Word geschrieben. Für diesen Fall kann man mit xelatex recht einfach die entsprechenden System-Schriften nutzen, selbst für den Formelsatz kann der entsprechende OT-Font genutzt werden. Wenn man dann noch die Farben der Überschriften und die Abstände anpasst, dann kommt man dem Word Design recht nahe. Betrachtet man jedoch das entsprechende Dokument genauer, so fällt der etwas bessere Formelsatz in LaTeX auf.

LaTeX

Word

\documentclass[11pt]{scrartcl}
\usepackage{xltxtra}
\usepackage[]{xkeyval,polyglossia}
\setmainlanguage[spelling=new]{german}
\usepackage[a4paper,top=2cm, bottom=2cm, left = 2.5cm, right=2cm]{geometry}
\usepackage[]{titlesec}
 
\usepackage{xcolor}
\definecolor{msdarkblue}{RGB}{54,95,145}
\definecolor{msblue}{RGB}{79,129,189}
 
%\titleformat{\section}[form]{layout}{labellayout}{abstand}{davorcode}[danachcode]
\titleformat{\section}[hang]{\color{msdarkblue}\Large\sffamily\bfseries}{}{0pt}{\vspace*{-6pt}}
\titleformat{\subsection}[hang]{\color{msblue}\large\sffamily\bfseries}{}{0pt}{\vspace*{-4pt}}
\titleformat{\subsubsection}[hang]{\color{msblue}\normalsize\sffamily\bfseries}{}{0pt}{}
 
\setsansfont[ItalicFont={Cambria Italic},BoldFont={Cambria Bold},BoldItalicFont={Cambria Bold Italic}]{Cambria}
\setmainfont[ItalicFont={Calibri Italic},BoldFont={Calibri Bold},BoldItalicFont={Calibri Bold Italic}]{Calibri}
\setmonofont[ItalicFont={Consolas Italic},BoldFont={Consolas Bold},BoldItalicFont={Consolas Bold Italic}]{Consolas}
 
\setlength{\parindent}{0pt}
\setlength{\parskip}{1em}
 
\usepackage{unicode-math}
\setmathfont{Cambria Math}
\begin{document}
 
\section{Überschrift 1. Ordnung}
\subsection{Überschrift 2. Ordnung}
\subsubsection{Überschrift 3. Ordnung}
 
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas pellentesque lobortis turpis, fringilla euismod nisi rutrum tempus. Etiam lorem sapien, aliquam sed tincidunt eget, congue vitae nisl. Ut quis metus vitae eros convallis fermentum eu quis nulla. Donec non iaculis enim. Nam commodo, justo quis aliquet ultrices, nisi est porttitor dui, sit amet scelerisque lacus lorem vitae nibh. Cras felis mi, venenatis a tincidunt non, tempor sit amet neque. Vivamus sodales purus neque, at semper ante. Aenean quis risus eros. Vestibulum convallis ligula erat, interdum tempus libero. Vivamus id libero non magna tincidunt sagittis vitae vitae neque. Proin blandit magna at dui porta lobortis. 
 
\texttt{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas pellentesque lobortis turpis, fringilla euismod nisi rutrum tempus. Etiam lorem sapien, aliquam sed tincidunt eget, congue vitae nisl. Ut quis metus vitae eros convallis fermentum eu quis nulla. Donec non iaculis enim.}
 
\begin{equation}
(x+a)^n = \sum_{k=0}^n \left(n\atop k \right) x^k a^{n-k}
\end{equation} 
 
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Copyright-Hinweis alle x Seiten einfügen

Von R. Niepraschk kommt der folgende Code, der nur alle x Seiten einen Copyright-Hinweis einblendet. Ein tolles Beispiel für eso-pic Magie…

\documentclass[fontsize=11pt,paper=a4,pagesize]{scrartcl}
 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{eso-pic,xcolor,graphicx}
\usepackage{blindtext}
 
\newcounter{pp}
\newcommand*\noBackground{3}
\newcommand*\copyrightText{Mein Text}
 
\AddToShipoutPicture{%
  \stepcounter{pp}%
  \ifnum\value{pp}>\noBackground %
    \setcounter{pp}{0}%
    \AtTextCenter{%
      \makebox(0,0)[c]{\resizebox{\textwidth}{!}{%
        \rotatebox{54.74}{\textsf{\textbf{%
          \color{lightgray}\copyrightText}}}}}%
    }%
  \fi
}
 
\begin{document}
 
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\blindtext \vfill \blindtext \newpage
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Multiple Inhaltsverzeichnisse mit minitoc

Hier ein kurzes Beispiel für minitoc. Es empfiehlt sich, die Anleitung genau zu lesen. 🙂

\documentclass[ngerman]{scrbook}
\usepackage[]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[]{minitoc}
 
\begin{document}
\dominitoc
\tableofcontents
 
\chapter{Foo}
\minitoc
\section{Hallo}
\subsection{a}
 
Ich bin ein Satz ohne Inhalt.
 
\subsection{b}
 
Ich bin ein Satz ohne Inhalt.
 
\chapter{Bar}
\minitoc
\section{Welt}
\subsection{a}
 
Ich bin ein Satz ohne Inhalt.
 
 
\subsection{b}
 
Ich bin ein Satz ohne Inhalt.
 
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Initialen mit LaTeX

Hier zwei Wege, Initialen in LaTeX zu verwenden, gefunden im Web:

\documentclass[ngerman]{scrreprt}
\usepackage{lettrine}
\usepackage[]{babel}
\begin{document}
 
\lettrine{L}{orem} ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
 
\end{document}
\documentclass[ngerman]{scrreprt}
\usepackage{yfonts}
\usepackage[]{blindtext}
\usepackage[]{babel}
 
\begin{document}
 
\yinipar \blindtext
 
\end{document}

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Folien vom Arduino Workshop in Troisdorf

Hier die Folien zum Arduino-Workshop bei der Trolug in Troisdorf.

Arduino-Slides (PDF)

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Nano für Windows

Nano, den schlanken Linux-Editor für die Kommandozeile, gibt es unter http://www.nano-editor.org/dist/v2.2/NT/ auch für Windows.

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website

Kumulative Summe mit T-SQL

Hier ein kurzes Beispiel, wie man mit T-SQL eine kumulative Summe ausrechnet.

CREATE TABLE #test(datum DATE, VALUE INT)
 
INSERT INTO #test VALUES('2010-01-01',10)
INSERT INTO #test VALUES('2010-01-02',20)
INSERT INTO #test VALUES('2010-01-02',30)
 
SELECT t1.*, (SELECT SUM(VALUE) FROM #test t2 WHERE t2.datum<=t1.datum) [cumulative amount]
FROM #test t1
ORDER BY t1.datum
DROP TABLE #test

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website