I'm getting a little bit lost with the following. As I'm quite new to using TeX
for more than just typesetting, I hope to get some help here.
I already searched this forum for some helpful posts and found many of them, but I didn't got all problems solved I ran into.
What I want to do is to automatically typeset a list of IP addresses and the corresponding FQDNs
into a table. It should look like:
Source: IP1:FQDN1;IP2:FQDN2;...
| IP1 FQDN1
Hosts | IP2 FQDN2
| ... ...
Here's what I tried to do (shortened down the code to the essential piece):
\documentclass{article}
\usepackage{xstring}
\usepackage{multirow}
\begin{document}
% test input
\newcommand{\myinput}{IP1:FQDN1;IP2:FQDN2}
\newcommand{\splitstring}[1]{
% split input into table rows
\ifx\@empty#1\else
\saveexpandmode\expandarg
% split column elements with leading & (after multirow)
\StrSubstitute{\tmp}{;}{\empty\\&}[\tmp] % fails with: forbidden control sequence found while scanning use of \@xs@next
% split row elements
\StrSubstitute{#1}{:}{&}[\tmp]
\restoreexpandmode\tmp
}
\begin{tabular}{l|ll}
% StrCount fails (Missing number, treated as zero)
\multirow{\StrCount{\myinput}{:}}{*}{Hosts} & \splitstring{\myinput}
\end{tabular}
\end{document}
Edit
Some additional information: Changing the line
\StrSubstitute{\tmp}{;}{\empty\\&}[\tmp]
to
\StrSubstitute{\tmp}{;}{\empty\\}[\tmp]
(and removing the &
) makes this step build without errors.
The output looks like this:
| IP1 FQDN1
Hosts |
IP2 | FQDN2
As you can see the &
is needed for correct alignement in the table.
I'm wondering why the substitution of ":"
by "&"
works without error, but this one fails.
No further news on feeding the StrCount
output into the multirow-environment.
Edit
I'm not sure if I can use the output from the xstring-functions
for typesetting or if they can be converted to be used as parameters.
Any help is greatly appreciated.
IP:FQDN;
type? The reason why I'm asking is to understand whether I can use;
as the row separator and:
as the column sparator for a possiblepgfplotstable
answer.;
is the row sep and:
is the column sep. Already thought about doing it the pfg/tikz way. But got stuck in the tex-solution ;) Looking forward for your ideas. Thanks in advance;
and use either a new line or `\\`