\newcommand{\resumeProjectHeading}[2]{ \item \begin{tabular*}{1.001\textwidth}{l#{\extracolsep{\fill}}r} \textit{\small#1} & \textbf{\small #4} \\ \end{tabular*}\vspace{-7pt} }
This is giving me the error
Illegal parameter number in definition of \resumeProjectHeading.
I am not able to understand that which part I need to rectify. Please help.
I tried putting #1 and #4 in curly braces. Still it did not help.
Related
I tried \verb|\{|, and it will print \{. If using \verb|{| without the backslash, an error would occur that says ! File ended while scanning \TX#get#body
Use the following to replicate this error on Overleaf or WinEdt:
\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{table}
\begin{tabularx}{\textwidth}{ll}
\hline
\verb|{| & Error. \\ % The use of \verb|{| here generates the error!
\hline
\end{tabularx}
\end{table}
\end{document}
I the above code, "\verb|{|" will generate the error.
With the kind help from samcarter_is_at_topanswers.xyz, I understand now that "{" can be displayed in tabularx using \listinline{{}. But this gives a plain-text style "{". Is there a way to make the "{" more code style? See the below picture for comparison.
You can use the listings package:
\documentclass{article}
\usepackage{tabularx}
\usepackage{listings}
\begin{document}
\begin{table}
\begin{tabularx}{\textwidth}{lX}
\hline
\lstinline{\}} & Error. \\
\hline
\end{tabularx}
\end{table}
\end{document}
Hi I'm new to LaTeX and I'm having some troubles in write a Use Case Specification using the style in this picture.I've tried using listings but i can't succeed in underlying some words.Anyone can help me?
I made a command so you can easily without much typing make multiple usecases, this is the complete latex code with 1 example, you can modify the command, it takes 5 parameters and you can access them with the #:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{enumitem}
\newcommand{\spec}[5]{
\begin{description}
\item[\underline{SpecificaUseCase}] #1 \\
#2
\begin{itemize}[noitemsep,topsep=-8pt]
\item[] \underline{pre}: #3
\item[] \underline{post}: #4
\end{itemize}
\item[\underline{FinalSecifica}] #5 \\
\end{description}
}
\begin{document}
\spec{usecasename}{method}{pre stuff}{post stuff}{final}
\end{document}
The result of this code is somthing like this:
I am having trouble using \midrule in a latex longtable along with brackets. For example, here is my latex document (test.tex):
\documentclass[a4paper]{article}\usepackage[]{graphicx}\usepackage[]{color}
\usepackage{longtable}
\usepackage{booktabs}
\begin{document}
\begin{longtable}{|l|l|}
\caption{} \\
\toprule
test & estimate\\
\midrule
(Intercept) & 10.000 \\
test & 20.000 \\
\bottomrule
\end{longtable}
\end{document}
When running pdflatex on this file:
pdflatex test.tex
I run into these errors:
! Undefined control sequence.
<argument> ...al \expandafter \let \cmrsideswitch
\#tempa \fi \fi
l.12 (Intercept)
& 10.000 \\
Removing the brackets fixes the issue. And interestingly switching the order of the 2 rows works too [i.e. the (Intercept) row as the second row). I can't figure out what is wrong. Has anyone encountered this?
OK, so I had the same problem with code generated from Pandoc (with bracket after \toprule), I fixed it by using \toprule{} instead, it seems that toprule eats the bracket otherwise. Maybe this will help you.
Another possibilty is to put empty \hbox{} before the opening bracket, which I used, since I could not modify tex produced by pandoc (but pandoc is capable of parsing latex snippets in markdown).
I'm setting up a new environment for my latex document for consistent tables. It looks like this:
\newenvironment{defaultTable}[2] {
\begin{table}[h]
\noindent
\tabularx{\textwidth}{#1}
\specialrule{0.5pt}{10pt}{0pt} \rowcolor[gray]{.9}
} {
\bottomrule
\endtabularx
\caption{#2}
\end{table}
}
It doesn't seem to find the \end{table} though:
! LaTeX Error: \begin{table} on input line 23 ended by \end{document}.
Is there a way to avoid this?
Replace \begin{table} with \#float{table} and replace \end{table} with \end#float.
The \#float and \end#float are LaTeX's internal commands for starting and ending the float environment.
You'll also want to follow Alexey's advice on the #2 parameter. Store it in the first part of your environment (\gdef\mycaption{#2}) and then recall it later \caption{\mycaption} in the second part. Put \def\mycaption{\relax} just before the \begin{defaultTable} line.
Also, since \#float and \end#float have # signs in them, if this code is in the preamble of your document file (instead of say, a .sty file), you'll need to put \makeatletter before your \begin{defaultTable} and also \makeatother after \end{defaultTable}.
You can use #2 in the end if you use the xparse mechanism:
\usepackage{xparse}
\NewDocumentEnvironment{defaultTable}{+m+m}{%
\begin{table}[h]
\noindent
\tabularx{\textwidth}{#1}
\specialrule{0.5pt}{10pt}{0pt} \rowcolor[gray]{.9}
} {%
\bottomrule
\endtabularx
\caption{#2}
\end{table}
}
You can not use #2 in the last argument of the \newenvironment macros. You should use #1..#9 in the second argument only.
Save your #2 to \tempa (or any macros). And use \tempa in the caption.
\newenvironment{defaultTable}[2]{
\begin{table}[h]
\def\tempa{#2}
\noindent
\tabularx{\textwidth}{#1} \specialrule{0.5pt}{10pt}{0pt} \rowcolor[gray]{.9}
}{
\bottomrule
\endtabularx
\caption{\tempa}
\end{table}
}
I've has the same problem, and it is because of the "\end{tabularx}". The solution is:
\newenvironment{defaultTable}[3] {
\begin{table}[h]
\caption{#2}
\noindent
\begin{tabularx}{\textwidth}{#1}
\specialrule{0.5pt}{10pt}{0pt} \rowcolor[gray]{.9}
#3
\bottomrule
\end{tabularx} } {
\end{table} }
So you define the rows as a parameter.
Regards,
Eric
You could also just use a \newcommand similar to Eric's solution.
\documentclass{article}
\usepackage{tabularx}
% The table design.
\newcommand{\defaultTable}[2]{
\begin{table}[h]
\begin{tabularx}{\textwidth}{cc}
Column A & Column B \\
#2
\end{tabularx}
\caption{#1}
\end{table}
}
\newcommand{\defaultTableRow}[2]{#1 & #2 \\}
\begin{document}
% The creation of a table.
\defaultTable{Example}{
\defaultTableRow{bla}{0815}
\defaultTableRow{blup}{0815}
}
\end{document}
This will avoid both your problems (the missing \end{table} and the error when referencing arguments in the environments closing code) without much hassle.
In fact I also like the idea of separating the table design from the table data. Especially if you create multiple tables that need to look equal.
I'm currently writing an API document in LaTeX. I have a tabular environment with a list of error codes and descriptions, like so:
\begin{tabular}{|c|l|}
\hline
\textbf{Code} & \textbf{Description} \\ \hline
1 & (description of error 1) \\ \hline
2 & (description of error 2) \\ \hline
\end{tabular}
At various places later in the document, I reference an error's code and its description together, like so:
Possible error conditions:
\begin{itemize}
\item 1---(description of error 1)
\end{itemize}
I want to automate this process so I don't have to retype the descriptions every time. I have tried using a counter, labels, and the \savebox command, but it's pretty cumbersome:
\newcounter{error}
% Inside the tabular environment:
\newsavebox{\ErrorOne}
\savebox{\ErrorOne}{(description of error 1)}
\refstepcounter{error} \label{ErrorOne} \arabic{error} & \usebox{\ErrorOne} \\ \hline
and later, to reference the error,
\ref{ErrorOne}---\usebox{\ErrorOne}
I particularly object to having to use ErrorOne for the labels but \ErrorOne (with the leading backslash) for the saveboxes. I also don't really want names like ErrorOne, since I might need to change the order at some point. What I want is to be able to define a few commands:
\newerror{errorlabel}{Description} % defines the error (doesn't output anything)
\errorcode{errorlabel} % outputs the error code
\errordesc{errorlabel} % outputs the error description
and then be able to say something like
\newerror{ArgumentError}{Too many arguments}
\newerror{DatabaseError}{Could not connect to database}
% Inside the tabular environment:
\errorcode{ArgumentError} & \errordesc{ArgumentError} \\ \hline
\errorcode{DatabaseError} & \errordesc{DatabaseError} \\ \hline
% Later on:
\errorcode{DatabaseError}---\errordesc{DatabaseError}
with the error codes (1, 2, 3, ...) being automatically generated like labels would be.
Any ideas?
The following works for me
\catcode`\#=11
\newcounter{error}
\def\newerror#1#2{\refstepcounter{error}%
\expandafter\xdef\csname errno##1\endcsname{\arabic{error}}%
\expandafter\xdef\csname errds##1\endcsname{#2}%
}
\def\errorcode#1{\expandafter\printerrinfo \csname errno##1\endcsname}
\def\errordesc#1{\expandafter\printerrinfo \csname errds##1\endcsname}
\def\printerrinfo#1{\ifx#1\relax\errmessage{Error code is invalid}%
\else\expandafter#1\fi}
\catcode`\#=12
\newerror{ArgumentError}{Too many arguments}
\newerror{DatabaseError}{Could not connect to database}
\errorcode{DatabaseError}---\errordesc{DatabaseError}
In your preamble, create new commands for each error, then just call the command:
\newcommand{\errorone}{this is the error and its description}
then in the body, just call the new command:
\begin{tabular}{|c|l|}
\hline
\textbf{Code} & \textbf{Description} \\ \hline
1 & \errorone \\ \hline